Home » Community » Forums » » Implementing Skin Meshes with DirectX 8
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic

Page:   1 2 »»

 Last Thread Next Thread 
 Implementing Skin Meshes with DirectX 8
Post Reply 
To compile your example under DirectX 8.1 you need to make a couple of changes to CMeshNode.cpp:

add
DWORD* face_remap = new DWORD[dwfacecount];
LPD3DXBUFFER vertex_remap;
result = D3DXCreateBuffer( dwfacecount, &vertex_remap );

change:
// blend the mesh
result = pD3DXSkinMesh->ConvertToBlendedMesh(MESH_WRITEONLY, padjacencyin, rgiAdjacency, &dwAttrCount, &pBoneCombinationBuf, face_remap, &vertex_remap, &pD3DXBlendedMesh );

add:
delete face_remap;
SAFERELEASE( vertex_remap );

Thanks for the article this stuff sure is confusing!



 User Rating: 1015    Report this Post to a Moderator | Link

You made a little mistake:

delete face_remap;

sould be changed to

delete [] face_remap;
face_remap = NULL;

 User Rating: 1016   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Hey I'm getting the following linking errors using DX8.1 sdk:

Compiling...
StdAfx.cpp
Compiling...
CAnimationNode.cpp
CFrameNode.cpp
CMeshNode.cpp
CObject.cpp
CSkinMesh.cpp
Exceptions.cpp
main.cpp
Generating Code...
Linking...
CAnimationNode.obj : error LNK2001: unresolved external symbol _TID_D3DRMAnimationKey
CAnimationNode.obj : error LNK2001: unresolved external symbol _TID_D3DRMFrame
CFrameNode.obj : error LNK2001: unresolved external symbol _TID_D3DRMFrame
CFrameNode.obj : error LNK2001: unresolved external symbol _TID_D3DRMAnimation
CSkinMesh.obj : error LNK2001: unresolved external symbol _TID_D3DRMAnimation
CFrameNode.obj : error LNK2001: unresolved external symbol _TID_D3DRMAnimationSet
CFrameNode.obj : error LNK2001: unresolved external symbol _TID_D3DRMFrameTransformMatrix
CFrameNode.obj : error LNK2001: unresolved external symbol _TID_D3DRMMesh
SkinMesh.exe : fatal error LNK1120: 6 unresolved externals
Error executing link.exe.
Creating browse info file...

SkinMesh.exe - 9 error(s), 0 warning(s)


 User Rating: 1015    Report this Post to a Moderator | Link

I wrote the sample code under DX 8. I haven't tried compiling it with DX8.1 yet. These external symbols (_TID_D3DRMFrame, ...) are the GUIDs of the mesh X templates. They are supposed to be contained in dxguid.lib. Make sure this library is included in:
Project Settings->Link->Object/library modules

Sorry for the spelling mistake in Fingure I am not a native English speaker after all.

Regards,
Sarmad A.


 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

From the Articles and Suggestions forum:

Original post by DamienBlews
I had one little problem in the DX8 article just highlighted on the main site. You get a error when you try to compile the prog...maybe it was only with mine for some ungodly reason, but here goes...

C:\Programming\skin_mesh_source\CMeshNode.cpp(181) : error C2660: 'ConvertToBlendedMesh' : function does not take 6 parameters


You would simply find the line and the function, and add NULL values to the sixth and seventh arguments like so...
result = pD3DXSkinMesh->ConvertToBlendedMesh( D3DXMESH_WRITEONLY,  
padjacencyin, 
rgiAdjacency, 
&dwAttrCount, 
&pBoneCombinationBuf, 
NULL,
NULL,
&pD3DXBlendedMesh );      


thanks, and I'm hoping I was kinda right..hehehe

 User Rating: 2077   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Gaiiden, I guess that is one way to fix it...
or you can do what Anonymous said in the first post here and change the function call and add 4 lines of code.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Hi!

I have a problem understanding how those matrices are created. I fully understand the notion of matrix stacks / matrix hierarchies. But I don´t undertand why they can be used with skinned bones that easily.
Take for instance:

FingerWorldMat = FingerMat * PalmMat * ForearmMat * ... * BodyMat

