CactusJack
02-10-2010 20:03:07
Hey guys,
I've got the following problem: in my puzzle game I wish to draw a lot of cubes. I found out that there are 3 methods to do this: instanced geometry, static geometry, or simply draw them as individual entities.
Drawing them as individuals is not a good solution if there are more than 1k cubes.
Static geometry is OK for now, but later probably i will wish to move some cubes.
Instanced geometry maybe would be the best choice but I could not find any working sample on the web (neither for classic Ogre). I thought there are not so much difference between static and instanced geometries, but my code does not work.
The result is either seeing nothing or getting some mysterious access violations and other no-ogre exceptions. If I declare ig as StaticGeometry, everything is OK...
Please, help me with sharing some working code-snippets with instanced geometries.
Thanks in advance.
Jack
I've got the following problem: in my puzzle game I wish to draw a lot of cubes. I found out that there are 3 methods to do this: instanced geometry, static geometry, or simply draw them as individual entities.
Drawing them as individuals is not a good solution if there are more than 1k cubes.
Static geometry is OK for now, but later probably i will wish to move some cubes.
Instanced geometry maybe would be the best choice but I could not find any working sample on the web (neither for classic Ogre). I thought there are not so much difference between static and instanced geometries, but my code does not work.
string ID = Guid.NewGuid().ToString();
Entity Mesh = SceneMgr.CreateEntity("LvlElem" + ID, "ElemSimple.mesh");
Mesh.SetMaterialName("ElemSimple");
Mesh.CastShadows = false;
SceneMgr.DestroyInstancedGeometry("geom");
SceneMgr.DestroyStaticGeometry("geom");
InstancedGeometry ig = SceneMgr.CreateInstancedGeometry("geom");
//StaticGeometry ig = SceneMgr.CreateStaticGeometry("geom");
ig.AddEntity(Mesh, new Vector3(0, 20, 0));
ig.AddEntity(Mesh, new Vector3(0, 30, 0));
ig.AddEntity(Mesh, new Vector3(0, 40, 0));
ig.AddEntity(Mesh, new Vector3(0, 50, 0));
ig.Build();
The result is either seeing nothing or getting some mysterious access violations and other no-ogre exceptions. If I declare ig as StaticGeometry, everything is OK...
Please, help me with sharing some working code-snippets with instanced geometries.
Thanks in advance.
Jack