About Store Forum Documentation Contact



Post Reply 
Mounting objects with offset
Author Message
Brainache Offline
Member

Post: #1
Mounting objects with offset
Hey there,

Im working on getting my object mouting the way I need it and ran across the case where I want to add in a local offset to the position returned from the skeletal point.

For example:

Here is the code from the skeletal point tutorial I am basing my work on:
Code:
OrientP &hand_r=cskel.getPoint("HandR");
      Matrix   m;
      m.setPosDir(hand_r.pos,hand_r.perp,hand_r.dir)               // set position and directions according to skeleton point
       .scaleOrn(0.7);                                             // scale down the matrix orientation a little, making the item smaller
      Meshs("../data/obj/item/weapon/blunt/club/0.mesh")->draw(m); // render item with matrix

In my case: A sword moounted to the hand point renders just a bit outside of the hand...

Now I can go back to the mesh and move it a bit and it'll line up...
But what I want to be able to do is something like:
hand_r.pos += Vec(0.5,0,0); // nudge it a bit on the local x axis

How can I do this? ( its probably right in front of my eyes...)

Thanks!
12-29-2008 07:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
Re: Mounting objects with offset
don't use hand_r.pos += ..; (because skeleton point returned by cskel.getPoint returns a reference to an point in array, so once you'll modify it, it will remain changed in the skeleton as well)

what you want to do is something like this:
Vec pos=hand_r.pos + 0.1f * hand_r.dir; // you can try 'hand_r.dir' or 'hand_r.perp' or 'hand_r.cross()' which are the 3 different local axis vectors

m.setPosDir(pos,hand_r.perp,hand_r.dir) // here 'pos' is used instead of 'hand_r.pos'
.scaleOrn(0.7);
12-29-2008 07:36 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #3
Re: Mounting objects with offset
Beautiful - looks like exactly what I need...
12-29-2008 07:56 PM
Find all posts by this user Quote this message in a reply
Post Reply