Archived

This topic is now archived and is closed to further replies.

using Tokamak with an object oriented game ...

This topic is 4981 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, for the past 2 days ive been working on a game using tokamak, opengl & c++. i decided to go for a full on Object Oriented (OOP) approach ... virtual classes for game objects. ive got some nice, clean code but when attaching the tokamak physics to this code, nothing seems to work. all the objects work individually, but they dont interact. the simulator object is passed to each object before the rigidbody/animatedbody is created ... i then create the body using that simulator. the body itself is stored within the class, but the simulator is updated in the main file (not the class). when i did this, everything moved in accordance to gravity but, as i said, they didnt collide. but if i put all the geometry/body creation code in the main file, everything works perfectly! so whats the deal then? does tokamak not like OOP or virtual classes, or am i doing something wrong ... thanx, SiN ps : if this post looks familiar, i asked the same question on the tokamak boards around a week ago ... i didnt get any replys, so i decided to try here, where the userbase is bigger. ie : im not a spammer! :D

Share this post


Link to post
Share on other sites
quote:
Original post by SiN
when i did this, everything moved in accordance to gravity but, as i said, they didnt collide. but if i put all the geometry/body creation code in the main file, everything works perfectly!


do you use any static objects related to tokamak?

Share this post


Link to post
Share on other sites
I dont really understand how you have it set up

I have a class to handle the simulator, a class for rigid boxes, and a class for rigid spheres

the rigid bodies interact with each other as well as the terrain

Share this post


Link to post
Share on other sites
hi,

quote:

I dont really understand how you have it set up

I have a class to handle the simulator, a class for rigid boxes, and a class for rigid spheres

the rigid bodies interact with each other as well as the terrain



heres my exact setup. in the main file (main.cpp), i create a Tokamak simulator.

I have another file (Object.cpp) which has the Object Class. The Object Class has a function called setSim(neSimulator* gSim), which (obviously) accepts a pointer from the Tokamak Simulator. The object class has a few virtual functions.

The Object Class is extended into other classes (eg Box.cpp). Here, i store any animated/static bodies. When its init() function is called, it uses the Tokamak Sim pointer (accepted from the setSim command) and creates whatever bodies it needs to.

does that make sense?

quote:

do you use any static objects related to tokamak?



uhhh ... i dont know. well, i havent declared any static objects myself, but maybe Tokamak might be using some static classes internally. why?


quote:

You should consult the framework code how it is written. Use that as basis.



i used the tutorials on www.adamdawes.com ... theyre pretty good IMO.


thanx for the help guys ...

SiN

Share this post


Link to post
Share on other sites
I would think it should still work because I think that Tokamak cant really tell your using classes and inheritance and virtual methods. you might be trying to make it more complicated than it needs to be though.

this is what I have done.

I have four classes. CWorld, CRigidBox, CAnimatedBox, and CRigidSphere.

CWorld takes care of initializing and updating the Tokamak simulator as well as setting the terrain.

the other classes add a rigid or animated body to the simulation and have a method that returns their current world matrix.

edit:

I have now made a base class for the rigid bodies and it works fine. there must be something else causing them not to collide

[edited by - eFoDay on April 24, 2004 10:11:02 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by SiN
uhhh ... i dont know. well, i havent declared any static objects myself, but maybe Tokamak might be using some static classes internally. why?


if you have a static in a header file, each compilation unit will get a copy. so each file would have its own simulator if the simulator was static. when you said it works when its in one file, this came to mind.

Share this post


Link to post
Share on other sites