Shanira
25-08-2006 22:05:57
Just can't seem to get it to work, especially since everything seems to work very different in ODN than it does in regular Ogre when it comes to this. Can anyone tell me where I'm going wrong?
Compiles fine, runs fine, just don't see anything.

Compiles fine, runs fine, just don't see anything.
using System;
using System.Drawing;
using OgreDotNet;
using Math3D;
namespace TutorialApplication1
{
class TutorialApplication : ExampleApplication
{
protected override void CreateScene()
{
HeightPlane mHP = new HeightPlane();
MeshManager.GetSingleton().CreateManual("test", "General", mHP);
Entity ent1;
ent1 = mSceneManager.CreateEntity("squaretest","test");
ent1.SetCastShadows(true);
mSceneManager.GetRootSceneNode().CreateChildSceneNode().AttachObject(ent1);
}
protected override void CreateCamera()
{
// create the camera
mCamera = mSceneManager.CreateCamera("PlayerCam");
// set its position, direction
mCamera.SetPosition(new Vector3(256, 100, 256));
mCamera.LookAt = new Vector3(0, 0, 0);
mCamera.SetNearClipDistance(5.0f);
}
[STAThread]
static void Main(string[] args)
{
using(TutorialApplication app = new TutorialApplication())
{
app.Start();
}
}
}
class HeightPlane : ManualResourceLoaderDirector
{
public HeightPlane() : base()
{
}
public override void loadResource (Resource resource)
{
Mesh hp = (Mesh)resource;
/*hp.SharedVertexData = new VertexData();
VertexData vdata = hp.SharedVertexData;
VertexDeclaration vdec = vdata.vertexDeclaration;
uint currOffset = 0;
VertexDeclaration.addElement(0, currOffset, Vet_Float3, Ves_Position);*/
// args are "name, group, usesharedvertices, vertexstart, vertexcount"
MeshBuilderHelper mbh = new MeshBuilderHelper("Rar", "General", false, 0, 4);
UInt32 offPos = mbh.addElement( VertexElementType.VET_FLOAT3 , VertexElementSemantic.VES_POSITION ).getOffset();
UInt32 offNorm = mbh.addElement( VertexElementType.VET_FLOAT3 , VertexElementSemantic.VES_NORMAL ).getOffset();
UInt32 offUV = mbh.addElement( VertexElementType.VET_FLOAT2 , VertexElementSemantic.VES_TEXTURE_COORDINATES ).getOffset();
mbh.createVertexBuffer (4 , HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
mbh.setVertFloat(0, offPos, -10, 0, -10);
mbh.setVertFloat(0, offNorm, 0, 1, 0);
mbh.setVertFloat(0, offUV, 0, 0);
mbh.setVertFloat(1, offPos, 10, 0, -10);
mbh.setVertFloat(1, offNorm, 0, 1, 0);
mbh.setVertFloat(1, offUV, 1, 0);
mbh.setVertFloat(2, offPos, -10, 0, 10);
mbh.setVertFloat(2, offNorm, 0, 1, 0);
mbh.setVertFloat(2, offUV, 0, 1);
mbh.setVertFloat(3, offPos, 10, 0, 10);
mbh.setVertFloat(3, offNorm, 0, 1, 0);
mbh.setVertFloat(3, offUV, 1, 1);
// trianglecount, hardwareindexbuffer:indextype itype, hardwarebuffer:usage usage[, useshadowbuffer]
mbh.createIndexBuffer(2, HardwareIndexBuffer.IndexType.IT_16BIT, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
mbh.setIndex16bit( 0, (UInt16)0, (UInt16)3, (UInt16)1 );
mbh.setIndex16bit( 1, (UInt16)0, (UInt16)2, (UInt16)3 );
MeshPtr mPtr = mbh.Load( "Examples/Rockwall" );
Mesh m = mPtr.Get();
m._setBounds( new AxisAlignedBox(-10.0f, 0.0f, -10.0f, 10.0f, 0.0f, 10.0f), false );
m._setBoundingSphereRadius( (float)Math.Sqrt(1.0f * 1.0f + 1.0f * 1.0f) );
resource = m;
resource.Load();
}
}
}