I want to implement cars in my game and I think the best way to do this is to make a new SceneNode-type. This new SceneNode should be a child of IAnimatedMeshSceneNode, extended by some variables and some functions for moving and rotating the car etc. I think.
I've already tried to write such a new SceneNode, according to the CustomSceneNode-Tutorial. Here is the code (nothing special yet):
Code: Select all
class CCarSceneNode : public IAnimatedMeshSceneNode
{
private:
core::vector3df direction;
float speed;
public:
virtual void setDirection(core::vector3df newDirection)
{
direction = newDirection;
}
virtual void setSpeed(float newSpeed)
{
speed = newSpeed;
}
virtual void render()
{
IAnimatedMeshSceneNode::render();
// Do the moving/rotating/... stuff here
}
};
Code: Select all
CCarSceneNode *carNode = sm->addAnimatedMeshSceneNode(carmesh);
I've got another question relating the CarSceneNode: Later I want to rotate the cars wheels when it moves. Is it somehow possible to rotate just a part of a SceneNode or do I have to create an animation for this in my modelling program (Milkshape)?