position issues
position issues
i have a main level (map)
then add some objects..
but all the objects have the position 0, 0, 0,
how can i get its position with relative to may map?
thnx
then add some objects..
but all the objects have the position 0, 0, 0,
how can i get its position with relative to may map?
thnx
opensource = freedom
<br>
how can you face the problem if the problem is your face?
<br>
how can you face the problem if the problem is your face?
-
- Posts: 226
- Joined: Fri Aug 22, 2008 8:50 pm
- Contact:
If your map is one sceneNode you can make the other objects children of this node. SetPosition will then always set a relative position with the transformation of the map node defining the coordinate system.
If you want the center of your map to be the center of the world without parenting, then you have to add this position to every positioning command: node->setPosition(position+centerposition);
greetings
If you want the center of your map to be the center of the world without parenting, then you have to add this position to every positioning command: node->setPosition(position+centerposition);
greetings
ive tried to add them as a child... but still in 0, 0, 0, coordinates
one thing...
after loading each mesh, scale up all my things by 10,
then by getting their transformedbox, it seems that the scale was ignored...
so the distance are very near to each other...
is there a way to also relate the position with the scale?
thnx
one thing...
after loading each mesh, scale up all my things by 10,
then by getting their transformedbox, it seems that the scale was ignored...
so the distance are very near to each other...
is there a way to also relate the position with the scale?
thnx
opensource = freedom
<br>
how can you face the problem if the problem is your face?
<br>
how can you face the problem if the problem is your face?
ok just to be precise...
here's exactly what i did...
create a level....
then add about 30 respawn point (separately) for my objects...
but the problem is all my respawn point coordinates are 0, 0, 0..
because its absolute..
ive already set my objects to be the child of my level,
and vice versa(set my level to be the parent of my objects)
but still in 0, 0, 0 coordinates...
so is there any way around in doing what im trying to do?
thnx
here's exactly what i did...
create a level....
then add about 30 respawn point (separately) for my objects...
but the problem is all my respawn point coordinates are 0, 0, 0..
because its absolute..
ive already set my objects to be the child of my level,
and vice versa(set my level to be the parent of my objects)
but still in 0, 0, 0 coordinates...
so is there any way around in doing what im trying to do?
thnx
opensource = freedom
<br>
how can you face the problem if the problem is your face?
<br>
how can you face the problem if the problem is your face?
here's my code
when i set the staticnode to the position of node, its still at its default position...
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_SOFTWARE, dimension2d<u32>(800, 600), 32,
false, true, true, 0);
if (!device)
return 1;
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
IAnimatedMesh *levelMesh = smgr->getMesh("..\\Documents\\exported_blender_files\\battlecity1.b3d");
IAnimatedMeshSceneNode *levelNode = smgr->addAnimatedMeshSceneNode(levelMesh);
levelNode->setScale(irr::core::vector3df(10, 10, 10));
levelNode->setMaterialFlag(EMF_LIGHTING, false);
IAnimatedMesh *staticMesh = smgr->getMesh("..\\Documents\\exported_blender_files\\stop0.b3d");
IAnimatedMeshSceneNode *staticNode = smgr->addAnimatedMeshSceneNode(staticMesh);
//staticNode->setScale(irr::core::vector3df(10, 10, 10));
staticNode->setParent(levelNode);
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
IAnimatedMesh* mesh = smgr->getMesh("..\\Documents\\exported_blender_files\\sydney.md2");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh, levelNode );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("..\\Documents\\exported_blender_files\\sydney.bmp") );
}
staticNode->setPosition(node->getPosition());
smgr->addCameraSceneNodeFPS();//(0, vector3df(0,30,-40), vector3df(0,5,0));
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
opensource = freedom
<br>
how can you face the problem if the problem is your face?
<br>
how can you face the problem if the problem is your face?
b3d files have their position already set when loaded...
like ive created them in blender.. and when i export them to b3d and load it to irrlicht.. their positions are already the same in blender....
but the problem is their holding on to their positons as (0, 0, 0) as their origin (for each object)...
so when i add another object, set it to the position of that already loaded b3d files, the value that i get was always 0, 0, 0 so instead of being placed on the position of that object, i was placed at the center of the scene...
like ive created them in blender.. and when i export them to b3d and load it to irrlicht.. their positions are already the same in blender....
but the problem is their holding on to their positons as (0, 0, 0) as their origin (for each object)...
so when i add another object, set it to the position of that already loaded b3d files, the value that i get was always 0, 0, 0 so instead of being placed on the position of that object, i was placed at the center of the scene...
opensource = freedom
<br>
how can you face the problem if the problem is your face?
<br>
how can you face the problem if the problem is your face?
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Now, these are two different things. The scene node has a position. The mesh has a local coord system, where the center of the mesh might be offset from the (0,0,0) center. Also, when animating (even if only one frame exists) the mesh might move. But these positions are not the scene node position. The scene node stays static while the animated mesh moves. You might be able to get a vertex position from the mesh at its absolute position. This would move while the mesh animates. But it would be pretty costly to check this.