Game Development Community

Simobjects

by Mehmet Kizil · in Torque Game Engine · 01/29/2004 (5:51 pm) · 9 replies

Hi guys,

um 2 quick questions......

1.say i create an object called myObject
and i run myObject->registerObject(3456); or myObject->registerObject("3456");

well i was wondering how i access that particular object somewhere else in code to say get it's transform. ie. how do i do this in correct code:

myObject newMyObject;
newMyObject = somehow get object using id. // <--- how do i do that?
MatrixF hello = newMyObject->getTransform();


2. inside one of my classes I create a few objects and register them with specific id's,
and if i go into the editor it displays the correct id's (hurray), but inside the code
of the object itself, if put a line in the render function to print out the id, and it prints
out a different id to the one showing in the editor?? i know this has something to do with
netcode but any ideas how I could print to the screen the actual id???

ta.

#1
01/30/2004 (4:44 am)
1) You can use SimObject* Sim::findObject(const char *name) or SimObject* SimSet::findObject(const char *name) to get your object.

2) If I remember correctly, the "name" and "id" of a simobject are two seperate entities. So i'm not really clear here on what you are doing or attempting to do. Can you be more specific, and maybe show some of the code in your render?
#2
01/30/2004 (9:29 am)
The different ID is because of Torque's ghosting system. You can find more information in the docs for NetObject in the c++ engine reference. The client is unaware of the server's ID.
#3
02/01/2004 (4:04 pm)
Hey Ben,

yeah i've read just about every little thing i can about netObject, however I still can't figure out how to access server objects from the client.

Basically i need some c++ code that allows me to access the transform of a server object, based on either the servers id or name. The code i want needs to be inside the renderObject function of a class which inherits from sceneObject.

Ta
#4
02/01/2004 (4:32 pm)
Mehmet :
if you open ../game/projectile.cc

and browse to line : 687
you will find within this function a nice comment and the descriptive code you seek.
#5
02/01/2004 (5:36 pm)
Sorry dude, dont get how that helps me!

I've been tryin to fix this prob for weeks, and i always end up at the same place....
oh well.
#6
02/01/2004 (5:47 pm)
If someone would like to be a champion they can try and figure out this problem with me?

Here it is:

I need to be able to go into the editor and place an object we'll call myList.
This object has to render a tetrahedron at it's origin.
Now I need a console function we'll call appendToList(x,y,z); which will create a new tetrahedron offsetted to the last one by x,y and z.
Then i need the object to figure out the positions of both tetrahedrons and draw a box which joins the two.

To visualise it better think of myList as placing a root node, and everytime appendToList is run, a new node is created and joined to the list (like a 3D graph).


Now I have had ideas from around 50 people in the last few weeks, and I have not achieved any ground, so if you have any ideas in CODE form, feel free to help (if not i guess your all not good enough :P).
#7
02/01/2004 (5:58 pm)
Why not look at the pathcam code? that basically does a bunch of points which are bound together with a marker showing the path between them?

Seems like a similar problem.
#8
02/01/2004 (7:53 pm)
Yeah similar but it doesn't make the path points on the fly, they are set in the editor
#9
02/01/2004 (8:45 pm)
Perhaps check this out.

Path Points/Way Points on the fly.

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3968