lucadestudios team mailing list archive
-
lucadestudios team
-
Mailing list archive
-
Message #00016
Physics Engine
I've updated the Physics UML a bit, it can be found is in
trunk/engine/doc/Physics
There are a lot of methods still missing and the internally running thread
needs to be modelled too..
Basic usage will be:
physics::Engine* _engine = new physics::Engine();
physics::World* _world = new physics::World(world dimensions in x,y,z);
_engine->setWorld(world);
_engine->setNetworkClient(_networkManager); //whatever is used to send
messages from the physics engine to the server, sending objects will be
performed from the main thread, not the internal physics thread
//for each object to be simulated
physics::PhysicsObject* myObject = new physics::PhysicsObject(mass,
centerOfMass, elasticity, position, orientation);
myRenderObject->linkTo(myObject); //used to retrieve position and rotation
matrix from the physics engine via _physicsObject->getTranslationMatrix()
//for playing sounds or other notifications:
void myCallback(const Contact& cont);
myObject->registerCollisionCallback(&myCallback);
_engine->spawnObject(myObject); //will spawn in currently selected world
***********************************************************
//in the main loop:
_engine->update(deltaTime);
//for all incoming Packets:
_engine->handlePacket(packet); //this is allowed to set positions of objects
directly
//***********************************************************
//modifying the state of the physical world just works with events as soon
as the simulation thread runs, no direct access to the PhysicsObjects!
//the events cannot set positions of models directly but just interacts with
forces
_engine->handleEvent( any of: SpawnObjectEvent, ApplyForceEvent,
DestroyObject,...);
Thats just a rough sketch, I'm not sure about the extra physics thread so
that might change, but no big changes I hope...
Let me know what you think about that
Cheers
Carsten
Follow ups