Adding skeleton manually makes mesh disappear

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
sjcomp
Gnome
Posts: 315
Joined: Sat Apr 23, 2005 2:35 pm
Location: Dover, NH
Contact:

Adding skeleton manually makes mesh disappear

Post by sjcomp » Wed Oct 12, 2005 7:14 pm

I can create mesh (a cube) but when I am trying to create a skelton to manipulate the mesh, the mesh disappears. What do I do wrong?
This is the code which I insert into function that creates a mesh:

Code: Select all

Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().createManual("Mesh",Ogre::ResourceGroupManager::getSingleton().getWorldResourceGroupName());
      Ogre::SubMesh * sub = mesh->createSubMesh();

//  ... skipp ...

// create skeleton and bones
Ogre::SkeletonPtr skel = Ogre::SkeletonManager::getSingleton().create(strName,Ogre::ResourceGroupManager::getSingleton().getWorldResourceGroupName());
mesh->_notifySkeleton(skel);
Ogre::Bone* pRootBone = skel->createBone();
pRootBone->resetOrientation();
pRootBone->setPosition(0,0,0);
skel->setBindingPose();
Ogre::VertexBoneAssignment vba;
vba.boneIndex = 0;
vba.weight = 1.0;
vba.vertexIndex = 0;
sub->addBoneAssignment(vba);
I insert this code just before I unlock the buffers.
0 x
Regards, Alexander. http://sjcomp.com

genva
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1603
Joined: Wed Oct 20, 2004 7:54 am
Location: Beijing, China

Post by genva » Thu Oct 13, 2005 2:54 am

Code: Select all

Ogre::VertexBoneAssignment vba;
vba.boneIndex = 0;
vba.weight = 1.0;
vba.vertexIndex = 0;
sub->addBoneAssignment(vba);
At least you MUST add vertex-bone-assignment for each vertex. I'm unclear other issues exists or not.
0 x

User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US

Post by xavier » Thu Oct 13, 2005 3:02 am

I have a related question...I haven't dug into it yet because I haven't got to that point yet, but can I get a reference to a bone from a given vertex?
0 x

User avatar
sjcomp
Gnome
Posts: 315
Joined: Sat Apr 23, 2005 2:35 pm
Location: Dover, NH
Contact:

Post by sjcomp » Thu Oct 13, 2005 1:12 pm

genva wrote:At least you MUST add vertex-bone-assignment for each vertex. I'm unclear other issues exists or not.
That was it! Once I add something to every vertex I got my mesh back on the screen! Thanks a lot.
0 x
Regards, Alexander. http://sjcomp.com

Post Reply