Jump to content
  • Advertisement
Sign in to follow this  
jad_salloum

Animation in HLSL

This topic is 4654 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

hi all i am using HLSL and i am loading my animated mesh file but the problem is that it's animation is not working so in my window i find a still mesh with wrong hierarchy and not animating so can anyone tell me why this happened and how to fix it and where i can find tutorials for this subject ...

Share this post


Link to post
Share on other sites
Advertisement

this is my code ok for the animation in HLSL u can use the tiny.x that comes with the directx SDK and the program will work fine but it is not animating and not texturing can anyone check this code plz and tell me what is wrong ???


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.IO;
using System.Runtime.InteropServices;


namespace Chapter13Code
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private Device device = null;
// Animation code
private AnimationRootFrame rootFrame;
private Vector3 objectCenter;
private float objectRadius;
private float elapsedTime;
private Effect effect;

private Matrix MatProj , worldMatrix , MatView;

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

this.Setstyle(Controlstyles.AllPaintingInWmPaint | Controlstyles.Opaque, true);
}

/// <summary>
/// We will initialize our graphics device here
/// </summary>
public bool InitializeGraphics()
{
// Set our presentation parameters
PresentParameters presentParams = new PresentParameters();

presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
presentParams.EnableAutoDepthStencil = true;

bool canDoHardwareSkinning = true;
// Does a hardware device support shaders?
Caps hardware = Manager.GetDeviceCaps(0, DeviceType.Hardware);
// We will need at least four blend matrices
if (hardware.MaxVertexBlendMatrices >= 4)
{
// Default to software processing
CreateFlags flags = CreateFlags.SoftwareVertexProcessing;

// Use hardware if it's available
if (hardware.DeviceCaps.SupportsHardwareTransformAndLight)
flags = CreateFlags.HardwareVertexProcessing;

// Use pure if it's available
if (hardware.DeviceCaps.SupportsPureDevice)
flags |= CreateFlags.PureDevice;

// Yes, Create our device
device = new Device(0, DeviceType.Hardware, this, flags, presentParams);
}
else
{
// No shader support
canDoHardwareSkinning = false;

// Create a reference device
device = new Device(0, DeviceType.Reference, this,
CreateFlags.SoftwareVertexProcessing, presentParams);
}

// Create the animation
CreateAnimation(@"..\..\tiny.x", presentParams);
effect = Effect.FromFile(device, "diffuse.fx", null, ShaderFlags.PartialPrecision, null);

// Hook the device reset event
device.DeviceReset += new EventHandler(OnDeviceReset);
OnDeviceReset(device, null);

return canDoHardwareSkinning;
}

/// <summary>
/// Occurs after the device has been reset
/// </summary>
private void OnDeviceReset(object sender, EventArgs e)
{
Device dev = (Device)sender;

// Set the view matrix
Vector3 vEye = new Vector3( 0, 0, -1.8f * objectRadius );
Vector3 vUp = new Vector3( 0, 1, 0 );

MatView = Matrix.LookAtLH(vEye, objectCenter, vUp);

// Setup the projection matrix
float aspectRatio = (float)dev.PresentationParameters.BackBufferWidth
/ (float)dev.PresentationParameters.BackBufferHeight;

MatProj = Matrix.PerspectiveFovLH( (float)Math.PI / 4, aspectRatio,
objectRadius/64.0f, objectRadius*200.0f );

// Initialize our light
dev.Lights[0].Type = LightType.Directional;
dev.Lights[0].Direction = new Vector3(0.0f, 0.0f, 1.0f);
dev.Lights[0].Diffuse = Color.White;
// dev.Lights[0].Commit();
dev.Lights[0].Enabled = true;
}

/// <summary>
/// Create the animation hierarchy for this file
/// </summary>
private void CreateAnimation(string file, PresentParameters presentParams)
{
// Create our allocate hierarchy derived class
AllocateHierarchyDerived alloc = new AllocateHierarchyDerived(this);

// Load our file
rootFrame = Mesh.LoadHierarchyFromFile(file, MeshFlags.Managed,
device, alloc, null);

// Calculate the center and radius of a bounding sphere
objectRadius = Frame.CalculateBoundingSphere(rootFrame.FrameHierarchy,
out objectCenter);

// Setup the matrices for animation
SetupBoneMatrices((FrameDerived)rootFrame.FrameHierarchy);

// Start the timer
DXUtil.Timer(DirectXTimer.Start);
}

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
ProcessNextFrame();

