Crystal Space
Welcome, Guest. Please login or register.
September 30, 2014, 01:49:06 pm

Login with username, password and session length
Search:     Advanced search
9020 Posts in 2053 Topics by 8556 Members
Latest Member: Boshyeng
* Home Help Search Login Register
  Show Posts
Pages: [1]
1  Associate Projects / CEL Discussion / Re: CELStart Python issues? on: April 28, 2009, 04:34:36 pm
What OS are you running; I'm guessing Windows since, if memory serves, that was the only case where I've seen that error... (unfortunately, it's been over a year now I think since I've played with celstart Sad ... I tried running my pycelstart example that I know used to work and got errorrs that I'll have to fix at some point )

Also, are there other python examples besides the dinosaur one posted that you're using to test?
2  Crystal Space Development / Support / Re: Some questions about how to insert net code in "simpmap"? on: March 05, 2009, 09:17:03 pm
Are you sure you're doing non-blocking sockets?  (and not doing something like while (!data = recv(100)))

I don't have any network code lying around, but basically, you should probably be doing something like either:

Option 1:  select based polling:
      add socket to r_fd; // man select should give you some examples
  select(&r_fd,&w_fd,&e_fd,0); // bah ... I can never remember the order of r,w,e
  if (check) // check to see if the socket is ready to be read
    recv(data,1000); //would block if there was nothing there, but select says it's safe
 
Option 2: non blocking sockets:
  //after creating sockets
   setsockopt(sock,SOCK_NBLOCK) ; //man setsockopt ... you probably need to include something and I'm blanking on the right flag

  in your process frames:

  retval = recv(data,1000); //read the man page ... if memory serves, 0 means no data, -1 means error, positive definitely indicates the number of bytes read... if you want to be slightly more robust, you can check errno ... EAGAIN (I think) indicates nothing was ready, other errors indicate things like the fact that the socket is dead so you'd want to either quit or try reconnecting.


Edit to add: if you haven't done so before, I'd strongly suggest you implement or at least take apart and minimally extend a non-blocking chat client/server (there should be plenty of tutorials on the web)... just using basic printf/gets to send/recv data over a network to avoid having to deal with both the complexities of networking and learning crystal space.
3  Crystal Space Development / Support / Re: Some questions about how to insert net code in "simpmap"? on: February 12, 2009, 12:31:31 am
Okay... I went back and looked at my code... I had migrated to using a thread (p_threads) so that I could get data from the server at a rate that was independent of the FPS calculations... having said that, the easiest thing to do is just put your recv() calls in ProcessFrame... you will have some delay (since if the server moves an object 3 units at time T, it may not be shown moving on the screen until T+k, where k is the delay to send across the wire + the delay between when the client gets the data and when ProcessFrame gets called... but assuming client and server are either on same machine or at least connected via LAN and your getting 30 fps, this shouldn't be the end of the world... I would suggest going that approach until you've played with CS more and only then worry about doing more advanced interpolation etc. (note that depending on what you're using (i.e. if you are using some of the cell behaviors that move objects for you), the delay may not be noticable... most of the time the server update is consistent with what CEL was dead reckoning you should be, and the rest is somewhat unavoidable just from the nature of the doing distributed processing)

So... did that answer your question or did you already try putting the recv() calls in processFrame? [Note that even in my code with threads, I basically had a get data loop in the separate thread to constantly update the client state (with some hand done dead reckoning if I hadn't gotten any updates from the server recently) and then in processFrame, I used to mutex to prevent doing stuff during an update of the local client state and then used the current client state to do all my positioning but I'd recommend avoiding threads during initial development (other than to keep them in mind) as I'm not a huge fan of debugging multi-threaded applications if I can help it]
4  Crystal Space Development / Support / Re: Some questions about how to insert net code in "simpmap"? on: February 09, 2009, 07:00:20 pm
Could you clarify what you mean by "in time".  More directly:
   What did you try already
   What type of sockets are you using (TCP or UDP)
   What type of I/O are you using (blocking or nonblocking)

A long time ago (before I opted to switch over to python / cel and then have my video card fail out) I had a fairly simple app built on top of simpmap that was set up to send stuff over non-blocking UDP sockets... if memory serves, I did both the send and receive in the same ProcessFrame function and don't recall having any problems as long as the amount of data was reasonably small (I had problems if I sent too much data from server to client and client started getting multiple messages glued together that it mistakenly treated as a single message  but that just required improving the message format.)
5  Crystal Space Development / Support / billboard question on: July 11, 2008, 04:07:56 am
Once upon a time (apparently it's been almost a year), I had a celzip file which contained some python code which featured clickable billboards. For whatever reason (probably I was doing something slightly wrong that the old version let slide and the new version isn't), that celzip file no longer registers the click events.  To try to keep this simple, I reduced my code to the simplest possible, and it's still not registering click events.  Also, I played quickly with the (XML-based versus Python-based) CrystalDash which also has billboards; those do work

Standard stuff Jorrit wants:


Version Info:
  celstart --version prints out 8
  running python version 2.5.1
   I believe I pulled down cs + cel via svn (using the default) on or around June 7th... cel version per celversion.h is 1.2.1
   Walktest also says I'm using CS 1.2.1 (April 2008) version
   (is there a better way to get the exact version that I'm forgetting?)

Hardware / OS Info
  Linux 32bit (Fedora Cool on x86 (Pentium Dual E2200, which is 64 bit capable but other apps were giving me fits under 64bit space)
  NVidia 8800 GT
  gcc 4.3.0

Code Fragment is below(hopefully the formatting won't be too badly off kilter (looked fine in preview):
Note that I checked the property classes in celEntity after creating the billboard and setting stuff up; the property with the description "Enable mouse events" has boolean value of True

class main:
   api_version = 2 # use new version of message callbacks.

   def pcbillboard_select(self,*args):
      print "Someone selected this billboard"

   def __init__(self,celEntity):
      self.c = celEntity
      message = "hello world"
      self.bg = celCreateBillboard(pl,celEntity)

      self.mygui = self.bg.GetBillboard()
      self.mygui.SetText(message)
      rez = self.mygui.SetMaterialNameFast('Stone')
      billboardsize = 307200 #magic number for BillBoard Space defined somewhere
      guiheight = self.mygui.GetTextDimensions()[1]
      self.mygui.SetSize(billboardsize-2000,guiheight*10)
      self.mygui.SetPosition(1000,100000)
      self.mygui.SetText(message)
      self.bg.EnableEvents(True)
6  Crystal Space Development / Support / Re: Bash build script for CS and cel on: March 20, 2008, 11:21:26 pm
I think you want to do
"cmd" >> $LOGFILE 2>&1

so for example, instead of

wget -q $CG_DOWNLOAD_URL >> $LOGFILE

do&

wget -q $CG_DOWNLOAD_URL >> $LOGFILE 2>&1

(adding the 2>&1 at the end of each line redirects stderr to stdout ... this always feels wrong to me (i.e. it'd feel more natural to do 2>&1 first and then the >> $LOGFILE, but meh)
7  Associate Projects / CEL Discussion / Re: need a file for celstart that isn't included in binary for windows on: November 13, 2007, 02:53:49 pm
I had mentioned that I had used it just fine with python 2.5 under linux, but remembered that I should caveat that with the fact that I built celstart under linux myself versus using the supplied one (and I can't test the prebuilt one anymore due to other issues)
8  Associate Projects / CEL Discussion / Re: need a file for celstart that isn't included in binary for windows on: November 09, 2007, 02:30:23 pm
can't help you then.  I just did a search on my windows drive and found no cspace.dll file (which should be what python loads when it sees import _cspace) but I can vouch that up until my video card died (leaving me with the onboard PoS), I was quite able to run celstart with python apps when using python 2.4  and got an error (which I am pretty sure is the one you're seeing but am not certain) when I had python 2.5 installed.  I did a grep in the celstart directory under windows and msvcrt.dll has cspace in it (but I can't remember how to do the equivalent of nm myobj.so to dump the dll symbol table (or else I can but it's been stripped) to see if it actually has the cspace code or if that's just a weird collision... it's possible that the cspace module is embedded inside that dll (and then possible but I'm stretching) that python 2.4 supported that somewhat bizarre behavior whereas 2.5 introduced stricter rules.

Good luck.
9  Associate Projects / CEL Discussion / Re: need a file for celstart that isn't included in binary for windows on: November 07, 2007, 04:23:58 pm
What version of python are you using (I'm assuming you installed Python first)... I've found that I need to use Python 2.4 to get celstart (the default binary) to work under Windows or I get that error.

Oops... meant to add that 2.5 works just fine under Linux with the latest celstart binary (even using the exact same celstart applications)
10  Crystal Space Development / Support / Re: Compiling CEL on: September 25, 2007, 01:25:02 am
I'm going to assume you have the cywin part right... but the export is definitely not correct... CRYSTAL should point to where the CrystalSpace stuff is, which should just be /cs, not /cs/cel (which eventually you should be setting the CEL variable to point to)

11  Associate Projects / CEL Discussion / Re: CelStart on: September 20, 2007, 03:18:30 pm
I'd suggest uninstalling python 2.5 and installing the latest python2.4 (i.e. the whole python2.4 env, not just the python24 dll).  I had the same issue with celstart 7 on windows (not sure if my linux is just old enough that i'm still running 2.4 or if this is a windows only issue... have noticed that I still need to futz with PythonPath under windows; linux works fine.)

editted to add:  Plug... I posted a python celstart example file to the celstart main page
(http://www.crystalspace3d.org/main/CELstart#Python_Based_Example_Demos.2FGames)


12  Associate Projects / CEL Discussion / Re: Error: appinit is not callable on: August 30, 2007, 04:09:36 am
I just posted my code to http://carletronicon.googlepages.com/mycelstartexample (click image to download).

Jorrit et al: is it permitted for me to just modify the celstart wiki page to add my example file / image or is there some procedure I'm missing to get approval?

13  Associate Projects / CEL Discussion / Re: Error: appinit is not callable on: August 24, 2007, 04:22:25 am
I agree it would be nice to have some python celzip's; I'm working on a simple app using python and celstart but I don't know if I'm doing this right (for example, I still haven't figured out how to get hover to work; if I try to create a new CraftController, the program immediately quits.  I am, however, making some progress and so can hopefully try to post something at some point so other people more experienced can tell me how to improve it and less can build off it, unless someone posts something better first.

Anyways, I suggest you add a line that appends pccommandinput to the PcFactories list

PcFactories.append("cel.pcfactory.pccommandinput")

(I have an initialization routine that does the following:


   def SetupFactories(self):
      pcclasses = ["region","tooltip","mesh","solid","meshselect","zonemanager","trigger", "quest","light","inventory","defaultcamera","gravity","movable",   "pccommandinput","linmove","actormove","colldet","timer","soundlistener", "soundsource","billboard","properties" ,"craft","hover","mechsys","mechobject"]
      for pcclass in pcclasses:
         PcFactories.append("cel.pcfactory."+pcclass)
         print "Added ",pcclass


I presumably adapted it from somewhere as I'm not using quest or light in my code at present, at least as far as I know)
14  Associate Projects / CEL Discussion / Re: Binding keyboard events to craft methods on: July 05, 2007, 02:53:31 pm
Thanks for the response, Genjix.
Unfortunately, the events are being fired just fine... the problem, as near as I can tell, is that I'm not doing the syntax of the XML correctly...

I would think that:
<event name="pccommandinput_forward1">
       <default propclass="?pccraft" />
       <action id="actid(ThrustOn)" />
     </event>

Means using propclass pccraft, apply the action "ThrustOn" ...

but if I replace actid(ThrustOn) with actid(ObviousilyBogusFunction) nothing changes and I don't get an error message.

At any rate, I'm in the middle of trying to upgrade my Linux box to the latest FC7 and then rebuild the latest CS/CEL and try again using python vs just the XML.

15  Associate Projects / CEL Discussion / Binding keyboard events to craft methods on: June 30, 2007, 03:02:57 am
Basically, trying to implement the CEL hoverdemo solely in XML (i.e. for celstart)

Using some of the sample celstart apps, I think it mostly working.  However, I can't get pressing keys to call the craft methods.

What I'm doing (and I can post the whole code somewhere if that would be easier)


    <addon plugin="cel.addons.xmlscripts">
      <!-- this is legacy! -->
      <pcfactory>cel.pcfactory.pccommandinput</pcfactory>
      <pcfactory>cel.pcfactory.defaultcamera</pcfactory>
      <pcfactory>cel.pcfactory.actormove</pcfactory>
      <pcfactory>cel.pcfactory.mesh</pcfactory>
      <pcfactory>cel.pcfactory.linmove</pcfactory>
      <pcfactory>cel.pcfactory.colldet</pcfactory>
      <pcfactory>cel.pcfactory.zonemanager</pcfactory>
      <pcfactory>cel.pcfactory.properties</pcfactory>
      <pcfactory>cel.pcfactory.mechsys</pcfactory>
      <pcfactory>cel.pcfactory.mechobject</pcfactory>
      <pcfactory>cel.pcfactory.hover</pcfactory>
      <pcfactory>cel.pcfactory.craft</pcfactory>   

        <script name="camera">
     <event name="realinit">
       <var name="pcmech" value="pc(pcmechobject)" />
       <var name="pccam" value="pc(pcdefaultcamera)" />
       <var name="pccraft" value="pc(pccraft)" />

     </event>

     <event name="pccommandinput_quit1">
       <quit/>
     </event>
     <event name="pccommandinput_forward1">
       <default propclass="?pccraft" />
       <action id="actid(ThrustOn)" />
     </event>
     <event name="pccommandinput_forward0">
       <default propclass="?pccraft" />
       <action id="actid(ThrustOff)" />
     </event>
(... more input events ...)

Also, in the entity object, I did specifiy that this entity should contain a propclass named pccraft and did a bunch of action name="SetXXX"><par name="xxx" float = "yy.y" /></action>'s


I do set up so that up arrow and w both map to forward and the original code (which called eval setforce(pcmesh)) did work...

Any thoughts what I'm missing?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 7.179 seconds with 16 queries.