|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic Page: 1 2 »» |
Last Thread Next Thread ![]() |
| Working with the DirectX .X File Format and Animation in DirectX 9.0 |
|
![]() dirtbag Member since: 3/30/2004 |
||||
|
|
||||
| Hey Jason,nice article Just 1 quick question though... (Copied from my previous post about it) Is there a certain way in creating animation-set's in a package like 3D Studio Max,for the .X Format,or does the direct x exporter(depending on which one)handle seperating them automatically. E.G,you have a character in 3DStudio that has 130 frames of animation. 0-29 has an idle anim,30-59 has a walk...run etc. How do you actually seperate them,into something like set1: idle set2: walk set3: run set4:die etc etc?? Is it animation package specific or DirectX exporter specific? DirectXXX Member since: 9/24/2002 From: Pakistan Posted - 1 April 2004 10:37:13 AM directx supports animation set if you are a programmer you have to modify example exporter of max to save .x animation sets. But if you are not a programmer just save individual .x files of each set and use MeshView utility that comes with DXSDK to combine them into 1 .x file. dirtbag Member since: 3/30/2004 From: Posted - 1 April 2004 11:16:33 AM What i really want to have is several anim sets in only 1 file. Btw,i'm a programmer Iv'e actually just read the new article on the .X format(here on the news page).If i'm unsuccessful in this thread,i'll post there. So,i gather the (easiest)solution would be to say..animate an idle animation,then export to .x format.Animate my other sets,exporting as seperate files. Then finally,open then up,and copy and paste the sets from all the differnt files,into 1 .xfile. Yes? No? dirtbag Member since: 3/30/2004 From: Posted - 1 April 2004 11:26:44 AM One more thing.. Iv'e opened an .xfile with notepad. which sections need to be copy + pasted to the 1 file? The section at the bottom after: } and at the start of the word.. AnimationSet{ etc...etc.. } end of the file? Appreciate your help jason. |
||||
|
||||
![]() __Daedalus__ Member since: 12/12/2002 From: Edinburgh, United Kingdom |
||||
|
|
||||
| If you look within an X file that has animations (e.g tiny.x) you'll see that there are templates called "AnimationSet" amongst all the others. They take the form of AnimationSet { . . Data and sub-templates etc . . } An "AnimationSet" encapsulates any one animation. There are typically many "Animation" templates within an "AnimationSet" - as many "Animation" templates as there are bones in your model. If you export to text format you can easily give the single animation a name like this AnimationSet WalkAnim { . . Data and sub-templates etc . . } which you can reference in your game engine (or see in the MeshView utility). So essentially and to answer you question, you can export your animations from MAX one at a time in to individual X files. With the model being the same you can just copy the entire AnimationSet templates from each X file and paste them one after the other in a single file. Just give each AnimationSet a unique name. |
||||
|
||||
![]() jasonjurecka Member since: 4/4/2004 From: USA |
||||
|
|
||||
| Sorry about the late reply. the exporter that I used just used the Maya time scale to deside what is an animation set. If I wanted to put multiple animations into one model I would have to export out the seperate animation data and then copy/paste it into the model. I know this is kinda getto but I did not write the exporter. the models that I used in the article are included in the MS SDK examples if you would like to take a look at them. I hope this answers your question. if not feel free to email me. ___________________________ Jason Jurecka www.jurecka.us jason@jurecka.us www.tsbgames.com "Everything is a game." [edited by - jasonjurecka on April 4, 2004 5:42:59 AM] |
||||
|
||||
![]() Roquqkie Member since: 4/11/2001 From: Hellerup, Denmark |
||||
|
|
||||
| Hi Jason Thanks for a great article...! I've implemented the code into my own project, but if I use lighting the model is all black!? Do you have any idea what to do? Best regards Roquqkie mikkel.hempel@tele2adsl.dk |
||||
|
||||
![]() Trip99 Member since: 8/11/2002 From: Whitby, United Kingdom |
||||
|
|
||||
| You can load models with different animation sets into the MeshView utility (comes with SDK) and combine them together into one .x file |
||||
|
||||
![]() jasonjurecka Member since: 4/4/2004 From: USA |
||||
|
|
||||
| it is good to hear people are using it. The model is black because the model does not have vert normals. there is an DX9 SDK example which goes through adding them in. I dont remember off hand which one it was but i do remember that the test app had a skull for the .x file that was used. If you have the sdk look at the sample browser. ___________________________ Jason Jurecka www.jurecka.us jason@jurecka.us www.tsbgames.com "Everything is a game." [edited by - jasonjurecka on April 6, 2004 5:15:24 PM] |
||||
|
||||
![]() Roquqkie Member since: 4/11/2001 From: Hellerup, Denmark |
||||
|
|
||||
| Hi Jason Yes I kindda figured that out, so I computed its normals using the DX Mesh viewer, which is included in the SDK-tools. In the mesh-viewer I can see it with lighting... But! It's still black! :| Best regards Roquqkie [edited by - Roquqkie on April 7, 2004 8:45:05 AM] |
||||
|
||||
![]() jasonjurecka Member since: 4/4/2004 From: USA |
||||
|
|
||||
| Ok well check and make sure you have the texture in the right directory. In the tutorial the texture that is used is assumed to be local to the location of the .x file. ___________________________ Jason Jurecka www.jurecka.us jason@jurecka.us www.tsbgames.com "Everything is a game." |
||||
|
||||
![]() Roquqkie Member since: 4/11/2001 From: Hellerup, Denmark |
||||
|
|
||||
| The texture is working... When I turn off lighting I can see the texture... Best regards Roquqkie |
||||
|
||||
![]() jasonjurecka Member since: 4/4/2004 From: USA |
||||
|
|
||||
| Make sure the light is being inited or setup. ___________________________ Jason Jurecka www.jurecka.us jason@jurecka.us www.tsbgames.com "Everything is a game." |
||||
|
||||
![]() jasonjurecka Member since: 4/4/2004 From: USA |
||||
|
|
||||
| for all of you that are haveing these errors: C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CModel.cpp(45) : error C2259: 'CAllocateHierarchy' : cannot instantiate abstract class due to following members: C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CAllocateHierarchy.h(24) : see declaration of 'CAllocateHierarchy' C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CModel.cpp(45) : warning C4259: 'long __stdcall ID3DXAllocateHierarchy::CreateMeshContainer(const char *,const struct _D3DXMESHDATA *,const struct _D3DXMATERIAL *,const struct _D3DXEFFECTINS TANCE *,unsigned long,const unsigned long *,struct ID3DXSkinInfo *,struct _D3DXMESHCONTAINER ** )' : pure virtual function was not defined C:\DX90SDK\INCLUDE\d3dx9anim.h(168) : see declaration of 'CreateMeshContainer' C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CModel.cpp(45) : error C2259: 'CAllocateHierarchy' : cannot instantiate abstract class due to following members: C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CAllocateHierarchy.h(24) : see declaration of 'CAllocateHierarchy' C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CModel.cpp(45) : warning C4259: 'long __stdcall ID3DXAllocateHierarchy::CreateMeshContainer(const char *,const struct _D3DXMESHDATA *,const struct _D3DXMATERIAL *,const struct _D3DXEFFECTINS TANCE *,unsigned long,const unsigned long *,struct ID3DXSkinInfo *,struct _D3DXMESHCONTAINER ** )' : pure virtual function was not defined C:\DX90SDK\INCLUDE\d3dx9anim.h(168) : see declaration of 'CreateMeshContainer' C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CModel.cpp(64) : error C2259: 'CAllocateHierarchy' : cannot instantiate abstract class due to following members: C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CAllocateHierarchy.h(24) : see declaration of 'CAllocateHierarchy' C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CModel.cpp(64) : warning C4259: 'long __stdcall ID3DXAllocateHierarchy::CreateMeshContainer(const char *,const struct _D3DXMESHDATA *,const struct _D3DXMATERIAL *,const struct _D3DXEFFECTINS TANCE *,unsigned long,const unsigned long *,struct ID3DXSkinInfo *,struct _D3DXMESHCONTAINER ** )' : pure virtual function was not defined C:\DX90SDK\INCLUDE\d3dx9anim.h(168) : see declaration of 'CreateMeshContainer' C:\Documents and Settings\Stu\Desktop\TestApp-2079\TestApp\CModel.cpp(227) : error C2039: 'SetTime' : is not a member of 'ID3DXAnimationController' C:\DX90SDK\INCLUDE\d3dx9anim.h(671) : see declaration of 'ID3DXAnimationController' Error executing cl.exe. TestApp.exe - 4 error(s), 3 warning(s) You have DX9.0 with the summer update right? Those errors are caused by you having the summer update for DX9. open the file d3dx9anim.h search the file for "ID3DXAnimationController" when you find the actual interface there will be added parameters to the CreateMeshContainer function. just add them in and the code will compile. you need not change anything else in the code but the function header and definition. there is no functionallity that is changed in the app. ___________________________ Jason Jurecka www.jurecka.us jason@jurecka.us www.tsbgames.com "Everything is a game." [edited by - jasonjurecka on May 5, 2004 7:39:03 PM] |
||||
|
||||
![]() Uriel Member since: 4/12/2004 |
||||
|
|
||||
| Hm.. I get those errors: error C2039: 'SetTime' : is not a member of 'ID3DXAnimationController' error C2259: 'CAllocateHierarchy' : cannot instantiate abstract class error C2259: 'CAllocateHierarchy' : cannot instantiate abstract class I have summer update, thats true. But could you name those functions i have to overload in 'ID3DXAnimationController'. Before i found your post here i was looking for not overloaded funcs in ID3DXAllocateHierarchy, since that is the class from CAllocateHierarchy is derrived? Its rainy today and im sleepy (out of coffee) but no functions from 'ID3DXAnimationController' are overloaded in this sample and there are over 20 of them. All funcs from ID3DXAllocateHierarchy are overloaded properly. Also there is no such func like SetTime(..) in ID3DXAnimationController. It seems that SetTime was made obsolete by AdvanceTime... but i may be wrong. [edited by - Uriel on April 25, 2004 11:18:44 AM] |
||||
|
||||
![]() Uriel Member since: 4/12/2004 |
||||
|
|
||||
| STDMETHOD(CreateMeshContainer)(THIS_ LPCSTR Name, CONST D3DXMESHDATA *pMeshData, CONST D3DXMATERIAL *pMaterials, CONST D3DXEFFECTINSTANCE *pEffectInstances, DWORD NumMaterials, CONST DWORD *pAdjacency, LPD3DXSKININFO pSkinInfo, LPD3DXMESHCONTAINER *ppNewMeshContainer); This was the only func that needed to be overloaded. |
||||
|
||||
![]() Uriel Member since: 4/12/2004 |
||||
|
|
||||
| Ok, i made animations work with my resources managers. The problem is: i have the same problem as Roquqkie. When i turn on lights - ambient to be precise, all meshes turn black. I switch lights off - i see textures. Normals are OK, because 5 h ago my game was running nice with same meshes, lights and textures on. I experimented with materials, but even when i use tiny.x from sample as reference model, she is black without textures. Any help? |
||||
|
||||
![]() jasonjurecka Member since: 4/4/2004 From: USA |
||||
|
|
||||
| Make sure that the light is not inside the model. if it is inside the model then there would be no light on the outside for it to use so the model is black. ___________________________ Jason Jurecka www.jurecka.us jason@jurecka.us www.tsbgames.com "Everything is a game." |
||||
|
||||
![]() Uriel Member since: 4/12/2004 |
||||
|
|
||||
| Well, im using only ambient light so its not important where it is located. This code and meshes worked perfectly with lights , until i implemented animations. Then all went black. I suspect problem with materials, but that doesnt explain why tiny.x also renders black. Edit: Of course it was just stupid mistake - TextureStage was leaved in incorrect state by particle manager. It became problem when i stopped using standard LPD3DXMESH and its DrawSubset. "Clean After Yourself, Fool!" *smacks himself with hammer* Sorry for bothering you, and nice tutorial ;-) [edited by - Uriel on April 26, 2004 3:39:41 PM] |
||||
|
||||
![]() Zawinul Member since: 7/15/1999 |
||||
|
|
||||
| Nice job on this tutorial/sample, very nice layout and clean design. Altho I see the problem people are having.. you're creating the array of materials and not populating it. You're only populating the textures themselves. You need to set each material9 entry to "Materials.MatD3D" (the actual material inside the d3dxmaterial structure.) You can do that right in the same loop you're loading textures. -Z |
||||
|
||||
![]() jasonjurecka Member since: 4/4/2004 From: USA |
||||
|
|
||||
| Well thank you i am just happy that people are finding it useful. i think the materials are mem copied in there somewhere. ___________________________ Jason Jurecka www.jurecka.us jason@jurecka.us www.tsbgames.com "Everything is a game." [edited by - JasonJurecka on May 20, 2004 5:11:53 PM] |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| p |
||||
|
||||
![]() commy2005 Member since: 1/19/2005 From: Australia |
||||
|
|
||||
| I updated to the december 2004 version of SDK. I followed the instructions went to the d3dx9anim.h but can't find any CreateMeshContainer function in the D3DXAnimationController,did I follow the wrong step or something was wrong? I can't fix the compilation error,althought I checked everything is overloaded properly. |
||||
|
||||
![]() nooperation Member since: 6/24/2004 From: USA |
||||
|
|
||||
| I am using the December 2004 Update, and I was getting the CAllocateHierarchy and SetTime errors as follows: error C2259: 'CAllocateHierarchy' : cannot instantiate abstract class error C2259: 'CAllocateHierarchy' : cannot instantiate abstract class error C2039: 'SetTime' : is not a member of 'ID3DXAnimationController' I modified CAllocateHierarchy.h like this:
STDMETHOD(CreateMeshContainer)(THIS_
LPCSTR Name,
CONST D3DXMESHDATA *pMeshData,
CONST D3DXMATERIAL *pMaterials,
CONST D3DXEFFECTINSTANCE *pEffectInstances,
DWORD NumMaterials,
CONST DWORD *pAdjacency,
LPD3DXSKININFO pSkinInfo,
LPD3DXMESHCONTAINER *ppNewMeshContainer);
Note that if you leave the PURE at the end on from the d3dx9anim.h, you will still get errors. I also modified CAllocateHierarchy.cpp like this:
HRESULT CAllocateHierarchy::CreateMeshContainer(LPCTSTR Name,
CONST D3DXMESHDATA *pMeshData,
CONST D3DXMATERIAL *pMaterials,
CONST D3DXEFFECTINSTANCE *pEffectInstances,
DWORD NumMaterials,
CONST DWORD *pAdjacency,
LPD3DXSKININFO pSkinInfo,
LPD3DXMESHCONTAINER *ppNewMeshContainer)
I then modified CModel.cpp like this:
//m_pAnimController->SetTime(m_pAnimController->GetTime()+dElapsedTime);
m_pAnimController->AdvanceTime(dElapsedTime, NULL);
It runs great now. The only exception being that there's a message I get upon exit: "Run-Time Check Failure #2 - Stack around the variable 'cBuff' was corrupted. I think that cBuff was defined too small in main.cpp, so I changed it to read: char cBuff[64]; Now that error is gone too. Hope this helps. Thanks Jason for the tutorial. [Edited by - nooperation on January 21, 2005 11:39:56 AM] |
||||
|
||||
![]() nooperation Member since: 6/24/2004 From: USA |
||||
|
|
||||
| I was having the same problem with the model appearing black in my application. I was rendering some other objects using my old rendering code and they were working ok, so I knew it wasn't a problem with the lighting. I followed Zawinul's advice and looked up the MatD3D thing. I found that you need to copy the material and copy the ambient value to the diffuse value. The last two lines below are the the lines that I added in to CAllocateHierarchy.cpp: for(DWORD dw = 0; dw < NumMaterials; ++dw) { pMeshContainer->ppTextures [dw] = NULL; // Added these to lines to fix problem with lighting pMeshContainer->pMaterials9[dw] = pMaterials[dw].MatD3D; pMeshContainer->pMaterials9[dw].Ambient = pMeshContainer->pMaterials9[dw].Diffuse; [Edited by - nooperation on January 21, 2005 11:11:43 AM] |
||||
|
||||
![]() commy2005 Member since: 1/19/2005 From: Australia |
||||
|
|
||||
| Thanx nooperation!!!!Millions of thanx to you.I figure out too was the CreateMeshContainer's parameters are different too.I wanted to change that today.But with your validation,I changed it to what you stated...IT WORKS!!!!Thank you so much for the help. Yeah I was having the same thing(lighting) after i fixed the CreateMeshContainer problems.Now I could incorperate it into my game.Thanx to Jason with the GREAT article and you too nooperation!!!IT works!!it works!!! |
||||
|
||||
![]() Super Dude Member since: 1/23/2005 From: USA |
||||
|
|
||||
| I'm having trouble getting the sample to work correctly. I've made the changes to CAllocateHierarchy::CreateMeshContainer, and I've commented out the SetTime method, and changed it to the AdvanceTime method. Everything compiles, but when I load tiny.x it's stuck in one of it's poses and won't animate. I can still rotate it around. Here's what it looks like when I first load tiny, without rotating her or anything: ![]() On my dated system, I did have to change one thing to get it to run. I had do change the AutoDepthStencilFormat to D3DFMT_D16, instead of D3DFMT_D24S8. I'm running VC++6 on Win98 SE with the Directx 9.0 SDK (Summer 2004 Update). Thanks in advance for any replies/help with my problem! |
||||
|
||||
|
Page: 1 2 »» All times are ET (US) ![]() |
Last Thread Next Thread ![]() |
|