device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);

device.BeginScene();


effect.SetValue("worldViewProj", worldMatrix * MatView * MatProj);
effect.SetValue("world", worldMatrix);
float time = (float)(Environment.TickCount * 0.001);
Vector4 lightPos = new Vector4((float)(50 * Math.Sin(time)), 0.0f, -(float)(200 * Math.Cos(time)), 1.0f);
effect.SetValue("lightPos", lightPos);
effect.Technique = "simple";
effect.Begin(0);
effect.BeginPass(0);

// Draw our root frame
DrawFrame((FrameDerived)rootFrame.FrameHierarchy);

effect.EndPass();
effect.End();


device.EndScene();

device.Present();

this.Invalidate();
}

/// <summary>
/// Draw a frame and all child and sibling frames
/// </summary>
/// <param name="frame">Frame to draw</param>
private void DrawFrame(FrameDerived frame)
{
MeshContainerDerived mesh = (MeshContainerDerived)frame.MeshContainer;
while(mesh != null)
{
DrawMeshContainer(mesh, frame);

mesh = (MeshContainerDerived)mesh.NextContainer;
}

if (frame.FrameSibling != null)
{
DrawFrame((FrameDerived)frame.FrameSibling);
}

if (frame.FrameFirstChild != null)
{
DrawFrame((FrameDerived)frame.FrameFirstChild);
}
}

