i have a mesh with two faces
the top face and the front face
and all the other faces are culled so as to reduce the mesh load, as the other faces are unwanted,
but when i am using static triangle group for it (as it my level making entity(basically platform for my level))
The collision is happening between the mesh(the cube) and the entity but the character(box entity) is unable to stand over the mesh and is falling through the mesh.
The code below is my level editor class ,
where the constructor is taking the world matrix the model name and the instance of the main game class to draw the platform with Statictrianglegroup.
Code: Select all
class leveleditor:DrawableGameComponent
{
Matrix worldmatrix;
Game1 chetangame;
public Model ground;
StaticTriangleGroup.StaticTriangleGroupVertex[] vertices;
SceneObject sceneobj;
int[] indices;
TriangleMesh triangleMesh;
public StaticTriangleGroup triangleGroup;
SpriteBatch spriteBatch
{
get;
set;
}
public leveleditor(Matrix world,Game1 game,String name):base(game)
{
worldmatrix = world;
chetangame = game;
ground = chetangame.Content.Load<Model>(name);
sceneobj = new SceneObject(ground);
sceneobj.ObjectType = ObjectType.Dynamic;
sceneobj.Visibility = ObjectVisibility.RenderedAndCastShadows;
sceneobj.World = worldmatrix;
chetangame.sceneInterface.ObjectManager.Submit(sceneobj);
spriteBatch = new SpriteBatch(chetangame.GraphicsDevice);
StaticTriangleGroup.GetVerticesAndIndicesFromModel(ground, out vertices, out indices);
triangleMesh = new TriangleMesh(vertices, indices,4.5f);
triangleGroup = new StaticTriangleGroup(triangleMesh);
triangleGroup.WorldMatrix = worldmatrix;
// ter = new Terrain(worldmatrix.Translation);
}
public override void Draw(GameTime gametime)
{
// Render the scene.
// Add custom rendering that should occur before the scene is rendered.
Matrix Transform;
Matrix[] boneTransforms;
Transform = worldmatrix;
foreach (ModelMesh modelMesh in ground.Meshes)
{
boneTransforms = new Matrix[ground.Bones.Count];
ground.CopyAbsoluteBoneTransformsTo(boneTransforms);
foreach (BasicEffect effect in modelMesh.Effects)
{
effect.World = boneTransforms[modelMesh.ParentBone.Index] * Transform;
//effect.LightingEnabled = true;
//effect.SpecularColor = new Vector3(0, 0, 0);
//effect.PreferPerPixelLighting = true;
//effect.SpecularPower = 1.0f;
//effect.AmbientLightColor = new Vector3(1, 0, 1);
//effect.DiffuseColor = new Vector3(0, 1.5f, 1);
//effect.EnableDefaultLighting();
//effect.EmissiveColor = new Vector3(0, 1, 1);
effect.View = chetangame.camera.ViewMatrix;
effect.Projection = chetangame.camera.ProjectionMatrix;
}
modelMesh.Draw();
}
}
}