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


  • Content count

  • Joined

  • Last visited

Community Reputation

107 Neutral

About Sesha

  • Rank

Personal Information

  • Location
  1. I gave a try what you had adviced but didnt worked.I dont understand the logic why u asked me to do that. What i suspect is whether i am handling the ProjTex correctly.I can understand I miss something silly, but dont know what it is.   I had attached an image, in which i had textured the plain with the rendered shadowmap.   Worrying is shadow is not drawn.
  2. Hello people, I am tring shadow mapping in directx 9 with HLSL. My system config Dual core, 1.5 GB RAM, ATI RADON 6600. My Problem is i am getting the shadow map but it fails to produce shadow. I am following Frank D Luna's book. Attached my HLSL code. float4x4 matWorldViewProjection; float4x4 matWorldInverseTranspose; float4x4 matWorld; float4x4 matLWorld; float3 EyePos; texture gTex; texture gShadowMap; float3 LightDirection; float4 Ambient; float4 Diffuse; float4 Specular; float SpecularPower; float4x4 MatrixPalette[35]; int numBoneInfluence = 2; static const float SHADOW_EPSILON = 0.00005f; static const float SMAP_SIZE = 512.0f; sampler Texture = sampler_state { Texture = (gTex); ADDRESSU = WRAP; ADDRESSV = WRAP; MAGFILTER = Anisotropic; MINFILTER = Anisotropic; MIPFILTER = Anisotropic; MAXANISOTROPY = 2; }; sampler ShadowMapS = sampler_state { Texture = (gShadowMap); MinFilter = POINT; MagFilter = POINT; MipFilter = POINT; AddressU = CLAMP; AddressV = CLAMP; }; struct VSHADOW_OUTPUT { float4 Position : POSITION0; float2 Depth : TEXCOORD0; }; struct VSHADOW1_OUTPUT { float4 Position : POSITION0; float3 Normal : TEXCOORD0; float3 PosW : TEXCOORD1; float2 TextureCoord : TEXCOORD2; float4 ProjTex : TEXCOORD3; }; VSHADOW_OUTPUT BuildShadowMapVS(float4 Position : POSITION0) { VSHADOW_OUTPUT OutputSh; OutputSh.Position = mul( Position, matLWorld ); OutputSh.Depth.x = Position.z; OutputSh.Depth.y = Position.w; return OutputSh; }; float4 BuildShadowMapPS(float2 Depth : TEXCOORD0) : COLOR { return (Depth.x/Depth.y); } technique BuildShadowTech { pass P0 { VertexShader = compile vs_2_0 BuildShadowMapVS(); PixelShader = compile ps_2_0 BuildShadowMapPS(); } } VSHADOW1_OUTPUT LightShadowVS( float4 Position : POSITION0, float3 Normal : NORMAL0, float2 TextureCoord : TEXCOORD0 ) { VSHADOW1_OUTPUT Output; Output.Position = mul( Position, matWorldViewProjection ); Output.Normal = mul( Normal, matWorldInverseTranspose); Output.PosW = mul( Position, matWorld); Output.TextureCoord = TextureCoord; Output.ProjTex = mul( Position, matLWorld ); return Output; } float4 LightShadowPS(float3 normal : TEXCOORD0, float3 posW : TEXCOORD1, float2 TextureCoord : TEXCOORD2, float4 ProjTex : TEXCOORD3) : COLOR0 { normal = normalize(normal); posW = normalize(posW); float3 light = normalize(LightDirection); float3 toEye = normalize(EyePos - posW); float3 r = reflect(-light, normal); float t = pow(max(dot(r, toEye), 0.0f), SpecularPower); float diffuseContribution = max(dot(normal, light), 0.0f); float4 tex = tex2D(Texture, TextureCoord); float4 ambient = Ambient * tex; float4 diffuse = Diffuse * tex * diffuseContribution; float4 specular = Specular * tex * t; ProjTex.xy /= ProjTex.w; ProjTex.x = 0.5f*ProjTex.x + 0.5f; ProjTex.y = -0.5f*ProjTex.y + 0.5f; float depth = ProjTex.z / ProjTex.w; float2 texelpos = SMAP_SIZE * ProjTex.xy; float2 lerps = frac( texelpos ); float dx = 1.0f / SMAP_SIZE; float s0 = (tex2D(ShadowMapS, ProjTex.xy).r + SHADOW_EPSILON < depth) ? 0.0f : 1.0f; float s1 = (tex2D(ShadowMapS, ProjTex.xy + float2(dx, 0.0f)).r + SHADOW_EPSILON < depth) ? 0.0f : 1.0f; float s2 = (tex2D(ShadowMapS, ProjTex.xy + float2(0.0f, dx)).r + SHADOW_EPSILON < depth) ? 0.0f : 1.0f; float s3 = (tex2D(ShadowMapS, ProjTex.xy + float2(dx, dx)).r + SHADOW_EPSILON < depth) ? 0.0f : 1.0f; float shadowCoeff = lerp( lerp( s0, s1, lerps.x ), lerp( s2, s3, lerps.x ), lerps.y ); return float4(ambient + diffuse*shadowCoeff + specular*shadowCoeff); } technique DrawShadowTech { pass P0 { VertexShader = compile vs_2_0 LightShadowVS(); PixelShader = compile ps_2_0 LightShadowPS(); } } Please help me i am stuck with this. Thanks in advance.
  3. Hi Drakken255 try removing the TEXCOORD from the effect file and compile just with the material if it succeed then it is with blender. I know some in directx and not XNA.
  4. Hello mefistomanna, Try clicking at other places of the screen(near light) if light gets selected at some other point then i think you have to tune your origin and direction vectors. And also have a look at this http://toymaker.info/Games/html/picking.html.
  5. Hai people, After long practice now i am stuck with a simple problem. The thing is i want to render the second triangle of a square but it draws the next adjacent triangle. [CODE] void D3DApp::Init_Vertexbuffer() { HRESULT hr; float PosPtrX = -width*0.5f; float PosPtrZ = depth*0.5f; int i = 0; hr=d3ddev->CreateVertexBuffer(numVertices*sizeof(Vertices),D3DUSAGE_WRITEONLY,D3D9T_CUSTOMVERTEX,D3DPOOL_MANAGED,&vb,0); std::vector<D3DXVECTOR3>vert; vert.resize(numVertices); for(int j=0; j<numVertCols; j++) { for(int k=0; k<numVertRows; k++) { vert[i].x = PosPtrX; vert[i].y = 0.0f; vert[i].z = PosPtrZ; PosPtrZ += -dz; ++i; } PosPtrX += +dx; PosPtrZ = depth*0.5f; } hr=vb->Lock(0,0,(void**)&v,0); for(int i = 0; i<numVertices; ++i) { v[i].pos = vert[i]; v[i].col = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); } vb->Unlock(); } void D3DApp::Init_Indexbuffer() { HRESULT hr; int numIndices = 3 * numTris; hr=d3ddev->CreateIndexBuffer(numIndices*sizeof(Vertices),D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_MANAGED,&ib,0); std::vector<DWORD>index; index.resize(numIndices); int c = 0; for(int a=0; a<numCellCols; a++) { for(int b=0; b<numCellRows; b++) { index[c++] = a * numVertRows + b; index[c++] = (a + 1) * numVertRows + b; index[c++] = a * numVertRows + b + 1; index[c++] = a * numVertRows + b + 1; index[c++] = (a + 1) * numVertRows + b; index[c++] = (a + 1) * numVertRows + b + 1; //c += 6; } } WORD *k = 0; hr=ib->Lock(0,0,(void**)&k,0); for(int i = 0; i<numIndices; ++i) k[i] = (WORD)index[i]; ib->Unlock(); } void D3DApp::Scene_Update(HWND &hWnd) { d3ddev->Clear(0,0,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0xff888888,1.0f,0); d3ddev->BeginScene(); cInput.Press(); if(cInput.KeyDown(DIK_LCONTROL)) { thetaY += cInput.MouseX() / 250.0f; } z -= cInput.MouseZ() / 3000.0f; camx = (z * 1.5f * width * sin(thetaY)); camy = (z * 1.5f * width * sin(thetaZ)); camz = (z * 1.5f * depth * cos(thetaY)); eyevector=D3DXVECTOR3(camx, camy, -camz); D3DXMatrixLookAtLH(&viewmatrix,&eyevector,&lookatvector,&upvector); d3ddev->SetFVF(D3D9T_CUSTOMVERTEX); d3ddev->SetStreamSource(0,vb,0,sizeof(Vertices)); d3ddev->SetIndices(ib); mfx->SetMatrix(mMatrix,&(viewmatrix*projectionmatrix)); mfx->SetTechnique(mTech); d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME); d3ddev->SetRenderState(D3DRS_LIGHTING,FALSE); d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE ); UINT numpass=0; mfx->Begin(&numpass,0); for(unsigned int a=0; a < numpass; ++a) { mfx->BeginPass(a); d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,numVertices,0,numTris); mfx->EndPass(); } mfx->End(); //d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME); if(cInput.KeyDown(DIK_LSHIFT)) CheckHit(hWnd); d3ddev->EndScene(); Time.End_Timer(); d3ddev->Present(0,0,0,0); } void D3DApp::CheckHit(HWND &hWnd) { POINT s; float w, h; D3DXVECTOR3 Origin; D3DXVECTOR3 Dir; D3DXMATRIX invView; GetCursorPos(&s); ScreenToClient(hWnd, &s); w = (float)d3dpp.BackBufferWidth; h = (float)d3dpp.BackBufferHeight; float x = ( (2.0f * s.x / w) - 1.0f) / viewmatrix._11; float y = -( (2.0f * s.y / h) - 1.0f) / viewmatrix._22; Origin = D3DXVECTOR3(x, y, 1.0f); Dir = D3DXVECTOR3(x, y, 100.0f); D3DXMatrixInverse(&invView, 0, &viewmatrix); D3DXVec3TransformCoord(&Origin, &Origin, &invView); D3DXVec3TransformNormal(&Dir, &Dir, &invView); D3DXVec3Normalize(&Dir, &Dir); float bu = 0.0f; float bv = 0.0f; float Dist = 0.0f; D3DXVECTOR3 vector0; D3DXVECTOR3 vector1; D3DXVECTOR3 vector2; int c = 0; for(int a=0; a<numCellCols; a++) { for(int b=0; b<numCellRows; b++) { vector0 = v[ a * numVertRows + b].pos; vector1 = v[(a + 1) * numVertRows + b].pos; vector2 = v[ a * numVertRows + b + 1].pos; if(D3DXIntersectTri(&vector0, &vector1, &vector2, &Origin, &Dir, &bu, &bv, &Dist)) { vb->Lock(0,0,(void**)&v,0); v[ a * numVertRows + b].col = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f); v[(a + 1) * numVertRows + b].col = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f); v[ a * numVertRows + b + 1].col = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f); vb->Unlock(); UINT numpass=0; mfx->Begin(&numpass,0); for(unsigned int d=0; d < numpass; ++d) { mfx->BeginPass(d); d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,(a * numVertRows + b),0,3,0,1); mfx->EndPass(); } mfx->End(); vb->Lock(0,0,(void**)&v,0); v[ a * numVertRows + b].col = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); v[(a + 1) * numVertRows + b].col = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); v[ a * numVertRows + b + 1].col = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); vb->Unlock(); } vector0 = v[ a * numVertRows + b + 1].pos; vector1 = v[(a + 1) * numVertRows + b].pos; vector2 = v[(a + 1) * numVertRows + b + 1].pos; if(D3DXIntersectTri(&vector0, &vector1, &vector2, &Origin, &Dir, &bu, &bv, &Dist)) { vb->Lock(0,0,(void**)&v,0); v[ a * numVertRows + b + 1].col = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f); v[(a + 1) * numVertRows + b].col = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f); v[(a + 1) * numVertRows + b + 1].col = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f); vb->Unlock(); UINT numpass=0; mfx->Begin(&numpass,0); for(unsigned int d=0; d < numpass; ++d) { mfx->BeginPass(d); d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,(a * numVertRows + b + 1),0,3,0,1); mfx->EndPass(); } mfx->End(); vb->Lock(0,0,(void**)&v,0); v[ a * numVertRows + b + 1].col = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); v[(a + 1) * numVertRows + b].col = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); v[(a + 1) * numVertRows + b + 1].col = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); vb->Unlock(); }//end if }//end for b }//end for a /*Vertices *vertex = 0; hr=vb->Lock(0,0,(void**)&v,0); for(int i = 0; i<numVertices; ++i) { v[i].pos = vert[i]; v[i].col = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f); } vb->Unlock();*/ } [/CODE] Drawing the second drawindexprimitive of checkhit() is the focus it draws the wrong second vertex. Thanks in advance.
  6. Hi OCN.FiX. If the texture is not loading, be sure the texture file is within the folder or specified place, another thing is to change FVF declaration in the line if (FAILED(d3ddev->CreateVertexBuffer(WIDTH * HEIGHT * sizeof(OURCUSTOMVERTEX), 0, D3DFVF_XYZ|D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &p_dx_VertexBuffer, NULL))) from D3DFVF_XYZ|D3DFVF_DIFFUSE to D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1
  7. Hi Tinytimrob i too had the same problem. I think removing D3DCLEAR_ZBUFFER from the line appsys.display.device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0,0,0,0), 1.0f, 0);may help you.
  8. [color="#000000"]Hi guys i am new to this forum and this is my first post. My aim of the program is to load simple animated mesh based on toymaker tutorial. Now the problem is updateskinnedmesh for the model is returning a [/color]D3DERR_INVALIDCALL. There is no problem when i render the source mesh and the originalmesh of meshcontainer without skinning, the problem comes as the updateskinnedmesh is used. Source is as given below. XFileloader.cpp [code]#include<windows.h> #include<assert.h> #include"XFileLoader.h" void Xloader::Load(LPDIRECT3DDEVICE9 &pDevice) { d3dDev=pDevice; HierarchyLoader *Allocator = new HierarchyLoader; D3DXLoadMeshHierarchyFromX("Bounce.x", D3DXMESH_MANAGED, d3dDev, Allocator, NULL, &RootFrame, &AnimeController); if(AnimeController) NumAnimation = AnimeController->GetMaxNumAnimationSets(); if(RootFrame) { SetUpBoneMatrices((Bone*)RootFrame); CurrentBoneMatrix = new D3DXMATRIX[maxBone]; ZeroMemory(CurrentBoneMatrix, sizeof(D3DXMATRIX)*maxBone); } delete Allocator; Allocator = 0; } void Xloader::SetUpBoneMatrices(Bone *RootBone) { BoneMesh *boneMesh = (BoneMesh*)RootBone->pMeshContainer; while(boneMesh && boneMesh->pSkinInfo) { D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]; if (FAILED(boneMesh->MeshData.pMesh->GetDeclaration(Declaration))) return; boneMesh->MeshData.pMesh->CloneMesh(D3DXMESH_MANAGED,Declaration,d3dDev,&boneMesh->OriginalMesh); maxBone = max(maxBone,(UINT)boneMesh->pSkinInfo->GetNumBones()); D3DXFRAME* TempFrame = NULL; for(unsigned int i=0; i<boneMesh->pSkinInfo->GetNumBones(); i++) { const char* boneName = boneMesh->pSkinInfo->GetBoneName(i); TempFrame = D3DXFrameFind(RootBone, boneName); if(TempFrame) { Bone* tempFrame = (Bone*)TempFrame; boneMesh->BoneMatrixPtrs[i] = &tempFrame->CombinedTransformationMatrix; } } boneMesh=(BoneMesh*)boneMesh->pNextMeshContainer; } if(RootBone->pFrameSibling!=NULL) SetUpBoneMatrices((Bone*)RootBone->pFrameSibling); if(RootBone->pFrameFirstChild!=NULL) SetUpBoneMatrices((Bone*)RootBone->pFrameFirstChild); } void Xloader::Update(D3DXMATRIX *ParentMatrix,float &Radius,float &TimeElapsed) { if(AnimeController!=NULL) { AnimeController->AdvanceTime(TimeElapsed,NULL); } currentTime+=TimeElapsed; UpdateBoneMatrices(RootFrame, ParentMatrix); UpdateMesh(RootFrame, Radius); } void Xloader::UpdateBoneMatrices(D3DXFRAME *bone,D3DXMATRIX *ParentMatrix) { Bone *CurrentBone = (Bone*)bone; if(ParentMatrix!=NULL) { D3DXMatrixMultiply(&CurrentBone->CombinedTransformationMatrix, &CurrentBone->TransformationMatrix, ParentMatrix); }else{ CurrentBone->CombinedTransformationMatrix = CurrentBone->TransformationMatrix; } if(CurrentBone->pFrameSibling!=NULL) UpdateBoneMatrices(CurrentBone->pFrameSibling, ParentMatrix); if(CurrentBone->pFrameFirstChild!=NULL) UpdateBoneMatrices(CurrentBone->pFrameFirstChild, &CurrentBone->CombinedTransformationMatrix); } void Xloader::UpdateMesh(D3DXFRAME *currentBone, float &Radius) { HRESULT hr; Bone *bone = (Bone*)currentBone; BoneMesh *bMesh = (BoneMesh*)bone->pMeshContainer; while(bMesh && bMesh->pSkinInfo) { unsigned int numBones = bMesh->pSkinInfo->GetNumBones(); assert(numBones<=maxBone); for(unsigned int i=0; i < numBones; ++i) { assert(i<maxBone); D3DXMatrixMultiply(&CurrentBoneMatrix[i], &bMesh->BoneOffsetMatrices[i], bMesh->BoneMatrixPtrs[i]); } void *src = 0; void *dest = 0; bMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&src); bMesh->OriginalMesh->LockVertexBuffer(0, (void**)&dest); hr=bMesh->pSkinInfo->UpdateSkinnedMesh(CurrentBoneMatrix, NULL, src, dest); if(hr=D3DERR_INVALIDCALL) MessageBox(NULL,"D3DERR_INVALIDCALL","Skinning",MB_OK); //D3DXComputeBoundingSphere((D3DXVECTOR3*)dest,bMesh->OriginalMesh->GetNumVertices(),D3DXGetFVFVertexSize(bMesh->pSkinInfo->GetFVF()),&center,&rad); Radius=rad; bMesh->OriginalMesh->UnlockVertexBuffer(); bMesh->MeshData.pMesh->UnlockVertexBuffer(); bMesh = (BoneMesh*)bMesh->pNextMeshContainer; } if(bone->pFrameSibling!=NULL) UpdateMesh((Bone*)bone->pFrameSibling, Radius); if(bone->pFrameFirstChild!=NULL) UpdateMesh((Bone*)bone->pFrameFirstChild, Radius); } void Xloader::RenderMesh(void) { if (RootFrame) DrawFrame(RootFrame); } void Xloader::DrawFrame(LPD3DXFRAME MainFrame) { LPD3DXMESHCONTAINER Mesh = MainFrame->pMeshContainer; while(Mesh) { DrawMesh(Mesh, MainFrame); Mesh = Mesh->pNextMeshContainer; } if (MainFrame->pFrameSibling!=NULL) DrawFrame(MainFrame->pFrameSibling); if (MainFrame->pFrameFirstChild!=NULL) DrawFrame(MainFrame->pFrameFirstChild); } void Xloader::DrawMesh(LPD3DXMESHCONTAINER RMesh, LPD3DXFRAME RFrame) { Bone *RBone = (Bone*)RFrame; BoneMesh *RMeshContainer = (BoneMesh*)RMesh; if(RMeshContainer->pSkinInfo!=NULL) { D3DXMATRIX mat,Trans; D3DXMatrixIdentity(&mat); D3DXMatrixIdentity(&Trans); D3DXMatrixTranslation(&Trans, 0.0f, 0.0f, 0.0f); D3DXMatrixMultiply(&mat, &mat, &Trans); d3dDev->SetTransform(D3DTS_WORLD, &mat); }else{ D3DXMATRIX mat; D3DXMatrixIdentity(&mat); D3DXMatrixTranslation(&mat, 0.0f, 0.0f, 0.0f); D3DXMatrixMultiply(&mat, &mat, &RBone->CombinedTransformationMatrix); d3dDev->SetTransform(D3DTS_WORLD, &RBone->CombinedTransformationMatrix); } for(unsigned int iMat=0; iMat<RMeshContainer->NumMaterials; iMat++) { d3dDev->SetMaterial(&RMeshContainer->MaterialList[iMat]); d3dDev->SetTexture(0, RMeshContainer->TextureList[iMat]); //LPD3DXMESH pDrawMesh = (RMeshContainer->pSkinInfo) ? RMeshContainer->OriginalMesh: RMeshContainer->MeshData.pMesh; //pDrawMesh->DrawSubset(iMat); RMeshContainer->OriginalMesh->DrawSubset(iMat); } } void Xloader::LoaderRelease() { AnimeController->Release(); } void Xloader::SetAnimation() { CurrentAnimation = 1; LPD3DXANIMATIONSET AnimeSet = NULL; AnimeController->GetAnimationSet(CurrentAnimation, &AnimeSet); AnimeController->SetTrackAnimationSet(CurrentAnimation, AnimeSet); AnimeSet->Release(); }[/code] Hierarchy.cpp [code]#include"Hierarchy.h" HRESULT HierarchyLoader::CreateFrame(LPCSTR Name, LPD3DXFRAME *ppNewFrame) { *ppNewFrame = 0; Bone *newBone=new Bone; ZeroMemory(newBone,sizeof(Bone)); D3DXMatrixIdentity(&newBone->TransformationMatrix); D3DXMatrixIdentity(&newBone->CombinedTransformationMatrix); newBone->pMeshContainer=0; newBone->pFrameSibling=0; newBone->pFrameFirstChild=0; *ppNewFrame=newBone; if(Name) { int nNameSize = strlen(Name)+1; newBone->Name = new char[nNameSize]; memcpy(newBone->Name, Name, nNameSize*sizeof(char)); }else{ newBone->Name = NULL; } return S_OK; } HRESULT HierarchyLoader::DestroyFrame(LPD3DXFRAME pFrameToFree) { if(pFrameToFree) { if(pFrameToFree->Name!=NULL) delete[]pFrameToFree->Name; delete pFrameToFree; } pFrameToFree=NULL; return S_OK; } HRESULT HierarchyLoader::CreateMeshContainer(LPCSTR Name, const D3DXMESHDATA *pMeshData, const D3DXMATERIAL *pMaterials, const D3DXEFFECTINSTANCE *pEffectInstances, DWORD NumMaterials, const DWORD *pAdjacency, LPD3DXSKININFO pSkinInfo, LPD3DXMESHCONTAINER *ppNewMeshContainer) { BoneMesh *newBoneMesh=new BoneMesh; ZeroMemory(newBoneMesh, sizeof(BoneMesh)); *ppNewMeshContainer = 0; if(Name) { // Put in the name int nNameSize = strlen(Name)+1; newBoneMesh->Name = new char[nNameSize]; memcpy(newBoneMesh->Name, Name, nNameSize*sizeof(char)); }else{ newBoneMesh->Name = NULL; } if(pMeshData->Type!=D3DXMESHTYPE_MESH) { DestroyMeshContainer(newBoneMesh); return E_FAIL; } newBoneMesh->MeshData.Type=D3DXMESHTYPE_MESH; DWORD dwFaces = pMeshData->pMesh->GetNumFaces(); newBoneMesh->pAdjacency = new DWORD[dwFaces*3]; if(pAdjacency) { memcpy(newBoneMesh->pAdjacency, pAdjacency, sizeof(DWORD)*dwFaces*3); }else{ if(FAILED( newBoneMesh->MeshData.pMesh->GenerateAdjacency( 1e-6f, (DWORD*)(void*)newBoneMesh->pAdjacency ) ) ) FillMemory((void*)newBoneMesh->pAdjacency, dwFaces*3, 0xFF ); } IDirect3DDevice9 *pDevice=0; pMeshData->pMesh->GetDevice(&pDevice); newBoneMesh->MeshData.pMesh=pMeshData->pMesh; pMeshData->pMesh->AddRef(); newBoneMesh->NumMaterials=max(NumMaterials,1); newBoneMesh->MaterialList=new D3DMATERIAL9[newBoneMesh->NumMaterials]; newBoneMesh->TextureList=new LPDIRECT3DTEXTURE9[newBoneMesh->NumMaterials]; if(newBoneMesh->NumMaterials>0) { for(DWORD i=0; i<NumMaterials; i++) { newBoneMesh->TextureList[i]=0; newBoneMesh->MaterialList[i]=pMaterials[i].MatD3D; newBoneMesh->MaterialList[i].Ambient=newBoneMesh->MaterialList[i].Diffuse; if(FAILED(D3DXCreateTextureFromFileA(pDevice,pMaterials[i].pTextureFilename,&newBoneMesh->TextureList[i]))) newBoneMesh->TextureList[i]=NULL; } }else{ newBoneMesh->MaterialList=new D3DMATERIAL9[0]; newBoneMesh->MaterialList[0].Diffuse.r=1.0f; newBoneMesh->MaterialList[0].Diffuse.g=1.0f; newBoneMesh->MaterialList[0].Diffuse.b=1.0f; newBoneMesh->MaterialList[0].Diffuse.a=1.0f; newBoneMesh->TextureList=new LPDIRECT3DTEXTURE9[0]; newBoneMesh->TextureList[0]=0; } if(pSkinInfo!=NULL) { newBoneMesh->pSkinInfo=pSkinInfo; pSkinInfo->AddRef(); //pMeshData->pMesh->CloneMeshFVF(D3DXMESH_MANAGED, pMeshData->pMesh->GetFVF(), pDevice, &newBoneMesh->MeshData.pMesh); int NumBones=pSkinInfo->GetNumBones(); newBoneMesh->BoneOffsetMatrices=new D3DXMATRIX[NumBones]; newBoneMesh->BoneMatrixPtrs = new D3DXMATRIX*[NumBones]; for(int i=0; i<NumBones; i++) newBoneMesh->BoneOffsetMatrices[i]=*(newBoneMesh->pSkinInfo->GetBoneOffsetMatrix(i)); }else{ newBoneMesh->pSkinInfo = 0; newBoneMesh->OriginalMesh = 0; newBoneMesh->BoneOffsetMatrices = 0; newBoneMesh->BoneMatrixPtrs = 0; } pDevice->Release(); *ppNewMeshContainer = newBoneMesh; return S_OK; } HRESULT HierarchyLoader::DestroyMeshContainer(LPD3DXMESHCONTAINER pMeshContainerToFree) { BoneMesh* meshContainer = (BoneMesh*)pMeshContainerToFree; if (!meshContainer) return S_OK; delete []meshContainer->Name; meshContainer->Name=0; delete []meshContainer->MaterialList; meshContainer->MaterialList=0; if(meshContainer->TextureList) { for(UINT i = 0; i < meshContainer->NumMaterials; ++i) { if (meshContainer->TextureList) meshContainer->TextureList[i]->Release(); } } delete []meshContainer->TextureList; delete []meshContainer->pAdjacency; delete []meshContainer->BoneOffsetMatrices; if (meshContainer->OriginalMesh) meshContainer->OriginalMesh->Release(); if (meshContainer->MeshData.pMesh) meshContainer->MeshData.pMesh->Release(); if (meshContainer->pSkinInfo) meshContainer->pSkinInfo->Release(); delete meshContainer; meshContainer=0; return S_OK; }[/code] Thanks in advance for your help.