problem Billboard's position
problem Billboard's position
I have a gun muzzle bone node.
But muzzle bone node's position is unchanged, no matter where I move
what should I do?
or how to gets the position of the node for muzzle bone in the whole world coordinates.
thanks very much
But muzzle bone node's position is unchanged, no matter where I move
what should I do?
or how to gets the position of the node for muzzle bone in the whole world coordinates.
thanks very much
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
thx
here it is
here it is
Code: Select all
/*
* 人物模型节点 character node
*/
node = smgr->addAnimatedMeshSceneNode(Urban_Mesh,0);
node->setPosition(core::vector3df(0,36.f,0)); // Put its feet on the floor.
node->setRotation(core::vector3df(0,180.f,0)); // And turn it towards the camera.
node->setMaterialFlag(EMF_LIGHTING, false);
/*
* 载入枪 load gun mesh
*/
ISkinnedMesh* M4a1_Mesh = (ISkinnedMesh*)smgr->getMesh("weapon/m4a1-1.x");
scene::IAnimatedMeshSceneNode* weaponnode = 0;
weaponnode = smgr->addAnimatedMeshSceneNode(M4a1_Mesh,0);
weaponnode->setMaterialFlag(EMF_LIGHTING, false);
weaponnode->setRotation(core::vector3df(0,180.f,0));
/*
* 得到flash位置骨头节点 flash bone node
*/
IBoneSceneNode* flashbonescenenode = weaponnode->getJointNode("flash");
/*
* 载入火花 flash billboard node
*/
IBillboardSceneNode* nodemuzzleflash = 0;
video::ITexture* images = device->getVideoDriver()->getTexture("weapon/m4a1_muzzleflash.bmp");
nodemuzzleflash = smgr->addBillboardSceneNode(weaponnode,core::dimension2d<f32>(5,5));
nodemuzzleflash->setMaterialFlag(EMF_LIGHTING, false);
nodemuzzleflash->setMaterialTexture(0,images);
nodemuzzleflash->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
nodemuzzleflash->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
nodemuzzleflash->setVisible(false);
/*
* 得到控制两个控制上半身方向的节点 It is used to control the upper body
*/
IBoneSceneNode* boneNode1 = node->getJointNode("U_Bip01_Spine");
IBoneSceneNode* boneNode2 = node->getJointNode("U_Bip01_Spine1");
IBoneSceneNode* boneNode3 = node->getJointNode("U_Bip01_R_Hand");
while(device->run())
if (device->isWindowActive())
{
/*
* 跟新骨头节点和枪和人物 updata weapon node and character node position
*/
if(PlayerState == MOVED)
{
//do something updata rotation weapnode and characters node and bonenode1
}
}
if(PlayerState == STANDED)
{
/*
* 身体和上半身的左右转动 upperbody look left look right by bonenode1
*/
// do something updata rotation bonenode1
}
if(PlayerState == JUMPED)
{
//do something updata rotation weapnode and characters node and bonenode1
}
if(UpperBodyState == RELOAD)
{//状态改变
if( Reload_Animator->getCurrentFrame() == Reload_Animator->getEndFrame() )
{
UpperBodyState = IDLE;
}
}
/*
* 上半身上下看骨头节点 upper body look up look down by bonenode2
*/
// do something updata rotation bonenode2
//here updata flash position but I don.t kown how to do it .I've tried many way
}
Last edited by klikli234 on Sat Apr 30, 2011 12:50 am, edited 5 times in total.
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Ok, this is some really hard to read code, I got a bit confused by all these rotation and position sets and copies, but maybe try this:
Code: Select all
/*
* ???
*/
ISkinnedMesh* M4a1_Mesh = (ISkinnedMesh*)smgr->getMesh("weapon/m4a1-1.x");
scene::IAnimatedMeshSceneNode* weaponnode = 0;
weaponnode = smgr->addAnimatedMeshSceneNode(M4a1_Mesh, 0);
//weaponnode = smgr->addAnimatedMeshSceneNode(M4a1_Mesh, USUALLY_CHARACTER_RIGHT_HAND_JOINT_HERE); //### HERE
weaponnode->setMaterialFlag(EMF_LIGHTING, false);
weaponnode->setRotation(core::vector3df(0,180.f,0));
/*
* ??flash??????
*/
IBoneSceneNode* flashbonescenenode = weaponnode->getJointNode("flash");
if (!flashbonescenenode) //###### HERE
printf("\n\n FAILED LOADING joint 'flash' \a \n"); //###### HERE the "\a will make it say BEEP! if it`s not loaded properly
/*
* ????
*/
IBillboardSceneNode* nodemuzzleflash = 0;
video::ITexture* images = device->getVideoDriver()->getTexture("weapon/m4a1_muzzleflash.bmp");
nodemuzzleflash = smgr->addBillboardSceneNode(flashbonescenenode,core::dimension2d<f32>(5,5)); //###### HERE you want your flamerose child of the muzzle bone
nodemuzzleflash->setMaterialFlag(EMF_LIGHTING, false);
nodemuzzleflash->setMaterialTexture(0,images);
nodemuzzleflash->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
nodemuzzleflash->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
nodemuzzleflash->setVisible(false);
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Once you create the character, weapon and flash nodes and set the correct parents, no additional calls like
will be needed. All this is causing you trouble. When a node has a parent Irrlicht updates its transformation according his parent, so everything else should work more or less as expected. And your images are not showing up here for some reason.
Code: Select all
vector3df flashpos = flashbonescenenode->getPosition() + weaponnode->getPosition();
nodemuzzleflash->setPosition(flashpos);
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Still doesn't work, the flash didn't moveshadowslair wrote:Once you create the character, weapon and flash nodes and set the correct parents, no additional calls likewill be needed. All this is causing you trouble. When a node has a parent Irrlicht updates its transformation according his parent, so everything else should work more or less as expected. And your images are not showing up here for some reason.Code: Select all
vector3df flashpos = flashbonescenenode->getPosition() + weaponnode->getPosition(); nodemuzzleflash->setPosition(flashpos);
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
That`s exactly what I wanted to say- you don`t need to if you setup your parent-child pairs correctly. But as you intend on positioning it manually, for getting world (absolute) positions you can try:
Code: Select all
flashbonescenenode->updateAbsolutePosition(); // just to make sure it`s updated. You usually don`t need to call it every time, depending on the case.
core::vector3df myBoneWorldPostion(flashbonescenenode->getAbsolutePosition());
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
No matter what I move,shadowslair wrote:That`s exactly what I wanted to say- you don`t need to if you setup your parent-child pairs correctly. But as you intend on positioning it manually, for getting world (absolute) positions you can try:
Code: Select all
flashbonescenenode->updateAbsolutePosition(); // just to make sure it`s updated. You usually don`t need to call it every time, depending on the case. core::vector3df myBoneWorldPostion(flashbonescenenode->getAbsolutePosition());
Bone's world coordinates didn't change.
thanks,nespa wrote:when you load the mesh gun, it is loaded at 0,0,0 coordinates, then create a billboard , position it in front of the gun, then bind the billboard as child to the mesh gun;
then, all the times you move the gun, the billboard will keep relative position to the gun;
but useless.
I moved the other bones.
This time the billboard not will keep relative position to the gun
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
If we should really help you (not sure if you want, it's hard to assess your intention from the few words you use) you should reduce your code to a minial setup. Load the mesh, attach the flash, let the animation run. This should be possible in less than 30 lines of code. Then check if the flash will move with the gun or not. Please show us the code after checking the results, and also the new screenshots with the new code.