- Home /
Obtaining the relative size of a Models body part
Hello there,
I am trying to calculate the xyz position of "important" regions on my models, I am doing this by:
Transform [] allChildren = this.transform.GetComponentsInChildren<Transform>();
foreach (Transform child in allChildren)
{
Vector3 objectPos = child.transform.position;
}
However this only gives me an xyz coordinate of the center of each object. However what I need is the xyz coordinates of points like the elbow and shoulder, instead of these I am actually obtaining the xyz coordinates of the center of the upper arm.
One way I can see of obtaining the coordinates I need would be to obtain the size of the upper arm and then extrapolate the location of the Shoulder and elbow from that.
How would I go about obtaining the size of the body part to calculate this? I'm pretty stumped right now.
Note: I am using this Model
Answer by Benproductions1 · Jul 16, 2013 at 10:51 AM
Hello,
As you might have noticed this is nowhere near as simple as it sounds. Your solution would require you to analyse the mesh data of that object. If you are confident enough to be able to find the vertices that make up the elbow, then find their size, go for it. But I presume that is beyond your capabilities (gathering from the code you posted)
A much simpler and elegant solution is to have an empty object representing the elbow point as a child of the elbow joint. Getting the "xyz" position of that points would be as simple as grabbing a reference of that objects Transform
component and doing Transform.position
.
Hope this helps,
Benproductions1
PS: If you do want a solution to actually find the size of the elbow, I can give you more detail to one I just came up with ;)
$$anonymous$$y intent isn't to actually work out the size of the elbow but to actually get the elbows xyz coordinate. By getting the size of the arm i would in theory be able to work out the xyz position of the elbow....As you mention the elbow joint is there a way of obtaining a joint right out?
As I said, if you want to find the elbow joint, the best method is an empty, reference object. If you don't understand the words I used in my answer, look them up :)
Your answer
Follow this Question
Related Questions
Why does object lerp to above the object it is lerping to? 1 Answer
stop object(door) translation 0 Answers
Transform.Position Collision Issue 0 Answers
If gameobject moves do this 1 Answer