FingerWorldMat then expresses a transformation from the finger´s local system into the worldsystem. Given a finger-geometry, where the joint of that finger-bone is at [0,0,0] (the origin), this matrix will transform the finger at its final position in the world - I fully agree. This will perfectly work with multipart bodies.

But now what I don´t understand is, why

Vw = Vm * M1 * w + Vm * M2 * (1-w)

should work !?

Lets make it more obvious:

Vfinger = Vfinger* Mfinger * w + Vfinger * Mpalm * (1-w)

Usually Vfinger is given in modelspace. So how can Mfinger _and_ Mpalm transform this vertex meaningful? Shouldn´t the vertex be transformed into the bones´ system (thereby moving the bone´s joint into the origin), before applying the bone local transformation and then being transformed back into modelspace?
I´ve found no tutorial/paper yet, describing such a transformation. Am I stupid? Do I oversee something obvious ?

skynet



 User Rating: 1015    Report this Post to a Moderator | Link

skynet, you're not mistaken. What you've said is right, but it seems that you didn't read the article to the end. I have mentioned this in my article and this is a copy:

"So what is the bone offset? It's important to know that all the vertices of the skin mesh are stored relative to one origin, which is the origin of the mesh and not the local origin of the bone. This means that in order to have the influence of the bone on the mesh, we should deform the mesh by the difference between the bone's current transform and the bone's original transform. Or in other words, we should transform the vertices to the bone's local space and then transform them back to the mesh's space using the new transform of the bone."

Regards,
Sarmad A.


 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I was wondering why the bitmaps are mirrored in this example? if you load the same .X file in DXSDKs example, 'SkinnedMesh' bitmaps are ok.

 User Rating: 1015    Report this Post to a Moderator | Link

It's mirrored because it's using left hand coordinate system while the mesh is exported in a right hand coordinate system. You can correct this simply by using D3DXMatrixPerspectiveFovRH instead of D3DXMatrixPerspectiveFovLH and using CW polygon culling instead of CCW. Actually, it's not only the texture that's flipped, the whole mesh is flipped horizontally.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

To enable smooth filtered textures, enter two lines in main.cpp function InitDevice

