If I override the Render function of a brumeObject
to draw a lot of object(like for a particles emitter), I can't use a different texture or color for each object drawn : the first texture and color set will be used.
Is it a feature ?
Moderator: Brume Dev Team
public override void Render()
{
BrumeMatrix world = this.WorldTransformation;
...
...
...
for (int i = 0; i < this.Particles.Length; i++)
{
local.M41 = this.Particles[i].Position.X;
local.M42 = this.Particles[i].Position.Y;
local.M43 = this.Particles[i].Position.Z;
brume.GraphicApi.SetWorld(local * newWorld);
this.Mesh.Render();
}
}
private void TestPhysicsStack()
{
// reuse sphere meshes
BrumeMesh reuseMesh = null;
BrumeBoundingSphere reuseBounding = null;
float stackX = -15.0f;
float stackY = 5.5f;
float stackZ = 10.0f;
// cubes & spheres
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 25; j++)
{
if (reuseMesh == null)
{
// first sphere is generated as always
BrumeSphereTextured sph = new BrumeSphereTextured(this, "sphere");
sph.RenderStates.Texture[0] = this.GetTexture("multitex1.tga");
sph.Pos = new BrumeVector(stackX + i, stackY + j, stackZ);
sph.HasPhysicsAndCollisions = true;
// we save the mesh and bounding info
reuseMesh = sph.Mesh;
reuseBounding = sph.BoundingSphere;
}
else
{
// optimisation : reuse of mesh and bounding info
BrumeLightedObject sph = new BrumeLightedObject(this, "sphere");
sph.Mesh = reuseMesh;
sph.RenderStates.Texture[0] = this.GetTexture("multitex1.tga");
sph.Pos = new BrumeVector(stackX + i, stackY + j, stackZ);
sph.AddBoundingSphere(new BrumeBoundingSphere(reuseBounding.Center, reuseBounding.Radius));
sph.HasPhysicsAndCollisions = true;
}
}
}
}
brume.GraphicApi.SetTexture(0,brume.GetTexture("multitex2.tga"));
for (int i = 0; i < ((BrumeComplexMesh)mesh).GetGeometries()[0].meshTextures.Length; i++)
{
RTSEngineForm.Engine.GraphicApi.SetTexture(0, ((BrumeComplexMesh)mesh).GetGeometries()[0].meshTextures[i]);
foreach (BrumeMeshGeometry geometry in ((BrumeComplexMesh)mesh).GetGeometries())
{
geometry.DrawSubSet(i);
}
}
Users browsing this forum: No registered users and 0 guests