Skip to main content
Link added
Source Link
Shashwat
  • 387
  • 3
  • 12

You have different WVP matrices for each object. But you can create a single BasicEffect instance to render all the objects. You just have to make sure that before rendering, you assign the correct matrices to the BasicEffect properties.

for every object
{
    basicEffect.World = obj[i].world;
    basicEffect.View = obj[i].view;
    basicEffect.Projection = obj[i].projection;
    GraphicsDevice.SetVertexBuffer(obj[i].vertexBuffer);
    foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
    {
        pass.Apply();
        GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
    }
}

Check this

You have different WVP matrices for each object. But you can create a single BasicEffect instance to render all the objects. You just have to make sure that before rendering, you assign the correct matrices to the BasicEffect properties.

for every object
{
    basicEffect.World = obj[i].world;
    basicEffect.View = obj[i].view;
    basicEffect.Projection = obj[i].projection;
    GraphicsDevice.SetVertexBuffer(obj[i].vertexBuffer);
    foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
    {
        pass.Apply();
        GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
    }
}

You have different WVP matrices for each object. But you can create a single BasicEffect instance to render all the objects. You just have to make sure that before rendering, you assign the correct matrices to the BasicEffect properties.

for every object
{
    basicEffect.World = obj[i].world;
    basicEffect.View = obj[i].view;
    basicEffect.Projection = obj[i].projection;
    GraphicsDevice.SetVertexBuffer(obj[i].vertexBuffer);
    foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
    {
        pass.Apply();
        GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
    }
}

Check this

Source Link
Shashwat
  • 387
  • 3
  • 12

You have different WVP matrices for each object. But you can create a single BasicEffect instance to render all the objects. You just have to make sure that before rendering, you assign the correct matrices to the BasicEffect properties.

for every object
{
    basicEffect.World = obj[i].world;
    basicEffect.View = obj[i].view;
    basicEffect.Projection = obj[i].projection;
    GraphicsDevice.SetVertexBuffer(obj[i].vertexBuffer);
    foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
    {
        pass.Apply();
        GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
    }
}