Page 1 of 1

Controlling the x,y,z coords of any object programmatically

Posted: 26.05.2005, 23:24
by paulooch1958
Hi, I'm new to Celestia and would like to make a modification. I would like to be able to take control of an object (of course it's a spaceship!!) currently in the database and be able to load my own x,y,z coords in for each tick of the simulation. I suppose I would have to somehow delete, modify or ignore the trjectory info stored in memory for the object on the fly. If I do that wouldnt Celestia do the rest of the rendering, etc automatically for each new position? My problem is that I can't figure out where in th code the coords are updated for the individual objects. If I could find that part of the code, and culd somehow ID which object I was trying to control I think the rest would be pretty simple. Of course once you can do this, adding some AI to control the other ship is the logical next step.

Any pointers for me?

Btw Celestia is one of the coolest programs I have ever seen! I have wanted to write something like this for 15 years, so thanks for all the hard work and congradualtions on a truly spectaular achievement!

:idea:

Posted: 29.05.2005, 09:55
by maxim
I agree that I would be a very usefull feature to have the ability to control a xyz-trajectory from within a script. You may contact Harry. Perhaps he has some clue about such an approach.

maxim

Posted: 29.05.2005, 17:23
by paulooch1958
I'm not talking about using a script to control an objects position. I want to use c++ function calls from within Celestia itself so tthat I can write an AI routine that would be called at each Celestia tick that would set the new position of the object. I already found a call named "setPosition(x,y,z) " (or somethin clase to that anyway) that can be used to move stars whereever you want. Planets and obiting objects dont seem to have any real xyz coordinates until you visit them so I cant find a way to control those. The problem with using the planet model for creating programmable spacship control is that planets are dran as spheres with textures applied which wont work for a spaceship. I alteres one of the .dsc files that desccribed a nebula to use a spaceship .3ds file instead of the nebula file, then changed the radius and I had a spacship in Celesti that was independant of any planet or star. I havent had time yet to see if the deepspace objects have a setPosition(x,y,z) function yet. If they do, then I think I am pretty much there as far as having a programmatically controlled(not scripted) spaceship.

Posted: 30.05.2005, 01:02
by Verteiron

Posted: 30.05.2005, 10:47
by maxim
paulooch1958 wrote:I'm not talking about using a script to control an objects position. I want to use c++ function calls from within Celestia itself so tthat I can write an AI routine that would be called at each Celestia tick that would set the new position of the object.


Lua scripts have access to Celestia on each simulation tick. So if you expose internal objects via an interface to lua you can do everything that an internal function can.

If you want to do things only for yourself, you may hack celestia with customised C-functions. But if you want to present your efforts to a wider audience, I'd suggest to expose all neccessary objects via interface and write your AI code as lua script functions. This way it is quite easy to attach several different kinds of AI behaviour to Celestia without recompiling and limiting the results to 'developers only'. If you find that your lua functions are too slow for what you need (which is unlikely), it's still rather easy to transform them into pure internal C-code (especially when there already are well defined interface structures defined).

maxim