• 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
TheGoozah

Map PhysicsBones to ModelBones for Ragdoll (PhysX and DirectX)

3 posts in this topic

Hey gamedev,

 

for a college project I need to create a ragdoll using DirectX and PhysX.
I'm still in the first phase of laying out the structure for this ragdoll. At this moment I'm trying to map
actors to the bones that are imported together with mesh data. The problem I have at this moment is
that I can move my actor to the position of the bone (all offsets + world = worldmatrix).
But when I want it to follow the animation, my bone gets translated and rotated (axis) correctly, but my shape
doesn't rotate. Only the axis changes.

This engine is an engine written by some teachers, so I can't share it here. Also, the architecture is still
rough. Here are some snippets of where the issue is.

 

I hope this is a know issue and someone can help me with this one! It is pretty important for my project.

 

Thank you in advance guys/girls!!

void PhysxBone::MapToBone(MeshFilter* pMeshFilter)
{
       //........................
	m_matModelSpace *= m_pBone->Offset;

       //..................
	D3DXMATRIX world;
	D3DXMatrixIdentity(&world);
	m_matWorldSpace = m_matModelSpace * world;
}

void PhysxBone::Update(D3DXMATRIX matKeyTransform)
{
	m_matWorldSpace = matKeyTransform * m_matModelSpace;

	NxMat34 nPos;
	PhysicsManager::GetInstance()->DMatToNMat(nPos, m_matWorldSpace);
	m_pActor->setGlobalPose(nPos);
}

void PhysicsManager::DMatToNMat(NxMat34& NxMat, const D3DXMATRIX& D3DMat)
{
	NxVec3 vTmp;

	vTmp = NxVec3(D3DMat._11, D3DMat._21, D3DMat._31);
	NxMat.M.setRow(0, vTmp);

	vTmp = NxVec3(D3DMat._12, D3DMat._22, D3DMat._32);
	NxMat.M.setRow(1, vTmp);

	vTmp = NxVec3(D3DMat._13, D3DMat._23, D3DMat._33);
	NxMat.M.setRow(2, vTmp);

	NxMat.t.set(D3DMat._41, D3DMat._42, D3DMat._43);
}

 

0

Share this post


Link to post
Share on other sites

There are usually two scenarios:

 

1) The animation system is driving the physics

- All actors should be kinematic and you pass the target transforms. PhysX will compute the linear and angular velocities to reach the target transforms. There are other options which involve motors, but the version I mentioned is the easiest

 

2) The physic system is driving the bones.

- There are some gotchas here. The easiest case is when you have 1 : 1 mapping. This means every bone is associated with one rigid body. In this case you simply copy over the rigid body transforms to your bones. You must make sure you update the animation system so it can compute the local transforms if this is needed.

The more involved case is when there are more bones than rigid bodies. In this case you need to detect internal and leaf bones which are not driven by a rigid bodies. You would reset the internal bones to the bind pose and let the physic system deal with the possible joint errors. For the leaf bones you can do whatever you like. 

0

Share this post


Link to post
Share on other sites

Hey, sorry for the late respons.
Dirk Gregorius: I am having issues with putting the PhysX actors in the right position. For some reasons the data I get does not match as a direct input for PhysX actors. For the step 1 I put the actors on the correct position at this moment. Doing it your way would make it more difficult at this stage, but your version would be the final version offcourse.

So, I know how a ragdoll system should work. But I have issues with writing one myself :). In particular the first step.


If I position my actors using this formula: TotalOffset * LocalTransformAnimation

I get these results:

http://img842.imageshack.us/img842/8779/ragdollissues01.jpg

http://img21.imageshack.us/img21/6029/ragdollissues02.jpg

My TotalOffset is something like this:

TotalOffset = parentOffset * parentOffset * ........... * ownOffset;

 

Also checked some of the raw data from the .x itself. And found some strange things.

1. The offset of the bone is the offset based from the parent BUT the transform already has transform of the parent. This is kinda weird, why not both the final transform and offset or it's own offset and it's own local transform?

2. When I double check the numbers of the TotalOffset not all of them are correct. Some numbers that need to be 32.901 for exmample are 35.487.

 

I've been looking into this issue for a while now and haven't come up with a solution. Could someone guide me in solving this issue?

 

Here you can find some code, in my opinion, related to this problem:

http://pastebin.com/QT8sxuUp

 

PS: Everything works fine for the model itself (raw transform are being passed to a shader that positions the vertices to the right position). It is being animated correctly so there is no issue with the raw data from the .X file I guess (also double checked it with the Assimp Viewer).

0

Share this post


Link to post
Share on other sites

Sorry for bumping this thread but I am really desperate in finding my problems.
As said before I guess there is something wrong with my Offset and TransformMatrix calculations.

So here the snippet isolated: http://pastebin.com/gVTLCrbJ.

 

Anyone out here having experience with ragdolls or mapping actors to "bones" from an .x file?

Maybe one can point me in the right direction regarding formulas or pointing out an mistake in my
logic :)
Thx guys!

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