• Create Account

### #ActualMatsK

Posted 25 February 2012 - 09:38 AM

Hey, I'm trying to render a mesh format where the vertices aren't stored with their actual coordinates in the file.
Here's the explanation I got:

in a mesh, vertices are stored as coordinates relative to the proximal end of the bone that they're attached to.
so you need to walk down the bone tree, and then for each vertex, rather than plotting it, move the camera to that position and obtain the absolute position of the camera, and then move back.
now you can store that position in the TransformedVertices array.
do that for both the fixed and blended vertices
then once the array is completely filled up, blend the blended vertices towards their fixed vertices that they're influenced by.
then you can draw all the faces for that mesh, and all the vertices will be in the right spots.

Here's my attempt to do the above:

public void TransformVertices2(Skeleton Skel)
{
float[,] LocalCopy;
foreach (Bone Bne in Skel.Bones)
{
foreach (BoneBinding BBinding in m_BoneBindings)
{
if (BBinding.BoneIndex == Bne.ID)
{
if (BBinding.FirstVertex != -1)
{
int VertexCount = 0;
if (BBinding.FirstVertex > BBinding.VertexCount)
VertexCount = BBinding.FirstVertex - BBinding.VertexCount;
else
VertexCount = BBinding.VertexCount - BBinding.FirstVertex;[/font]
LocalCopy = new float[VertexCount, 6];
Array.Copy(m_VertexData, BBinding.FirstVertex, LocalCopy, 0, VertexCount);[/font]
for (int i = 0; i < VertexCount; i++)
{
//The below is from: http://msdn.microsoft.com/en-us/library/bb197901.aspx
//Calculate the camera's current position.[/font]
//Set the direction the camera points without rotation.
Vector3 CameraReference = Bne.GlobalTranslation;
//Camera's position.
Vector3 CameraPos = new Vector3(LocalCopy[i, 0], LocalCopy[i, 1], LocalCopy[i, 2]);[/font]
Matrix RotationMatrix = Matrix.CreateFromQuaternion(Bne.GlobalRotation);
//Create a vector pointing the direction the camera is facing.
Vector3 TransformedReference = Vector3.Transform(CameraReference, RotationMatrix);
//Calculate the position the camera is looking at.
Vector3 CameraLookat = CameraPos + TransformedReference;[/font]
m_TransformedVertices[i] = CameraLookat;
}
}
if (BBinding.FirstBlendedVert != -1)
{
int BlendedVertexCount = 0;
if (BBinding.FirstBlendedVert > BBinding.BlendedVertexCount)
BlendedVertexCount = BBinding.FirstBlendedVert - BBinding.BlendedVertexCount;
else
BlendedVertexCount = BBinding.BlendedVertexCount - BBinding.FirstBlendedVert;[/font]
LocalCopy = new float[BlendedVertexCount, 6];
Array.Copy(m_VertexData, BBinding.FirstBlendedVert, LocalCopy, 0, BlendedVertexCount);[/font]
for (int j = 0; j < BlendedVertexCount; j++)
{
//The below is from: http://msdn.microsoft.com/en-us/library/bb197901.aspx
//Calculate the camera's current position.[/font]
//Set the direction the camera points without rotation.
Vector3 CameraReference = Bne.GlobalTranslation;
//Camera's position.
Vector3 CameraPos = new Vector3(LocalCopy[j, 0], LocalCopy[j, 1], LocalCopy[j, 2]);[/font]
Matrix RotationMatrix = Matrix.CreateFromQuaternion(Bne.GlobalRotation);
//Create a vector pointing the direction the camera is facing.
Vector3 TransformedReference = Vector3.Transform(CameraReference, RotationMatrix);
//Calculate the position the camera is looking at.
Vector3 CameraLookat = CameraPos + TransformedReference;[/font]
m_TransformedVertices[j] = CameraLookat;
}
}
}
}
}
}