/// <summary>
/// Draw a meshcontainer
/// </summary>
/// <param name="mesh">Mesh container to draw</param>
/// <param name="frame">Parent frame of this container</param>
private void DrawMeshContainer(MeshContainerDerived mesh, FrameDerived frame)
{
// Is there skin information?
if (mesh.SkinInformation != null)
{

int attribIdPrev = -1;

// Draw
for (int iattrib = 0; iattrib < mesh.NumberAttributes; iattrib++)
{
int numBlend = 0;
BoneCombination[] bones = mesh.GetBones();
for (int i = 0; i < mesh.NumberInfluences; i++)
{
if (bones[iattrib].BoneId != -1)
{
numBlend = i;
}
}

if (device.DeviceCaps.MaxVertexBlendMatrices >= numBlend + 1)
{
// first calculate the world matrices for the current set of
// blend weights and get the accurate count of the number of
// blends
Matrix[] offsetMatrices = mesh.GetOffsetMatrices();
FrameDerived[] frameMatrices = mesh.GetFrames();
for (int i = 0; i < mesh.NumberInfluences; i++)
{
int matrixIndex = bones[iattrib].BoneId;
if (matrixIndex != -1)
{
Matrix tempMatrix = offsetMatrices[matrixIndex] *
frameMatrices[matrixIndex].
CombinedTransformationMatrix;

device.Transform.SetWorldMatrixByIndex(i, tempMatrix);

}
}

device.RenderState.VertexBlend = (VertexBlend)numBlend;
// lookup the material used for this subset of faces
// if ((attribIdPrev != bones[iattrib].AttribId) ||
// (attribIdPrev == -1))
// {
// device.Material = mesh.GetMaterials()[
// bones[iattrib].AttribId].Material3D;
//
// device.SetTexture(0, mesh.GetTextures()[
// bones[iattrib].AttribId]);
//
// attribIdPrev = bones[iattrib].AttribId;
// }

mesh.MeshData.Mesh.DrawSubset(iattrib);
}
}
}
else // standard mesh, just draw it after setting material properties
{
device.Transform.World = frame.CombinedTransformationMatrix;

ExtendedMaterial[] mtrl = mesh.GetMaterials();
for (int iMaterial = 0; iMaterial < mtrl.Length; iMaterial++)
{
device.Material = mtrl[iMaterial].Material3D;
device.SetTexture(0, mesh.GetTextures()[iMaterial]);
mesh.MeshData.Mesh.DrawSubset(iMaterial);
}
}
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

/// <summary>
/// Generate the skinned mesh information
/// </summary>
/// <param name="mesh">Container of mesh to generate</param>
public void GenerateSkinnedMesh(MeshContainerDerived mesh)
{
if (mesh.SkinInformation == null)
throw new ArgumentException();

int numInfl = 0;
BoneCombination[] bones;

// Use ConvertToBlendedMesh to generate a drawable mesh
MeshData m = mesh.MeshData;
m.Mesh = mesh.SkinInformation.ConvertToBlendedMesh(m.Mesh, MeshFlags.Managed
| MeshFlags.OptimizeVertexCache, mesh.GetAdjacencyStream(), out numInfl,
out bones);

// Store this info
mesh.NumberInfluences = numInfl;
mesh.SetBones(bones);

// Get the number of attributes
mesh.NumberAttributes = bones.Length;

mesh.MeshData = m;
}

/// <summary>
/// Do all the processing for this frame before we render it
/// </summary>
private void ProcessNextFrame()
{
// Get the current elapsed time
elapsedTime = DXUtil.Timer(DirectXTimer.GetElapsedTime);

// Set the world matrix
worldMatrix = Matrix.Translation(objectCenter);
device.Transform.World = worldMatrix;

if (rootFrame.AnimationController != null)
rootFrame.AnimationController.AdvanceTime(elapsedTime, null);

UpdateFrameMatrices((FrameDerived)rootFrame.FrameHierarchy, worldMatrix);
}

/// <summary>
/// This method will set the bone matrices for a frame
/// </summary>
private void SetupBoneMatrices(FrameDerived frame)
{
if (frame.MeshContainer != null)
{
SetupBoneMatrices((MeshContainerDerived)frame.MeshContainer);
}

if (frame.FrameSibling != null)
{
SetupBoneMatrices((FrameDerived)frame.FrameSibling);
}

if (frame.FrameFirstChild != null)
{
SetupBoneMatrices((FrameDerived)frame.FrameFirstChild);
}
}

/// <summary>
/// Sets the bone matrices for a mesh container
/// </summary>
private void SetupBoneMatrices(MeshContainerDerived mesh)
{
// Is there skin information? If so, setup the matrices
if (mesh.SkinInformation != null)
{
int numBones = mesh.SkinInformation.NumberBones;

FrameDerived[] frameMatrices = new FrameDerived[numBones];
for(int i = 0; i< numBones; i++)
{
FrameDerived frame = (FrameDerived)Frame.Find(
rootFrame.FrameHierarchy,
mesh.SkinInformation.GetBoneName(i));

if (frame == null)
throw new ArgumentException();

frameMatrices = frame;
}
mesh.SetFrames(frameMatrices);
}
}

/// <summary>
/// Update the frames matrices and combine it with it's parents
/// </summary>
private void UpdateFrameMatrices(FrameDerived frame, Matrix parentMatrix)
{
frame.CombinedTransformationMatrix = frame.TransformationMatrix *
parentMatrix;

if (frame.FrameSibling != null)
{
UpdateFrameMatrices((FrameDerived)frame.FrameSibling, parentMatrix);
}

if (frame.FrameFirstChild != null)
{
UpdateFrameMatrices((FrameDerived)frame.FrameFirstChild,
frame.CombinedTransformationMatrix);
}
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new Size(800,600);
this.Text = "Form1";
}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
using (Form1 frm = new Form1())
{
// Show our form and initialize our graphics engine
frm.Show();
if (!frm.InitializeGraphics())
{
MessageBox.Show("Your card can not perform skeletal animation on " +
"this file in hardware. This application will run in " +
"ref mode instead.");
}
Application.Run(frm);
}
}
}
/// <summary>
/// The derived frame class
/// </summary>
public class FrameDerived : Frame
{
// Store the combined transformation matrix
private Matrix combined = Matrix.Identity;
public Matrix CombinedTransformationMatrix
{
get { return combined; } set { combined = value; }
}
}

/// <summary>
/// The derived mesh container class
/// </summary>
public class MeshContainerDerived : MeshContainer
{
private Texture[] meshTextures = null;
private int numAttr = 0;
private int numInfl = 0;
private BoneCombination[] bones;
private FrameDerived[] frameMatrices;
private Matrix[] offsetMatrices;

// Public properties
public Texture[] GetTextures() { return meshTextures; }
public void SetTextures(Texture[] textures) { meshTextures = textures; }

public BoneCombination[] GetBones() { return bones; }
public void SetBones(BoneCombination[] b) { bones = b; }

public FrameDerived[] GetFrames() { return frameMatrices; }
public void SetFrames(FrameDerived[] frames) { frameMatrices = frames; }

public Matrix[] GetOffsetMatrices() { return offsetMatrices; }
public void SetOffsetMatrices(Matrix[] matrices) { offsetMatrices = matrices; }

public int NumberAttributes { get { return numAttr; } set { numAttr = value; } }
public int NumberInfluences { get { return numInfl; } set { numInfl = value; } }
}

