• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
nbviper

Multiple Mesh World Transformation help

3 posts in this topic

Hello,

I hope you can help me out with this. I'm attempting to manipulate the position and orientation of a human skeleton in a 3D environment. The skeleton is made up of multiple meshes (skull, body core, left arm, right arm).

The skull and body have the same center of rotation, but the arms have a center of rotation located at the top of each arm. (This is because I need to manipulate the arms separately from the body, later on).

My problem is, I can't seem to figure out the correct transformation to keep the arms with the body. My current code looks as follows (using SlimDX):


[code]
//Body
_device.SetTransform(TransformState.World, Matrix.Scaling(_scale, _scale, _scale)
* Matrix.RotationY(_skullYPR.Y) //Rotation about the Y axis
* Matrix.Translation(_position)); //Location in 3D space
...
...


//Right Upper Arm
_device.SetTransform(TransformState.World, Matrix.Scaling(_scale, _scale, _scale)
* Matrix.RotationY(_skullYPR.Y)
* Matrix.Translation(_position.X - 5.0f, _position.Y - 5.5f, _position.Z)); //Offset of arm position
[/code]


This results in the arm remaining in the same position (with a proper rotation around it's own center of rotation) I've attach a couple images for you to reference.

I've tried adding additional rotation matrices, but I'm just having a brain fart right now and can't think it through properly.

The question is how do I properly apply a rotation that takes into account the translation from the center of the body?

Facing Forward, everything is ok. (I know a collar bone is missing :) )
[attachment=2199:facing forward.png]
Rotated, rotates in position, doesn't move with body
[attachment=2200:rotated.png]

Any help or direction would be greatly appreciated!!!
0

Share this post


Link to post
Share on other sites
You want to build the transform of the child bones by appending them to the transforms of the parent bones.

First, some abbrebiations to make things simpler:

Mb: body matrix
Ma: arm matrix

Sb: body scale
Rb: body rotation
Tb: body translation
Sa: arm scale
Ra: arm rotation
Ta: arm translation

If your body matrix is defined like this:

Mb = Sb * Rb * Tb,

then your arm matrix would be defined like this:

Ma = Sa * Ra * Ta * Mb
or
Ma = Sa * Ra * Ta * Sb * Rb * Tb

Basically everything that you put on the left hand side adds to the chain of transforms. In this case the arm translation is only the offset from the center of the body to the arm position, it has nothing to do with the arm's global position. Because you're chaining it together with the body translation, you can say that the arm translation is defined in "body space", instead of "world space", where you would supply the actual coordinate of it. Again the arm rotation is only the rotation of the arm in its own local space, it doesn't have anything to do with the rotation of the body.

You could do a similar thing with a hand mesh, by defining its rotation and translation relative to the position of the arm.

Mh = Sh * Rh * Th * Sa * Ra * Ta * Sb * Rb * Tb.

This concept comes up a lot when doing animation, basically in the simplest explanation is that when you have an object whose transform is a derivative of some parent, then you want to define the position of the sub object relative to the coordinate space of the parent, don't try to compute it directly in the world space. Its the same concept whether you're dealing with hands on arms on torsos or moons orbiting planets orbiting stars.
2

Share this post


Link to post
Share on other sites
The keyword to look for is "forward kinematics", often simply called "parenting"; karwosts has described its math for row vectors and the usual transformation chain scale -> rotation -> translation.

However, the things may be more complicated dependent on how the various co-ordinate spaces in use are placed and related. Each mesh, when imported for its own, has its local co-ordinate space. The 1st transformation applied uses it as its reference. The 2nd transformation then is applied w.r.t. the so transformed space. The 3rd transformation ... and so on. Hence, you may need to adapt the space in order to apply a transformation in the desired space if that space isn't accidentally coincident with the current one. That means extra steps to take if e.g. the center of scaling and the center of rotation isn't the same point, or e.g. (using karwosts' solution) the co-ordinate frame of the arm isn't directly given w.r.t. the frame of the body.
1

Share this post


Link to post
Share on other sites
Perfect, thank you both! This makes complete sense.

My skeleton is now whole. :)

Thank you again for the clear explanation!
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0