this class SceneNode: public ndBody
will be too difficult in c++.
the ndBody is just a common interface for the engine, if a high level app derive from that class, the core engine object will not be aware of what kind of object it is. for example, the ndScene implements everything related to collision, contacts, shapes, that kind of things. for thatm is uses ndKinematc as base class. a new body derived from ndBody is not going to be ndKinematic so it will no be on any sub system.
similarly, the solvers deal with ndBodyKineamtix and ndBodyDynamics, so they will understand bodies derive from ndBodyDynamics and treat them as dynamics bodies that interact with other bodies. I will handle bodies derived from ndBodyKinematics, but will treat them as static bodies. they will not be integrated.
what you want to do in this.
for getting and update for the network. you can subclass the world and overload OnPostUpdate
- Code: Select all
class ndServeWorld: public ndWorld
{
public:
ndServeWorld(ndDemoEntityManager* const manager);
virtual ~ndServeWorld();
// do all the server stuff logic
void OnPostUpdate(ndFloat32 timestep);
};
them, in OnPostUpdate you can do scene management stuff like when a new body is added to a client or remove. there you can add or remove new bodies that come and go form the server,
To interface with bodies no matter what type they are, you can make a custom
base class ndBodyNotify, and assign that to the bodies in you creation functions.
this way all bodies in the scene, will have a notification with a common base class that was made by your application. Plus, the bodies get appropriate call backs that you can overload to do the network synchronization on per body bases and you do not have to worry about type casting. as you would if you did this in the world update loop.
in the sandbox demos, that class is class ndDemoEntityNotify: public ndBodyNotify
there you can implement the force and torque function, but also, you can add the serve corrections.
if you look at the demos, some objects require special attention.
for example thet ragdoll demo, that I am working now, used this.
class ndActiveRagdollEntityNotify : public ndDemoEntityNotify
and there it checks if some collision cause so modifies to acquire a huge velocity, and if so, is clamp it.
there are other demos, that use different subclasses of ndDemoEntityNotify because they do different thing. But doing that you can do there equivalent of what you mention in the post.
there are some other examples, The player capsule would play the animation of the visual body.
class ndBasicPlayerCapsuleNotify : public ndDemoEntityNotify
the fracture, I think it use a special one as well, and so on.