Problem is, this doesn't work!
Can someone please explain how to implement this algorithm in XNA?

Here's my rendering code:

private void mWinForm_OnFrameRender(GraphicsDevice pDevice)
{
/*m_SBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);

m_SBatch.Draw(m_BackgroundTex, new Microsoft.Xna.Framework.Rectangle(0, 0, m_BackgroundTex.Width,
m_BackgroundTex.Height), Microsoft.Xna.Framework.Graphics.Color.White);

m_SBatch.End();*/

Device.RenderState.DepthBufferEnable = true;
Device.RenderState.DepthBufferWriteEnable = true;
Device.RenderState.AlphaBlendEnable = false;

// Configure effect
mSimpleEffect.World = this.mWorldMat;
mSimpleEffect.View = this.mViewMat;
mSimpleEffect.Projection = this.mProjectionMat;

if (m_Tex != null)
{
mSimpleEffect.Texture = m_Tex;
mSimpleEffect.TextureEnabled = true;

//Disable lights in an attempt to render bodies...
//mSimpleEffect.EnableDefaultLighting();
}

mSimpleEffect.CommitChanges();

// Draw
mSimpleEffect.Begin();
mSimpleEffect.Techniques[0].Passes[0].Begin();

if (m_NormVerticies != null)
{
{
if (m_CurrentMesh.IsBodyMesh)
{
//m_MatrixStack.Push(mSimpleEffect.World);
//mSimpleEffect.View = Matrix.Identity;

m_CurrentMesh.TransformVertices2(m_Skeleton);

//mSimpleEffect.View = m_MatrixStack.Pop();

m_CurrentMesh.BlendVertices2();
}

foreach (Face Fce in m_CurrentMesh.Faces)
{
VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
Vertex[0] = m_NormVerticies[Fce.AVertexIndex];
Vertex[1] = m_NormVerticies[Fce.BVertexIndex];
Vertex[2] = m_NormVerticies[Fce.CVertexIndex];

Vertex[0].TextureCoordinate = m_NormVerticies[Fce.AVertexIndex].TextureCoordinate;
Vertex[1].TextureCoordinate = m_NormVerticies[Fce.BVertexIndex].TextureCoordinate;
Vertex[2].TextureCoordinate = m_NormVerticies[Fce.CVertexIndex].TextureCoordinate;

pDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
Vertex, 0, 1);
}
}
}

mSimpleEffect.Techniques[0].Passes[0].End();
mSimpleEffect.End();

}

### #3MatsK

Posted 25 February 2012 - 09:37 AM

Hey, I'm trying to render a mesh format where the vertices aren't stored with their actual coordinates in the file.
Here's the explanation I got:

in a mesh, vertices are stored as coordinates relative to the proximal end of the bone that they're attached to.
so you need to walk down the bone tree, and then for each vertex, rather than plotting it, move the camera to that position and obtain the absolute position of the camera, and then move back.
now you can store that position in the TransformedVertices array.
do that for both the fixed and blended vertices
then once the array is completely filled up, blend the blended vertices towards their fixed vertices that they're influenced by.
then you can draw all the faces for that mesh, and all the vertices will be in the right spots.

Here's my attempt to do the above:

