Jump to content
  • Advertisement
Sign in to follow this  

[MDX] Animated meshes with HLSL [Semi-Solved]

This topic is 4424 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Everything with fixed function was working pretty well in my vb engine, now I'm updating it to use shaders, the static meshes have been quite easy to integrate with the excellent tutorials out there and some posts from this forum but the problem is coming with animated meshes, I've found a c# port of the simple animation sample. I'm using the same shader to start working so I adapted the changes to my engine to get it working but although I'm not getting any error neither tiny.x nor an animated cylinder I've created for testing purposes are showing on my render form, I'm including my DrawMeshContainer code that did work with ff but not with shaders. Any help would be appreciated. 'Not including the whole method xoDevice.RenderState.IndexedVertexBlendEnable = True Dim attribIdPrev As Integer = -1 Dim iattrib As Integer = 0 For iattrib = 0 To mesh.NumeroAtributos - 1 Dim numBlend As Integer = 0 Dim bones() As BoneCombination = mesh.Bones Dim i As Integer = 0 For i = 0 To mesh.NumeroInfluencias - 1 If bones(iattrib).BoneId(i) <> -1 Then numBlend = i End If Next If xoDevice.DeviceCaps.MaxVertexBlendMatrices >= numBlend + 1 Then Dim offsetMatrices() As Matrix = mesh.OffsetMatrices Dim frameMatrices() As ExFrame = mesh.Frames Dim clippedBoneMatrices(mesh.NumeroInfluencias - 1) As Matrix For i = 0 To mesh.NumeroInfluencias - 1 Dim matrixIndex As Integer = bones(iattrib).BoneId(i) If matrixIndex <> -1 Then Dim tempMatrix As Matrix = offsetMatrices(matrixIndex) * frameMatrices(matrixIndex).MatrizTransformacionCombinada clippedBoneMatrices(i) = tempMatrix End If Next foefecte.SetValue("mWorldMatrixArray", clippedBoneMatrices) foefecte.SetValue("CurNumBones", mesh.NumeroInfluencias - 1) xoDevice.RenderState.VertexBlend = CType(numBlend, VertexBlend) If (attribIdPrev <> bones(iattrib).AttributeId) Or (attribIdPrev = 1) Then Dim tempMateriales() As ExtendedMaterial = mesh.GetMaterials 'we add light contributions Dim color1 As Color = tempMateriales(bones(iattrib).AttributeId).Material3D.Ambient Dim color2 As Color = Color.FromArgb(255, 64, 64, 64) Dim color3 As Color = tempMateriales(bones(iattrib).AttributeId).Material3D.Emissive Dim ambEmm As Color = Microsoft.DirectX.Direct3D.ColorOperator.Modulate(color1, color2) ambEmm = ColorOperator.Add(ambEmm, color3) Dim color4 As ColorValue = ColorValue.FromColor(tempMateriales(bones(iattrib).AttributeId).Material3D.Diffuse) 'set color proerties in the shader foefecte.SetValue("MaterialDiffuse", color4) foefecte.SetValue("MaterialAmbient", ColorValue.FromColor(ambEmm)) Dim tempTextures() As Texture = mesh.Textura xoDevice.SetTexture(0, tempTextures(bones(iattrib).AttributeId)) attribIdPrev = bones(iattrib).AttributeId End If foefecte.CommitChanges() Dim pasActual As Integer = 0 Dim pasos As Integer = foefecte.Begin(FX.DoNotSaveState) For pasActual = 0 To pasos - 1 foefecte.BeginPass(pasActual) mesh.MeshData.Mesh.DrawSubset(iattrib) foefecte.EndPass() Next foefecte.End() End If Next Edit: I forgot to set the view projetion matrix, now the meshes are showing but some vertices are doing weird things, I've got to try some more things. [Edited by - Dreamy on June 6, 2006 5:31:15 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!