I wasnt sure how to label this topic so just left it a simple ?s type lol..
Ok I found it quite simple to follow the tutorial and adding a simple model to your program... like this..
scene::IAnimatedMesh* mesh = smgr->getMesh(
"../../media/room.3ds");
smgr->getMeshManipulator()->makePlanarTextureMapping(
mesh->getMesh(0), 0.012f);
scene::ISceneNode* node = 0;
node = smgr->addAnimatedMeshSceneNode(mesh);
node->setMaterialTexture(0, driver->getTexture("../../media/wall.jpg"));
node->getMaterial(0).EmissiveColor.set(0,55,55,55);
Now lets say I want to scale this I didnt find a node to add to set scale to a IAnimatedMesh...
Now lets say I want to move it around, Same thing..
So when looking around I figured that maybe you can only do this with a
IAnimatedMeshSceneNode like this..
scene::IAnimatedMeshSceneNode* anode = 0;
mesh = smgr->getMesh("../../media/sydney.md2");
anode = smgr->addAnimatedMeshSceneNode(mesh);
anode->setPosition(core::vector3df(15,45,-30));
anode->setMD2Animation(scene::EMAT_STAND);
anode->setMaterialTexture(0, driver->getTexture("../../media/sydney.BMP"));
anode->addShadowVolumeSceneNode();
Allowing me to move it around and so on... But I still didnt find scale..
The thing is my model isnt animated.. Its just a simple 3ds like the room for the FX example..
Now here is the fun part...
I tried to add a second
scene::IAnimatedMeshSceneNode* anode = 0;
By changing the anode to bnode in hopes I could have two independant objects and move them around and texture them diff and so on... But when I add a second one like this something wacks out with the gravity or something and I fall to no mans land. I cant stay up in the 3ds room to see what is wrong lol... Its rather strange..
I thought that maybe something was going on with the CollisionResponseAnimator and was thinking that my new model was to have the gravity insted but ive looked all over the screen down up, moved from side to side so on.. And I dont see myself standing on anything...
Its quite strange...
So maybe someone can post an example of how to add multiple meshes that I can move around and scale insted of the first way I have posted..
Again everyone has been great help and I thank everyone agian for there help..
Some ?s
To change scale:
node->setScale(irr::core::vector3df(0,0,0));
Meshes != nodes. A mesh in Irrlicht is just a bunch of geometry data. A node is something that can control a mesh.
And instead of "scene::IAnimatedMeshSceneNode* anode = 0;", use "anode = NULL;". Here you set the pointer to nothing (well yeah, something, just some crap that was left). Now use it again to add an AnimatedMesh. This method is only used when you don't need to change something to the nodes later...
node->setScale(irr::core::vector3df(0,0,0));
Meshes != nodes. A mesh in Irrlicht is just a bunch of geometry data. A node is something that can control a mesh.
And instead of "scene::IAnimatedMeshSceneNode* anode = 0;", use "anode = NULL;". Here you set the pointer to nothing (well yeah, something, just some crap that was left). Now use it again to add an AnimatedMesh. This method is only used when you don't need to change something to the nodes later...
Ok I figured this one out on my own...
I couldnt figure out why when I simply added a second model in the code that when I started the application I fell to my death in a endless white mass lol...
I knew that when I set gravity to 0,0,0 that everything was still loading just fine and displaying perfectly..
In fact my new model was even there..
But I could walk into walls and so on..
I finally figured out that my new model took over the Collision and I was now bumping into it insted of my room...
I looked at my code and looked at my code and finally I found it..
//load room//
scene::IAnimatedMesh* mesh = smgr->getMesh(
"../../media/room.3ds");
smgr->getMeshManipulator()->makePlanarTextureMapping(
mesh->getMesh(0), 0.012f);
scene::ISceneNode* node = 0;
node = smgr->addAnimatedMeshSceneNode(mesh);
node->setMaterialTexture(0, driver->getTexture("../../media/wall.jpg"));
node->getMaterial(0).EmissiveColor.set(0,55,55,55);
////DONT PLACE CODE FOR OTHER OBJECTS INBETWEEN HERE LOL////
scene::ITriangleSelector* selector = 0;
if (node)
{
selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 128);
node->setTriangleSelector(selector);
selector->drop();
}
// add animated character
scene::IAnimatedMeshSceneNode* anode = 0;
mesh = smgr->getMesh("../../media/sydney.md2");
anode = smgr->addAnimatedMeshSceneNode(mesh);
anode->setPosition(core::vector3df(15,45,-30));
anode->setMD2Animation(scene::EMAT_STAND);
anode->setMaterialTexture(0, driver->getTexture("../../media/sydney.bmp"));
anode->addShadowVolumeSceneNode();
I noticed that my room loading was above scene::ITriangleSelector* selector = 0;
And my model of sydney was after selector...
If I made the mistake and placed another loading of a model above scene::ITriangleSelector other then the room (Note the room is the model set up for Collision), Then my camera would now shift Collision over to the new model that I added...
I found this very strange at first and still kinda do but as soon as I figured this out and moved the model below like in the example above everything was great again..
So if you have strange things like this happen to you when your level loads and you fall into a pit of white nothingness, Take a close look at this and maybe you have made the same mistake as me...
I think that explains the mistake I did I hope lol..
Anyway it was a pain in the butt tell I found my stupid mistake lol..
And thanks for the scale info too...
I couldnt figure out why when I simply added a second model in the code that when I started the application I fell to my death in a endless white mass lol...
I knew that when I set gravity to 0,0,0 that everything was still loading just fine and displaying perfectly..
In fact my new model was even there..
But I could walk into walls and so on..
I finally figured out that my new model took over the Collision and I was now bumping into it insted of my room...
I looked at my code and looked at my code and finally I found it..
//load room//
scene::IAnimatedMesh* mesh = smgr->getMesh(
"../../media/room.3ds");
smgr->getMeshManipulator()->makePlanarTextureMapping(
mesh->getMesh(0), 0.012f);
scene::ISceneNode* node = 0;
node = smgr->addAnimatedMeshSceneNode(mesh);
node->setMaterialTexture(0, driver->getTexture("../../media/wall.jpg"));
node->getMaterial(0).EmissiveColor.set(0,55,55,55);
////DONT PLACE CODE FOR OTHER OBJECTS INBETWEEN HERE LOL////
scene::ITriangleSelector* selector = 0;
if (node)
{
selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 128);
node->setTriangleSelector(selector);
selector->drop();
}
// add animated character
scene::IAnimatedMeshSceneNode* anode = 0;
mesh = smgr->getMesh("../../media/sydney.md2");
anode = smgr->addAnimatedMeshSceneNode(mesh);
anode->setPosition(core::vector3df(15,45,-30));
anode->setMD2Animation(scene::EMAT_STAND);
anode->setMaterialTexture(0, driver->getTexture("../../media/sydney.bmp"));
anode->addShadowVolumeSceneNode();
I noticed that my room loading was above scene::ITriangleSelector* selector = 0;
And my model of sydney was after selector...
If I made the mistake and placed another loading of a model above scene::ITriangleSelector other then the room (Note the room is the model set up for Collision), Then my camera would now shift Collision over to the new model that I added...
I found this very strange at first and still kinda do but as soon as I figured this out and moved the model below like in the example above everything was great again..
So if you have strange things like this happen to you when your level loads and you fall into a pit of white nothingness, Take a close look at this and maybe you have made the same mistake as me...
I think that explains the mistake I did I hope lol..
Anyway it was a pain in the butt tell I found my stupid mistake lol..
And thanks for the scale info too...
W.r.t. Bal's remark about using NULL versus 0: not so.
NULL is the C way of writing a pointer that points to nothing, 0 is the C++ way, but both are the same value (NULL simply maps to 0).
In fact, you can do a pointer comparison in C such as "if(ptr) ...."
and that works because a pointer to memory address 0 (which it technically is) is by convention invalid.
All memory allocation functions return NULL (or 0) when they are unsuccessful.
One whole byte of memory wasted! But it's better than one extra byte wasted for each and every pointer (just to store the validity status of the pointer)...
And depending on the underlying hardware, address 0 may not be generally usable anyway. (it may contain a pointer to BIOS reset code or something along those lines)
I myself prefer writing NULL by the way. But there's no law about it in either C or C++.
NULL is the C way of writing a pointer that points to nothing, 0 is the C++ way, but both are the same value (NULL simply maps to 0).
In fact, you can do a pointer comparison in C such as "if(ptr) ...."
and that works because a pointer to memory address 0 (which it technically is) is by convention invalid.
All memory allocation functions return NULL (or 0) when they are unsuccessful.
One whole byte of memory wasted! But it's better than one extra byte wasted for each and every pointer (just to store the validity status of the pointer)...
And depending on the underlying hardware, address 0 may not be generally usable anyway. (it may contain a pointer to BIOS reset code or something along those lines)
I myself prefer writing NULL by the way. But there's no law about it in either C or C++.
> NULL is the C way of writing a pointer that points to nothing
True, but this a bit misleading. A pointer set to zero (NULL) points to the
very first memory location. It points to something, whatever data
happens to be there. It's not anything useful though. In some cases
this will cause a protection fault in your program but don't count on it.
>NULL simply maps to 0
NULL is equal to zero.
> In fact, you can do a pointer comparison in C such as "if(ptr) ...."
This is also a bit misleading. "if ( ptr )" doesn't compare pointers or
what the ptr points to. It checks to see if the expression is true or
false. ptr is evaluated as a number and if it's not zero (NULL) then
it evaluates as true. Non-zero = true in C and C++
> All memory allocation functions return NULL (or 0) when they are unsuccessful.
Also keep in mind that not all compilers will set uninitialized pointers
to zero (NULL). Some set it to the hex number 0xCCCCCCCC. Others
set it to something nonsensical or random. Some use the hex number
0xDEADBEEF or 0xBADFOOD. Code that works on one compiler may
not on another if you don't initialize pointers.
True, but this a bit misleading. A pointer set to zero (NULL) points to the
very first memory location. It points to something, whatever data
happens to be there. It's not anything useful though. In some cases
this will cause a protection fault in your program but don't count on it.
>NULL simply maps to 0
NULL is equal to zero.
> In fact, you can do a pointer comparison in C such as "if(ptr) ...."
This is also a bit misleading. "if ( ptr )" doesn't compare pointers or
what the ptr points to. It checks to see if the expression is true or
false. ptr is evaluated as a number and if it's not zero (NULL) then
it evaluates as true. Non-zero = true in C and C++
> All memory allocation functions return NULL (or 0) when they are unsuccessful.
Also keep in mind that not all compilers will set uninitialized pointers
to zero (NULL). Some set it to the hex number 0xCCCCCCCC. Others
set it to something nonsensical or random. Some use the hex number
0xDEADBEEF or 0xBADFOOD. Code that works on one compiler may
not on another if you don't initialize pointers.