I wrote a basic program to load a scene from IrrEdit. I'm having trouble figuring out how to access the scene nodes from my .irr scene. For example, I placed a FPS camera in my level with IrrEdit, and I want to be able to load the scene into my code and run it without having to manually create the camera in the code (and have manually input the location etc).
All of the tutorials that I have found for loading .irr scenes in irrlicht involve creating the camera in the code rather than just using the camera that I put into scene with irredit.
In case what I'm asking seems really dumb, I want to state that I am absolutely new to irrEdit and (though I have played around with irrlicht engine for a couple years) I have very limited experience with irrlicht. I openly admit that I am most likely overlooking something very simple, so please be gentle
As I understand it, IrrEdit gives me the capability to design my scenes and implement behaviors and actions and more. If anyone knows of some good resources to help me get off the ground with using .irr scene nodes in Irrlicht, I would greatly appreciate it.
Thanks in advance.
Accessing IrrEdit scene nodes
Hi!
You could search your scene and find the (camera)node you'r looking for with any of these functions (which are available in the scene manager)
So, set name/id of a node in the editor and search for it after having loaded the scene.
You could search your scene and find the (camera)node you'r looking for with any of these functions (which are available in the scene manager)
Code: Select all
//! Get the first scene node with the specified id.
/** \param id: The id to search for
\param start: Scene node to start from. All children of this scene
node are searched. If null is specified, the root scene node is
taken.
\return Pointer to the first scene node with this id,
and null if no scene node could be found.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual ISceneNode* getSceneNodeFromId(s32 id, ISceneNode* start=0) = 0;
//! Get the first scene node with the specified name.
/** \param name: The name to search for
\param start: Scene node to start from. All children of this scene
node are searched. If null is specified, the root scene node is
taken.
\return Pointer to the first scene node with this id,
and null if no scene node could be found.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual ISceneNode* getSceneNodeFromName(const c8* name, ISceneNode* start=0) = 0;
//! Get the first scene node with the specified type.
/** \param type: The type to search for
\param start: Scene node to start from. All children of this scene
node are searched. If null is specified, the root scene node is
taken.
\return Pointer to the first scene node with this type,
and null if no scene node could be found.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual ISceneNode* getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode* start=0) = 0;
//! Get scene nodes by type.
/** \param type: Type of scene node to find (ESNT_ANY will return all child nodes).
\param outNodes: array to be filled with results.
\param start: Scene node to start from. All children of this scene
node are searched. If null is specified, the root scene node is
taken. */
virtual void getSceneNodesFromType(ESCENE_NODE_TYPE type,
core::array<scene::ISceneNode*>& outNodes,
ISceneNode* start=0) = 0;
After you find your camera, don't forget to make it active:
Code: Select all
ISceneManager* sceneManager; // previously set
ICameraSceneNode* myCamera=0;
ICameraSceneNode* oldCamera=0;
myCamera = static_cast<ICameraSceneNode*>(sceneManager->getSceneNodeFromName("myCameraName"));
oldCamera = sceneManager->getActiveCamera();
sceneManager->setActiveCamera(myCamera);
Thank you for the helpful replies. I managed to access the camera with the following code:
I'm not sure if there is a more direct way to use the camera from the .irr scene, but this seems to function correctly. I am posting this code so you can tell me if I am doing something redundant or not.
Now, in the .irr scene I made, I added a dynamic light that flies in a circle, but when I run the application I made, it doesn't show the effect of the light moving from wall to wall like it does when I run it in irrEdit. It only shows static light on the walls. How do I render the light animation and other animations from my .irr scene in my code? I would of assumed that by loading the .irr scene it would automatically render the light animations etc, but from what I have discerned I have to make a call manually?
Additionally, when I run my code it shows the FPS as 1, as if everything is static. I don't understand why it is rendering the meshes and the initial frame of the light node but not any of the animations that go with it.
Any help is appreciated.
Code: Select all
camera = static_cast<ICameraSceneNode*>(smgr->getSceneNodeFromId(397221078));
device->getCursorControl()->setVisible(false);
cameraFPS = smgr->addCameraSceneNodeFPS(0,100.0f,0.5,-1,keyMap,9,true,0.1f,false,true);
cameraFPS->setPosition(camera->getPosition());
cameraFPS->setRotation(camera->getRotation());
cameraFPS->setTarget(camera->getTarget());
cameraFPS->setAspectRatio(camera->getAspectRatio());
cameraFPS->setFarValue(camera->getFarValue());
cameraFPS->setFOV(camera->getFOV());
Now, in the .irr scene I made, I added a dynamic light that flies in a circle, but when I run the application I made, it doesn't show the effect of the light moving from wall to wall like it does when I run it in irrEdit. It only shows static light on the walls. How do I render the light animation and other animations from my .irr scene in my code? I would of assumed that by loading the .irr scene it would automatically render the light animations etc, but from what I have discerned I have to make a call manually?
Additionally, when I run my code it shows the FPS as 1, as if everything is static. I don't understand why it is rendering the meshes and the initial frame of the light node but not any of the animations that go with it.
Any help is appreciated.