viewing a rig using spheres.
Blitz3D Forums/Blitz3D Programming/viewing a rig using spheres.
| ||
Hello again, After a huge amount of pointers about surface choosing I have moved my way to viewing a mesh's rig using spheres. I am assuming due to the fact I know very little about .b3d exporting I am missing a couple key elements to this event and I am hoping someone out there could lend me a hand with this. What I have us a mesh loaded into game from a file. You select "Load Mesh" , select the mesh you want and it loads in. I have the camera,lights and all in place functioning. Using a few examples here on the forum I coded in to find each Bone Name and I get the x,y,z location of each. Create a Sphere and Position that sphere at the Bones x y z location. Using a combo box you can choose the Bone you want to look at. Forcing that bone sphere to change color to red. Everything runs well including the sphere color changing. The problem is the Sphere locations. They wont line up with the mesh. They also appear jumbled around. For instance : the Head bone is below the Neck bone. and are touching each other Here is the code for this event For bb.bone = Each bone ;get bone entity ID bonepos%=FindChild(MeshEN,bb\BoneName) bb\bonex = EntityX(bonepos) bb\boney = EntityY(bonepos) bb\bonez = EntityZ(bonepos) ;create the sphere and enter the entity ID bb\SphereEN=CreateSphere() ;Position the sphere at the proper local PositionEntity(bb\SphereEN,EntityX(bonepos%),EntityY(bonepos%),EntityZ(bonepos%)) ;add this bone name to the combo box AddComboBoxItem( cbo_bonenames, 0, bb\BoneName , "" ) Next I believe my problem is a logical one. I just can not seem to wrap my head around it, after reading the snippet a thousand times over I just can bot seem to grasp this. Any help and/or pointers would be great, Thanks! Last edited 2011 Last edited 2011 |
| ||
I think this is a local/global positioning issue. You're creating the spheres without any parent. However, the position you extract from the bones with EntityX etc. is local, as you haven't set the global position flag to True (Bones use parent/child relationships to represent the skeletal structure). Suggestion: try either creating the spheres as children of each other (for this you'll probably need to track which sphere is representing the parent bone), or positioning them using the bones' global coordinates (EntityX(bonepos, True) etc.). Which solution is best depends on what you want the representation to do: if it just stands still, global positions and no parents are fine. If it sticks to the character at all times, you could even just parent the spheres to the bones themselves. |
| ||
Thanks Yasha! I had the loop in place already for proper updates and the such. Setting the EntityX(bonepos,true) set me up perfectly! Now just have to find out why I am missing any bone that is at the end, like head,hands,feet... :) Thanks again for the tip........ |