First, I have a question for you. What exactly do you mean by "However, if I want to do something within this scene, what should I do?"
I think you mean, for example, how can you make a cube move during the scene?
Well, first let me address your point about the camera. Unless I am horribly mistaken at this very late hour, there should be no reason why you must create a camera after the node.
Your code probably looks something like:
Code: Select all
...
ISceneNode* cube = smgr->addCubeSceneNode(10.0f);
cube->setMaterialFlag(EMF_LIGHTING, false);
smgr->addCameraSceneNodeFPS();
while (device->run())
{
driver->beginScene(true, true, SColor(255, 255, 255, 255);
smgr->drawAll();
driver->endScene();
}
device->drop();
I excluded a large portion, of course, but if I remember correctly, this is basically how the tutorials are structured.
Now, first, there is no reason why I couldn't create my camera before I created the cube, and the reason is pretty simple.
The while-loop is the render loop. Every frame, this loop is executed. So, the actual drawing is occurring at the function call smgr->drawAll();
Look back at how we created the camera and the cube scene node. They are created by the ISceneManager, thus they are also managed by the ISceneManager.
The scene manager keeps track of all your 3D data, and perceives the world from the active camera. So, as long as you set a camera before the render loop, there should be no problem.
About the second part of your question. Again, I'm not very clear on what you meant, but I'm guessing you might want something to move around. For this, remember that the render loop is called every frame. In order to move something around, it's position should be updated every frame.
So, let's just make the cube that I created move in a straight line:
(The only thing changed is in the render loop)
Code: Select all
...
ISceneNode* cube = smgr->addCubeSceneNode(10.0f);
cube->setMaterialFlag(EMF_LIGHTING, false);
smgr->addCameraSceneNodeFPS();
while (device->run())
{
cube->setPosition(vector3df(cube->getAbsolutePosition().X + 2, 0, 0));
driver->beginScene(true, true, SColor(255, 255, 255, 255);
smgr->drawAll();
driver->endScene();
}
device->drop();
So the idea is to set the position of the cube to the previous position plus the amount that you want to offset it by (in this case 2).
If this didn't answer your question, then feel free to ask!