/// <summary>
/// AllocateHierarchy derived class
/// </summary>
public class AllocateHierarchyDerived : AllocateHierarchy
{
Form1 app = null;
/// <summary>
/// Create new instance of this class
/// </summary>
/// <param name="parent">Parent of this class</param>
public AllocateHierarchyDerived(Form1 parent)
{
app = parent;
}

/// <summary>
/// Create a new frame
/// </summary>
/// <returns>The newly created frame</returns>
public override Frame CreateFrame(string name)
{
FrameDerived frame = new FrameDerived();
frame.Name = name;
frame.TransformationMatrix = Matrix.Identity;
frame.CombinedTransformationMatrix = Matrix.Identity;

return frame;
}

/// <summary>
/// Create a new mesh container
/// </summary>
/// <returns>The newly created container</returns>
public override MeshContainer CreateMeshContainer(string name,
MeshData meshData, ExtendedMaterial[] materials,
EffectInstance[] effectInstances, GraphicsStream adjacency,
SkinInformation skinInfo)
{
// We only handle meshes here
if (meshData.Mesh == null)
throw new ArgumentException();

// We must have a vertex format mesh
if (meshData.Mesh.VertexFormat == VertexFormats.None)
throw new ArgumentException();

MeshContainerDerived mesh = new MeshContainerDerived();

mesh.Name = name;
int numFaces = meshData.Mesh.NumberFaces;
Device dev = meshData.Mesh.Device;

// Make sure there are normals
if ((meshData.Mesh.VertexFormat & VertexFormats.Normal) == 0)
{
// Clone the mesh
Mesh tempMesh = meshData.Mesh.Clone(meshData.Mesh.Options.Value,
meshData.Mesh.VertexFormat | VertexFormats.Normal, dev);

meshData.Mesh = tempMesh;
meshData.Mesh.ComputeNormals();
}

// Store the materials
mesh.SetMaterials(materials);
mesh.SetAdjacency(adjacency);
Texture[] meshTextures = new Texture[materials.Length];

// Create any textures
for (int i = 0; i < materials.Length; i++)
{
if (materials.TextureFilename != null)
{
meshTextures = TextureLoader.FromFile(dev, @"..\..\" +
materials.TextureFilename);
}
}
mesh.SetTextures(meshTextures);
mesh.MeshData = meshData;

// If there is skinning info, save any required data
if (skinInfo != null)
{
mesh.SkinInformation = skinInfo;
int numBones = skinInfo.NumberBones;
Matrix[] offsetMatrices = new Matrix[numBones];

for (int i = 0; i < numBones; i++)
offsetMatrices = skinInfo.GetBoneOffsetMatrix(i);

mesh.SetOffsetMatrices(offsetMatrices);

app.GenerateSkinnedMesh(mesh);
}

return mesh;
}

}
}

#region DXUtil

/// <summary>
/// Enumeration for various actions our timer can perform
/// </summary>
public enum DirectXTimer
{
Reset,
Start,
Stop,
Advance,
GetAbsoluteTime,
GetApplicationTime,
GetElapsedTime
};




