alberts
03-12-2005 17:56:05
Hi!
I'm trying to create a simple triangle with the MeshBuilderHelper class, but i can't. I donĀ“t know what is the problem.
Here is the code:
The program runs, but I can't see the triangle. What's wrong?
Thanks a lot!!!
I'm trying to create a simple triangle with the MeshBuilderHelper class, but i can't. I donĀ“t know what is the problem.
Here is the code:
class ManualMesh : ExampleApplication
{
protected override void CreateScene()
{
createTriangle("myTriangle");
Entity ent1 = mSceneManager.CreateEntity("1", "myTriangle");
SceneNode node1 = mSceneManager.GetRootSceneNode().CreateChildSceneNode("TriangleNode");
node1.AttachObject(ent1);
}
void createTriangle(string name)
{
OgreDotNet.MeshBuilderHelper mbh = new MeshBuilderHelper(
name,"General", false, 0, 3 );
UInt32 offPos = mbh.addElement( VertexElementType.VET_FLOAT3 , VertexElementSemantic.VES_POSITION ).getOffset();
UInt32 offDiff = mbh.addElement( VertexElementType.VET_FLOAT3 , VertexElementSemantic.VES_DIFFUSE ).getOffset();
mbh.createVertexBuffer ( 3 , HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY );
mbh.setVertFloat( 0, offPos, 0, 0, 0 ); //position
mbh.setVertFloat( 0, offDiff, 0, 1, 0 ); //color
mbh.setVertFloat( 1, offPos, 0, 1,0 ); //position
mbh.setVertFloat( 1, offDiff, 0, 0, 1 ); //color
mbh.setVertFloat( 2, offPos, 1, 0, 0 ); //position
mbh.setVertFloat( 2, offDiff, 1, 0, 0 ); //color
mbh.createIndexBuffer ( 1, HardwareIndexBuffer.IndexType.IT_16BIT, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
mbh.setIndex16bit( 0, (UInt16)0, (UInt16)2, (UInt16)1 );
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
using(ManualMesh app = new ManualMesh() )
{
app.Start();
}
}
}
The program runs, but I can't see the triangle. What's wrong?
Thanks a lot!!!