public void TransformVertices2(Skeleton Skel)
{
float[,] LocalCopy;[/font]
[font=Verdana, sans-serif]foreach (Bone Bne in Skel.Bones)
{
foreach (BoneBinding BBinding in m_BoneBindings)
{
if (BBinding.BoneIndex == Bne.ID)
{
if (BBinding.FirstVertex != -1)
{
int VertexCount = 0;
if (BBinding.FirstVertex > BBinding.VertexCount)
VertexCount = BBinding.FirstVertex - BBinding.VertexCount;
else
VertexCount = BBinding.VertexCount - BBinding.FirstVertex;[/font]
[font=Verdana, sans-serif]					LocalCopy = new float[VertexCount, 6];
Array.Copy(m_VertexData, BBinding.FirstVertex, LocalCopy, 0, VertexCount);[/font]
[font=Verdana, sans-serif]					for (int i = 0; i < VertexCount; i++)
{
//The below is from: http://msdn.microsoft.com/en-us/library/bb197901.aspx
//Calculate the camera's current position.[/font]
[font=Verdana, sans-serif]						//Set the direction the camera points without rotation.
Vector3 CameraReference = Bne.GlobalTranslation;
//Camera's position.
Vector3 CameraPos = new Vector3(LocalCopy[i, 0], LocalCopy[i, 1], LocalCopy[i, 2]);[/font]
[font=Verdana, sans-serif]						Matrix RotationMatrix = Matrix.CreateFromQuaternion(Bne.GlobalRotation);
//Create a vector pointing the direction the camera is facing.
Vector3 TransformedReference = Vector3.Transform(CameraReference, RotationMatrix);
//Calculate the position the camera is looking at.
Vector3 CameraLookat = CameraPos + TransformedReference;[/font]
[font=Verdana, sans-serif]						m_TransformedVertices[i] = CameraLookat;
}
}[/font]
[font=Verdana, sans-serif]				if (BBinding.FirstBlendedVert != -1)
{
int BlendedVertexCount = 0;
if (BBinding.FirstBlendedVert > BBinding.BlendedVertexCount)
BlendedVertexCount = BBinding.FirstBlendedVert - BBinding.BlendedVertexCount;
else
BlendedVertexCount = BBinding.BlendedVertexCount - BBinding.FirstBlendedVert;[/font]
LocalCopy = new float[BlendedVertexCount, 6];
Array.Copy(m_VertexData, BBinding.FirstBlendedVert, LocalCopy, 0, BlendedVertexCount);[/font]
for (int j = 0; j < BlendedVertexCount; j++)
{
//The below is from: http://msdn.microsoft.com/en-us/library/bb197901.aspx
//Calculate the camera's current position.[/font]
//Set the direction the camera points without rotation.
Vector3 CameraReference = Bne.GlobalTranslation;
//Camera's position.
Vector3 CameraPos = new Vector3(LocalCopy[j, 0], LocalCopy[j, 1], LocalCopy[j, 2]);[/font]
Matrix RotationMatrix = Matrix.CreateFromQuaternion(Bne.GlobalRotation);
//Create a vector pointing the direction the camera is facing.
Vector3 TransformedReference = Vector3.Transform(CameraReference, RotationMatrix);
//Calculate the position the camera is looking at.
Vector3 CameraLookat = CameraPos + TransformedReference;[/font]
m_TransformedVertices[j] = CameraLookat;
}
}
}
}
}
}

Problem is, this doesn't work!
Can someone please explain how to implement this algorithm in XNA?

Here's my rendering code:

private void mWinForm_OnFrameRender(GraphicsDevice pDevice)
{
/*m_SBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);

m_SBatch.Draw(m_BackgroundTex, new Microsoft.Xna.Framework.Rectangle(0, 0, m_BackgroundTex.Width,
m_BackgroundTex.Height), Microsoft.Xna.Framework.Graphics.Color.White);

m_SBatch.End();*/

Device.RenderState.DepthBufferEnable = true;
Device.RenderState.DepthBufferWriteEnable = true;
Device.RenderState.AlphaBlendEnable = false;

// Configure effect
mSimpleEffect.World = this.mWorldMat;
mSimpleEffect.View = this.mViewMat;
mSimpleEffect.Projection = this.mProjectionMat;

if (m_Tex != null)
{
mSimpleEffect.Texture = m_Tex;
mSimpleEffect.TextureEnabled = true;

//Disable lights in an attempt to render bodies...
//mSimpleEffect.EnableDefaultLighting();
}

mSimpleEffect.CommitChanges();

// Draw
mSimpleEffect.Begin();
mSimpleEffect.Techniques[0].Passes[0].Begin();

if (m_NormVerticies != null)
{
{
if (m_CurrentMesh.IsBodyMesh)
{
//m_MatrixStack.Push(mSimpleEffect.World);
//mSimpleEffect.View = Matrix.Identity;

m_CurrentMesh.TransformVertices2(m_Skeleton);

//mSimpleEffect.View = m_MatrixStack.Pop();

m_CurrentMesh.BlendVertices2();
}

foreach (Face Fce in m_CurrentMesh.Faces)
{
VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
Vertex[0] = m_NormVerticies[Fce.AVertexIndex];
Vertex[1] = m_NormVerticies[Fce.BVertexIndex];
Vertex[2] = m_NormVerticies[Fce.CVertexIndex];

Vertex[0].TextureCoordinate = m_NormVerticies[Fce.AVertexIndex].TextureCoordinate;
Vertex[1].TextureCoordinate = m_NormVerticies[Fce.BVertexIndex].TextureCoordinate;
Vertex[2].TextureCoordinate = m_NormVerticies[Fce.CVertexIndex].TextureCoordinate;

pDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
Vertex, 0, 1);
}
}
}

mSimpleEffect.Techniques[0].Passes[0].End();
mSimpleEffect.End();

}

### #2MatsK

Posted 25 February 2012 - 09:34 AM

Hey, I'm trying to render a mesh format where the vertices aren't stored with their actual coordinates in the file.
Here's the explanation I got:

in a mesh, vertices are stored as coordinates relative to the proximal end of the bone that they're attached to.
so you need to walk down the bone tree, and then for each vertex, rather than plotting it, move the camera to that position and obtain the absolute position of the camera, and then move back.
now you can store that position in the TransformedVertices array.
do that for both the fixed and blended vertices
then once the array is completely filled up, blend the blended vertices towards their fixed vertices that they're influenced by.
then you can draw all the faces for that mesh, and all the vertices will be in the right spots.

Here's my attempt to do the above:

public void TransformVertices2(Skeleton Skel)
{
float[,] LocalCopy;[/font]
[font=Verdana, sans-serif]	foreach (Bone Bne in Skel.Bones)
{
foreach (BoneBinding BBinding in m_BoneBindings)
{
if (BBinding.BoneIndex == Bne.ID)
{
if (BBinding.FirstVertex != -1)
{
int VertexCount = 0;
if (BBinding.FirstVertex > BBinding.VertexCount)
VertexCount = BBinding.FirstVertex - BBinding.VertexCount;
else
VertexCount = BBinding.VertexCount - BBinding.FirstVertex;[/font]
[font=Verdana, sans-serif]					LocalCopy = new float[VertexCount, 6];
Array.Copy(m_VertexData, BBinding.FirstVertex, LocalCopy, 0, VertexCount);[/font]
[font=Verdana, sans-serif]					for (int i = 0; i < VertexCount; i++)
{
//The below is from: http://msdn.microsoft.com/en-us/library/bb197901.aspx
//Calculate the camera's current position.[/font]
[font=Verdana, sans-serif]						//Set the direction the camera points without rotation.
Vector3 CameraReference = Bne.GlobalTranslation;
//Camera's position.
Vector3 CameraPos = new Vector3(LocalCopy[i, 0], LocalCopy[i, 1], LocalCopy[i, 2]);[/font]
[font=Verdana, sans-serif]						Matrix RotationMatrix = Matrix.CreateFromQuaternion(Bne.GlobalRotation);
//Create a vector pointing the direction the camera is facing.
Vector3 TransformedReference = Vector3.Transform(CameraReference, RotationMatrix);
//Calculate the position the camera is looking at.
Vector3 CameraLookat = CameraPos + TransformedReference;[/font]
[font=Verdana, sans-serif]						m_TransformedVertices[i] = CameraLookat;
}
}[/font]
[font=Verdana, sans-serif]				if (BBinding.FirstBlendedVert != -1)
{
int BlendedVertexCount = 0;
if (BBinding.FirstBlendedVert > BBinding.BlendedVertexCount)
BlendedVertexCount = BBinding.FirstBlendedVert - BBinding.BlendedVertexCount;
else
BlendedVertexCount = BBinding.BlendedVertexCount - BBinding.FirstBlendedVert;[/font]
[font=Verdana, sans-serif]					LocalCopy = new float[BlendedVertexCount, 6];
Array.Copy(m_VertexData, BBinding.FirstBlendedVert, LocalCopy, 0, BlendedVertexCount);[/font]
[font=Verdana, sans-serif]					for (int j = 0; j < BlendedVertexCount; j++)
{
//The below is from: http://msdn.microsoft.com/en-us/library/bb197901.aspx
//Calculate the camera's current position.[/font]
[font=Verdana, sans-serif]						//Set the direction the camera points without rotation.
Vector3 CameraReference = Bne.GlobalTranslation;
//Camera's position.
Vector3 CameraPos = new Vector3(LocalCopy[j, 0], LocalCopy[j, 1], LocalCopy[j, 2]);[/font]
[font=Verdana, sans-serif]						Matrix RotationMatrix = Matrix.CreateFromQuaternion(Bne.GlobalRotation);
//Create a vector pointing the direction the camera is facing.
Vector3 TransformedReference = Vector3.Transform(CameraReference, RotationMatrix);
//Calculate the position the camera is looking at.
Vector3 CameraLookat = CameraPos + TransformedReference;[/font]
[font=Verdana, sans-serif]						m_TransformedVertices[j] = CameraLookat;
}
}
}
}
}
}

Problem is, this doesn't work!
Can someone please explain how to implement this algorithm in XNA?

Here's my rendering code:

[/font]private void mWinForm_OnFrameRender(GraphicsDevice pDevice)
{
/*m_SBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);

m_SBatch.Draw(m_BackgroundTex, new Microsoft.Xna.Framework.Rectangle(0, 0, m_BackgroundTex.Width,
m_BackgroundTex.Height), Microsoft.Xna.Framework.Graphics.Color.White);

m_SBatch.End();*/

Device.RenderState.DepthBufferEnable = true;
Device.RenderState.DepthBufferWriteEnable = true;
Device.RenderState.AlphaBlendEnable = false;

// Configure effect
mSimpleEffect.World = this.mWorldMat;
mSimpleEffect.View = this.mViewMat;
mSimpleEffect.Projection = this.mProjectionMat;

if (m_Tex != null)
{
mSimpleEffect.Texture = m_Tex;
mSimpleEffect.TextureEnabled = true;

//Disable lights in an attempt to render bodies...
//mSimpleEffect.EnableDefaultLighting();
}

mSimpleEffect.CommitChanges();

// Draw
mSimpleEffect.Begin();
mSimpleEffect.Techniques[0].Passes[0].Begin();

if (m_NormVerticies != null)
{
{
if (m_CurrentMesh.IsBodyMesh)
{
//m_MatrixStack.Push(mSimpleEffect.World);
//mSimpleEffect.View = Matrix.Identity;

m_CurrentMesh.TransformVertices2(m_Skeleton);

//mSimpleEffect.View = m_MatrixStack.Pop();

m_CurrentMesh.BlendVertices2();
}

foreach (Face Fce in m_CurrentMesh.Faces)
{
VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
Vertex[0] = m_NormVerticies[Fce.AVertexIndex];
Vertex[1] = m_NormVerticies[Fce.BVertexIndex];
Vertex[2] = m_NormVerticies[Fce.CVertexIndex];

Vertex[0].TextureCoordinate = m_NormVerticies[Fce.AVertexIndex].TextureCoordinate;
Vertex[1].TextureCoordinate = m_NormVerticies[Fce.BVertexIndex].TextureCoordinate;
Vertex[2].TextureCoordinate = m_NormVerticies[Fce.CVertexIndex].TextureCoordinate;

pDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
Vertex, 0, 1);
}
}
}

mSimpleEffect.Techniques[0].Passes[0].End();
mSimpleEffect.End();

}[font=Verdana, sans-serif]

### #1MatsK

Posted 25 February 2012 - 09:33 AM

Hey, I'm trying to render a mesh format where the vertices aren't stored with their actual coordinates in the file.
Here's the explanation I got:

in a mesh, vertices are stored as coordinates relative to the proximal end of the bone that they're attached to.
so you need to walk down the bone tree, and then for each vertex, rather than plotting it, move the camera to that position and obtain the absolute position of the camera, and then move back.
now you can store that position in the TransformedVertices array.
do that for both the fixed and blended vertices
then once the array is completely filled up, blend the blended vertices towards their fixed vertices that they're influenced by.
then you can draw all the faces for that mesh, and all the vertices will be in the right spots.

Here's my attempt to do the above:

public void TransformVertices2(Skeleton Skel)
{
float[,] LocalCopy;[/font]
[font=Verdana, sans-serif]    foreach (Bone Bne in Skel.Bones)
{
foreach (BoneBinding BBinding in m_BoneBindings)
{
if (BBinding.BoneIndex == Bne.ID)
{
if (BBinding.FirstVertex != -1)
{
int VertexCount = 0;
if (BBinding.FirstVertex > BBinding.VertexCount)
VertexCount = BBinding.FirstVertex - BBinding.VertexCount;
else
VertexCount = BBinding.VertexCount - BBinding.FirstVertex;[/font]
[font=Verdana, sans-serif]				    LocalCopy = new float[VertexCount, 6];
Array.Copy(m_VertexData, BBinding.FirstVertex, LocalCopy, 0, VertexCount);[/font]
[font=Verdana, sans-serif]				    for (int i = 0; i < VertexCount; i++)
{
//The below is from: http://msdn.microsoft.com/en-us/library/bb197901.aspx
//Calculate the camera's current position.[/font]
[font=Verdana, sans-serif]					    //Set the direction the camera points without rotation.
Vector3 CameraReference = Bne.GlobalTranslation;
//Camera's position.
Vector3 CameraPos = new Vector3(LocalCopy[i, 0], LocalCopy[i, 1], LocalCopy[i, 2]);[/font]
[font=Verdana, sans-serif]					    Matrix RotationMatrix = Matrix.CreateFromQuaternion(Bne.GlobalRotation);
//Create a vector pointing the direction the camera is facing.
Vector3 TransformedReference = Vector3.Transform(CameraReference, RotationMatrix);
//Calculate the position the camera is looking at.
Vector3 CameraLookat = CameraPos + TransformedReference;[/font]
[font=Verdana, sans-serif]					    m_TransformedVertices[i] = CameraLookat;
}
}[/font]
[font=Verdana, sans-serif]			    if (BBinding.FirstBlendedVert != -1)
{
int BlendedVertexCount = 0;
if (BBinding.FirstBlendedVert > BBinding.BlendedVertexCount)
BlendedVertexCount = BBinding.FirstBlendedVert - BBinding.BlendedVertexCount;
else
BlendedVertexCount = BBinding.BlendedVertexCount - BBinding.FirstBlendedVert;[/font]
[font=Verdana, sans-serif]				    LocalCopy = new float[BlendedVertexCount, 6];
Array.Copy(m_VertexData, BBinding.FirstBlendedVert, LocalCopy, 0, BlendedVertexCount);[/font]
[font=Verdana, sans-serif]				    for (int j = 0; j < BlendedVertexCount; j++)
{
//The below is from: http://msdn.microsoft.com/en-us/library/bb197901.aspx
//Calculate the camera's current position.[/font]
[font=Verdana, sans-serif]					    //Set the direction the camera points without rotation.
Vector3 CameraReference = Bne.GlobalTranslation;
//Camera's position.
Vector3 CameraPos = new Vector3(LocalCopy[j, 0], LocalCopy[j, 1], LocalCopy[j, 2]);[/font]
[font=Verdana, sans-serif]					    Matrix RotationMatrix = Matrix.CreateFromQuaternion(Bne.GlobalRotation);
//Create a vector pointing the direction the camera is facing.
Vector3 TransformedReference = Vector3.Transform(CameraReference, RotationMatrix);
//Calculate the position the camera is looking at.
Vector3 CameraLookat = CameraPos + TransformedReference;[/font]
[font=Verdana, sans-serif]					    m_TransformedVertices[j] = CameraLookat;
}
}
}
}
}
}

Problem is, this doesn't work!
Can someone please explain how to implement this algorithm in XNA?

Here's my rendering code:

private void mWinForm_OnFrameRender(GraphicsDevice pDevice)
{
/*m_SBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);[/font]
[font=Verdana, sans-serif]    m_SBatch.Draw(m_BackgroundTex, new Microsoft.Xna.Framework.Rectangle(0, 0, m_BackgroundTex.Width,
m_BackgroundTex.Height), Microsoft.Xna.Framework.Graphics.Color.White);[/font]
[font=Verdana, sans-serif]    m_SBatch.End();*/[/font]
[font=Verdana, sans-serif]    Device.RenderState.DepthBufferEnable = true;
Device.RenderState.DepthBufferWriteEnable = true;
Device.RenderState.AlphaBlendEnable = false;[/font]
[font=Verdana, sans-serif]    // Configure effect
mSimpleEffect.World = this.mWorldMat;
mSimpleEffect.View = this.mViewMat;
mSimpleEffect.Projection = this.mProjectionMat;[/font]
[font=Verdana, sans-serif]    if (m_Tex != null)
{
mSimpleEffect.Texture = m_Tex;
mSimpleEffect.TextureEnabled = true;[/font]
[font=Verdana, sans-serif]	    //Disable lights in an attempt to render bodies...
//mSimpleEffect.EnableDefaultLighting();
}[/font]
[font=Verdana, sans-serif]    mSimpleEffect.CommitChanges();[/font]
[font=Verdana, sans-serif]    // Draw
mSimpleEffect.Begin();
mSimpleEffect.Techniques[0].Passes[0].Begin();[/font]
[font=Verdana, sans-serif]    if (m_NormVerticies != null)
{
{
if (m_CurrentMesh.IsBodyMesh)
{
//m_MatrixStack.Push(mSimpleEffect.World);
//mSimpleEffect.View = Matrix.Identity;[/font]
[font=Verdana, sans-serif]			    m_CurrentMesh.TransformVertices2(m_Skeleton);[/font]
[font=Verdana, sans-serif]			    //mSimpleEffect.View = m_MatrixStack.Pop();[/font]
[font=Verdana, sans-serif]			    m_CurrentMesh.BlendVertices2();
}[/font]
[font=Verdana, sans-serif]		    foreach (Face Fce in m_CurrentMesh.Faces)
{
VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
Vertex[0] = m_NormVerticies[Fce.AVertexIndex];
Vertex[1] = m_NormVerticies[Fce.BVertexIndex];
Vertex[2] = m_NormVerticies[Fce.CVertexIndex];[/font]
[font=Verdana, sans-serif]			    Vertex[0].TextureCoordinate = m_NormVerticies[Fce.AVertexIndex].TextureCoordinate;
Vertex[1].TextureCoordinate = m_NormVerticies[Fce.BVertexIndex].TextureCoordinate;
Vertex[2].TextureCoordinate = m_NormVerticies[Fce.CVertexIndex].TextureCoordinate;[/font]
[font=Verdana, sans-serif]			    pDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
Vertex, 0, 1);
}
}
}[/font]
[font=Verdana, sans-serif]    mSimpleEffect.Techniques[0].Passes[0].End();
mSimpleEffect.End();
}

PARTNERS