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

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
paulooch1958
Posts: 11
Joined: 26.05.2005
With us: 19 years 4 months
Location: Cal

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

Post #1by paulooch1958 » 26.05.2005, 23:24

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:
Paul

maxim
Posts: 1036
Joined: 13.11.2003
With us: 20 years 10 months
Location: N?rnberg, Germany

Post #2by maxim » 29.05.2005, 09:55

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

Topic author
paulooch1958
Posts: 11
Joined: 26.05.2005
With us: 19 years 4 months
Location: Cal

Post #3by paulooch1958 » 29.05.2005, 17:23

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.
Paul

Verteiron
Posts: 2
Joined: 27.05.2005
With us: 19 years 4 months

Post #4by Verteiron » 30.05.2005, 01:02


maxim
Posts: 1036
Joined: 13.11.2003
With us: 20 years 10 months
Location: N?rnberg, Germany

Post #5by maxim » 30.05.2005, 10:47

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


Return to “Development”