I used the pretty much used the theoretically working code from here exactly: http://discourse.urho3d.io/t/solved-how-to-create-mesh/35 This post is a bit old so maybe things have changed a bit?
It simply doesn’t render correctly depending on the direction and position of the camera. It seems to fail whenever the camera is close or when the object almost falls off of the camera.
Here is it messing up
But when I back up a bit it works
float dirLightVertexData[] =
{
-1, 1, 0,
1, 1, 0,
1, -1, 0,
-1, -1, 0,
};
unsigned short dirLightIndexData[] =
{
0, 1, 2,
2, 3, 0,
};
SharedPtr<VertexBuffer> dlvb(new VertexBuffer(context_));
dlvb->SetShadowed(true);
dlvb->SetSize(4, MASK_POSITION);
dlvb->SetData(dirLightVertexData);
SharedPtr<IndexBuffer> dlib(new IndexBuffer(context_));
dlib->SetShadowed(true);
dlib->SetSize(6, false);
dlib->SetData(dirLightIndexData);
Geometry *dirLightGeometry_ = new Geometry(context_);
dirLightGeometry_->SetVertexBuffer(0, dlvb);
dirLightGeometry_->SetIndexBuffer(dlib);
dirLightGeometry_->SetDrawRange(TRIANGLE_LIST, 0, dlib->GetIndexCount());
SharedPtr<Model> testModel(new Model(context_));
Vector<SharedPtr<VertexBuffer> > dlvbVector;
Vector<SharedPtr<IndexBuffer> > dlibVector;
dlvbVector.Push(dlvb);
dlibVector.Push(dlib);
testModel->SetNumGeometries(1);
testModel->SetNumGeometryLodLevels(0, 1);
testModel->SetGeometry(0, 0, dirLightGeometry_);
// Define the model buffers and bounding box
PODVector<unsigned> emptyMorphRange;
testModel->SetVertexBuffers(dlvbVector, emptyMorphRange, emptyMorphRange);
testModel->SetIndexBuffers(dlibVector);
testModel->SetBoundingBox(BoundingBox(Vector3(-1.0f, -1.0f, 0.0f), Vector3(1.0f, 1.0f, 0.0f)));
Node* testnodea = scene_->CreateChild("testasdasd");
testnodea->SetScale(Vector3(1.0f, 1.0f, 1.0f));
StaticModel* testObjecta = testnodea->CreateComponent<StaticModel>();
testObjecta->SetModel(testModel);
testObjecta->SetMaterial(cache->GetResource<Material>("Materials/BlueUnlit.xml"));
testnodea->SetPosition(Vector3(-1.0f, 5.0f, 2.0f));
Any help is nice! Thanks!