/// <summary>
/// Generic utility functions for our samples
/// </summary>
public class DXUtil
{
#region Timer Internal Stuff
[System.Security.SuppressUnmanagedCodeSecurity] // We won't use this maliciously
[DllImport("kernel32")]
private static extern bool QueryPerformanceFrequency(ref long PerformanceFrequency);
[System.Security.SuppressUnmanagedCodeSecurity] // We won't use this maliciously
[DllImport("kernel32")]
private static extern bool QueryPerformanceCounter(ref long PerformanceCount);
[System.Security.SuppressUnmanagedCodeSecurity] // We won't use this maliciously
[DllImport("winmm.dll")]
public static extern int timeGetTime();
private static bool isTimerInitialized = false;
private static bool m_bUsingQPF = false;
private static bool m_bTimerStopped = true;
private static long m_llQPFTicksPerSec = 0;
private static long m_llStopTime = 0;
private static long m_llLastElapsedTime = 0;
private static long m_llBaseTime = 0;
private static double m_fLastElapsedTime = 0.0;
private static double m_fBaseTime = 0.0;
private static double m_fStopTime = 0.0;
#endregion

private DXUtil() { /* Private Constructor */ }

/// <summary>
/// Performs timer opertations. Use the following commands:
///
/// DirectXTimer.Reset - to reset the timer
/// DirectXTimer.Start - to start the timer
/// DirectXTimer.Stop - to stop (or pause) the timer
/// DirectXTimer.Advance - to advance the timer by 0.1 seconds
/// DirectXTimer.GetAbsoluteTime - to get the absolute system time
/// DirectXTimer.GetApplicationTime - to get the current time
/// DirectXTimer.GetElapsedTime - to get the time that elapsed between TIMER_GETELAPSEDTIME calls
///
/// </summary>
public static float Timer(DirectXTimer command)
{
if (!isTimerInitialized)
{
isTimerInitialized = true;

// Use QueryPerformanceFrequency() to get frequency of timer. If QPF is
// not supported, we will timeGetTime() which returns milliseconds.
long qwTicksPerSec = 0;
m_bUsingQPF = QueryPerformanceFrequency(ref qwTicksPerSec);
if (m_bUsingQPF)
m_llQPFTicksPerSec = qwTicksPerSec;
}
if (m_bUsingQPF)
{
double time;
double fElapsedTime;
long qwTime = 0;

// Get either the current time or the stop time, depending
// on whether we're stopped and what command was sent
if (m_llStopTime != 0 && command != DirectXTimer.Start && command != DirectXTimer.GetAbsoluteTime)
qwTime = m_llStopTime;
else
QueryPerformanceCounter(ref qwTime);

// Return the elapsed time
if (command == DirectXTimer.GetElapsedTime)
{
fElapsedTime = (double) (qwTime - m_llLastElapsedTime) / (double) m_llQPFTicksPerSec;
m_llLastElapsedTime = qwTime;
return (float)fElapsedTime;
}

// Return the current time
if (command == DirectXTimer.GetApplicationTime)
{
double fAppTime = (double) (qwTime - m_llBaseTime) / (double) m_llQPFTicksPerSec;
return (float)fAppTime;
}

// Reset the timer
if (command == DirectXTimer.Reset)
{
m_llBaseTime = qwTime;
m_llLastElapsedTime = qwTime;
m_llStopTime = 0;
m_bTimerStopped = false;
return 0.0f;
}

// Start the timer
if (command == DirectXTimer.Start)
{
if (m_bTimerStopped)
m_llBaseTime += qwTime - m_llStopTime;
m_llStopTime = 0;
m_llLastElapsedTime = qwTime;
m_bTimerStopped = false;
return 0.0f;
}

// Stop the timer
if (command == DirectXTimer.Stop)
{
if (!m_bTimerStopped)
{
m_llStopTime = qwTime;
m_llLastElapsedTime = qwTime;
m_bTimerStopped = true;
}
return 0.0f;
}

// Advance the timer by 1/10th second
if (command == DirectXTimer.Advance)
{
m_llStopTime += m_llQPFTicksPerSec/10;
return 0.0f;
}

if (command == DirectXTimer.GetAbsoluteTime)
{
time = qwTime / (double) m_llQPFTicksPerSec;
return (float)time;
}

return -1.0f; // Invalid command specified
}
else
{
// Get the time using timeGetTime()
double time;
double fElapsedTime;

// Get either the current time or the stop time, depending
// on whether we're stopped and what command was sent
if (m_fStopTime != 0.0 && command != DirectXTimer.Start && command != DirectXTimer.GetAbsoluteTime)
time = m_fStopTime;
else
time = timeGetTime() * 0.001;

// Return the elapsed time
if (command == DirectXTimer.GetElapsedTime)
{
fElapsedTime = (double) (time - m_fLastElapsedTime);
m_fLastElapsedTime = time;
return (float) fElapsedTime;
}

// Return the current time
if (command == DirectXTimer.GetApplicationTime)
{
return (float) (time - m_fBaseTime);
}

// Reset the timer
if (command == DirectXTimer.Reset)
{
m_fBaseTime = time;
m_fLastElapsedTime = time;
m_fStopTime = 0;
m_bTimerStopped = false;
return 0.0f;
}

// Start the timer
if (command == DirectXTimer.Start)
{
if (m_bTimerStopped)
m_fBaseTime += time - m_fStopTime;
m_fStopTime = 0.0f;
m_fLastElapsedTime = time;
m_bTimerStopped = false;
return 0.0f;
}

// Stop the timer
if (command == DirectXTimer.Stop)
{
if (!m_bTimerStopped)
{
m_fStopTime = time;
m_fLastElapsedTime = time;
m_bTimerStopped = true;
}
return 0.0f;
}

// Advance the timer by 1/10th second
if (command == DirectXTimer.Advance)
{
m_fStopTime += 0.1f;
return 0.0f;
}

if (command == DirectXTimer.GetAbsoluteTime)
{
return (float) time;
}

return -1.0f; // Invalid command specified
}
}
}