void InitDevice( void )
{
// set the states of the device
g_pD3DDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
g_pD3DDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
//Enter the following function calls.
g_pD3DDevice->SetTextureStageState ( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
g_pD3DDevice->SetTextureStageState ( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );

//....


 User Rating: 1015    Report this Post to a Moderator | Link

To enable smooth filtered textures, enter two lines in main.cpp function InitDevice

void InitDevice( void )
{
// set the states of the device
g_pD3DDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
g_pD3DDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
//Enter the following function calls.
g_pD3DDevice->SetTextureStageState ( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
g_pD3DDevice->SetTextureStageState ( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );

//....


 User Rating: 1015    Report this Post to a Moderator | Link

Sarmad,

Thanks for your helful article/tutorial on Vertex and index-blended meshes. I've looked in many places for information like the code you offered and found your source code to be the most helpful. I've read quite a few programming books and articles on XMeshes, and none of the material even begins to cover real practical hands-on animation techniques beyond a "beginner's" grasp. The books I've read just refer me to the SDK examples, which I have to admit I find somewhat overwhelming. I know to write basic vetex shader code to animate sections of a cylinder, for example, but I'm really looking for much more instructional material that will get me up-to-speed on DX model animation to a professional level, so I can write original source code to animate vertices the way I want to (as vertex-blended index-blend) shader code and API pipeline, instead of just memorizing snippets of what someone else did. I've read "Rendering Tricks and techniques", "Zen of Direct3D", and other such books but they don't cover model animation on the level that you know how to do. What instructional books/article/resources..etc. would you suggest I persue??

Thanks,

Frank


 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I dont speak english very well. So I hope that you will understand me: I have a problem. For example I have an object, which is animated and has 5 positions of my animation, but I need jump from third position to start of animation(first position).Could you tell me how?
Thanks

 User Rating: 1015    Report this Post to a Moderator | Link

I dont speak english very well. So I hope that you will understand me: I have a problem. For example I have an object, which is animated and has 5 positions of my animation, but I need jump from third position to start of animation(first position).Could you tell me how?
Thanks

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Cheers dude,

Without your help i couldnt do my uni project

Would be nice to see the code in c as i could undersatnd it easier, but that's just a personal preference thanks no end mate.

Aaron

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

This article's great! Very informative. I have a question on this bit, though:

(in class CMeshNode, method GenerateMesh)
// calculate the max face influence count
if( (pD3DXBlendedMesh->GetFVF() & D3DFVF_POSITION_MASK) != D3DFVF_XYZ )
dwMaxFaceInfl = 1 + ((pD3DXBlendedMesh->GetFVF() & D3DFVF_POSITION_MASK) - D3DFVF_XYZRHW) / 2;
else
dwMaxFaceInfl = 1;
}

dwMaxFaceInfl is the argument for the render state of vertex blending... how does this equation come up with the required weighting?

[edited by - Riskbreaker on December 25, 2002 9:05:08 AM]

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

im really confused with this line...
from

CAnimationNode.cpp

in the

void CAnimation::SetTime(DWORD dwTime)

dwtime %= aMatrixKey[dwMatrixKeyCount-1].dwTime;


%= is a remainder operator right?
so what does this do? it does dwtime / aMatrixKey[dwMatrixKeyCount-1].dwTime ?

why is it important to get the remainder?

is it part of a loop, because it is below the if statement, so i guess it just does this once...

i don't really know what i am talking about... can anyone please explain me this... thanks

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

hi..will someone pls explain to me
in meshnode:
DWORD dwAttrCount;//!< The attribute count
what does this attribute do and contain ?


 User Rating: 1015    Report this Post to a Moderator | Link

To NeoDirect3D:

Answering your question on using the remainder, that line is used to get the point of the XFile animation that should be rendered. This function is executed continuously as the program runs (more than once).

aMatrixKey[dwMatrixKeyCount-1].dwTime

This value is the total running time of the animation, in milliseconds (4880 for the tiny.x walk cycle animation, I think). The function is called with a value gotten from the standard time function, so using the remainder function gets a value between 0 and 4880. This way, the program knows which transformation matrix to use for rendering. Every time the value passes 4880, the % pushes it back to zero, and the cycle repeats.

To AP, concerning the dwAttrCount:

That's the number of bone combinations that the ConvertToBlendedMesh function returns. It correlates to the pBoneCombinationBuf, which holds the actual bone combinations for the mesh as D3DXBONECOMBINATION structures. You need to know this information for rendering.

I hope this helps.

[edited by - Riskbreaker on January 5, 2003 2:57:29 AM]

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

thanks

 User Rating: 1015    Report this Post to a Moderator | Link

No prob. I have another question that hopefully someone can answer...

In the SetTime() function of the CAnimationNode class,
Why negate the x, y, and z quaternion key values for q1 and q2 before using D3DXQuaternionSlerp? Why's it necessary?

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

There's a bug in the CAnimationNode::SetTime function that will make animation based on position keys really herky-jerky.

CAnimationNode.cpp
line 492, which looks like:
void CAnimationNode::SetTime(DWORD dwtime)
...
// check for position keys
if( aPositionKey )
{
 ikey1 = ikey2 = 0;
 dwtime %= aPositionKey[dwPositionKeyCount-1].dwTime;
 // get the two keys surrounding the time value
 for( ikey = 0; ikey < dwPositionKeyCount; ikey++ )
  if( aPositionKey[ikey].dwTime > dwtime )
  {
   ikey2 = ikey1; // BUG!


the line should be

ikey2 = ikey;

The bug doesn't show up in the "tiny.x" example because all her animations are done with matrix keys rather than the rotation, scale, and position keys exported by most 3d programs. I love this tutorial though, thanks Sarmad!!


 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I'm compiling this under DirectX 8.1, and I get the following error:

Exceptions.obj : error LNK2001: unresolved external symbol "char const * __stdcall DXGetErrorString8A(long)" (?DXGetErrorString8A@@YGPBDJ@Z)
SkinMesh.exe : fatal error LNK1120: 1 unresolved externals


DXErr8.h is included, DXErr8.lib is in the project settings, as is DSGUID.lib.

What is missing?


 User Rating: 1015   |  Rate This User  Send Private MessageView ProfileView GD Showcase Entries Report this Post to a Moderator | Link
Page:   1 2 »»
All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: