bvagis
27-08-2010 16:11:16
I am creating a mesh of a terrain and trying to get shadows to appropriately show up on it. I have thus far had little success. My mesh is quite large, over 100,000 vertices. I am not sure If I am doing it correctly, because shadows do not seem to show up correctly, if at all.
I am first creating a ManualObject out of my pre-triangulated ground data, then converting it to a MeshPtr and setting the CastShadows attribute to true.
The mesh shows up fine, but the shadows do not show up correctly. Moving the camera around will cause the program to crash with an AccessViolation exception. Is there something wrong with my indexing? Is there something special that should be in my material? Maybe I just have too many points in my mesh?
Here is my material:
Any tips would be appreciated!
I am first creating a ManualObject out of my pre-triangulated ground data, then converting it to a MeshPtr and setting the CastShadows attribute to true.
int counter = 0;
foreach (var subTriangleArray in subTriangles)
{
name = subCloud.Name;
name = name.Replace("PointCloud_", "Mesh_" + (counter++) + "_");
manualObject = m_SceneManager.CreateManualObject(name);
manualObject.Begin("ReferenceData", RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
ushort j = 0;
foreach (Triangle triangle in subTriangleArray)
{
if (j + 3 > ushort.MaxValue)
{
break;
}
foreach (int vertex in triangle.vertecies)
{
ColorPosition cp = subCloud.ColorPositions[tPoints[vertex].nVertexID];
manualObject.Position(cp.Position);
manualObject.Colour(cp.Colour);
manualObject.Index(j++);
}
}
manualObject.End();
if (tPoints.Length < 3)
{
return;
}
MeshPtr mesh = manualObject.ConvertToMesh(name);
name = mesh.Name.Replace("Mesh_", "Entity_");
Entity entity = m_SceneManager.CreateEntity(name, mesh.Name);
entity.CastShadows = true;
m_Meshes.Add(name);
m_MeshNode.AttachObject(entity);
}
The mesh shows up fine, but the shadows do not show up correctly. Moving the camera around will cause the program to crash with an AccessViolation exception. Is there something wrong with my indexing? Is there something special that should be in my material? Maybe I just have too many points in my mesh?
Here is my material:
material ReferenceData
{
technique
{
pass
{
scene_blend alpha_blend
diffuse vertexcolour
specular vertexcolour
ambient vertexcolour
}
}
}
Any tips would be appreciated!