#endregion



[Edited by - Coder on September 25, 2005 3:22:55 AM]

Share this post


Link to post
Share on other sites
And this is the code for the effect file diffuse.fx


float4x4 worldViewProj : WORLDVIEWPROJ; //our world view projection matrix
float4x4 world :WORLD; //world matrix
float3 lightPos;

//application to vertex structure
struct a2v
{
float4 position : POSITION0;
float3 normal : NORMAL0;
float2 texCoord : TEXCOORD0;
};

//vertex to pixel shader structure
struct v2p
{
float4 position : POSITION0;
float2 texCoord : TEXCOORD0;
float4 color : COLOR0;
};

//VERTEX SHADER
void vs( in a2v IN, out v2p OUT)
{
//getting to position to object space
OUT.position = mul(IN.position, worldViewProj);
float3 posWorld = mul(IN.position, world).xyz; //get the vertex to world space
float3 normal = mul(IN.normal, world).xyz; //get the normal to world space
float3 light = normalize(lightPos - posWorld); //calculating the light direction
float lightIntensity = clamp(dot(normal, light), 0, 1); //calculate the light intensity and clamp it to a range
float3 lightColor = float3(1.0f, 1.0f, 1.0f); //set the light color
float4 color = float4(lightColor * lightIntensity, 1.0f); //calculate the color of the vertex
color.rgb += 0.5f; //add an ambient color to the shader
OUT.color = clamp(color, 0, 1); //set the color to the output color
OUT.texCoord = IN.texCoord;
}

technique simple
{
pass p0
{
vertexshader = compile vs_1_1 vs();
}
}


[Edited by - Coder on September 25, 2005 3:23:11 AM]

Share this post


Link to post
Share on other sites

guys there is no one who know what is problem with my program ??????????????????????????????????????? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! where r the professionals ????????

Share this post


Link to post
Share on other sites
7abiby Jad,

hows it going?

i know ur problem. there might be others hiding in there, but wats not moving ur mesh is u rnt updating ur mesh everyframe.

or if its there and im not seeing it, it might be the matrix that u pass in there. it has to be negative center, and not the center, just to make sure the object is centered correctly in place and bones r calculated right.

tell me if that helps!

Share this post


Link to post
Share on other sites
Hi there jad_salloum,
How are you doing?

The Problem
Animation in HLSL

The Solution
Normally when debugging these kinds of things I take one step back.
Check if the animation is correctly saved to the file.

Have you tested it in the fixed function pipeline?
It might seem stupid but it will give you an indication that your mesh has the animation correctly saved to the file.

Steps I would follow.

1) Check that the animation of the mesh has been saved correctly
2) Create a simple test bed in directx using the fixed function pipeline and test the animation
3) Create a simple shader that will just transform the vertices.. ignore details such as light. This means just take away items such as normals, textures etc..

Having followed these steps you will realise what is wrong and have a more definite question for us.

From a quick glance it looks like your shader will work.

Your problem might lie in your loading of the frame hierarchy etc...
Have a look and debug it using the FFP and see if it works. If it doesn't just review the tutorial you are following.

I hope this helps buddy.
Take care.
If you don't come right I will have a look at your loading code. I have to run out for a bit.

PS: Don't give up ;)

Share this post


Link to post
Share on other sites

well, the animation works fine in the fixed function pipeline and the .fx file is also working , and i tried to wpdate my worldmatrix to take the rootframe.combinedtransformationmatrix but the animation is still not working :(:( . my problem is in loading the fram hierarchy i know but i don't know how to fix it i tried many ways , but nothing is working , so how to load the animation is the a specific thing i should do ???

Share this post


Link to post
Share on other sites
Quote:
Original post by jad_salloum

guys there is no one who know what is problem with my program ??????????????????????????????????????? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! where r the professionals ????????

Make sure you read How to ask questions the smart way. There are a lot of professionals here, but none of them is interested in reading your whole 2 files searching for your bugs. If you've read the Forum FAQ, you'd have known that you should've posted the relevant bits of code, wrapped in source tags. You did neither.

Share this post


Link to post
Share on other sites

with all respect coder but if i know where the problem is in my game i would have solved it but i don't know where it is that's why i put all the code to let others use it without the need to redifine everything from the beggining and spend more time in fixing it , so now they just copy and paste the code and it will work , so why don't u try this ????

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!