Dear guys
I m trying to display a simple 3d triangle using simple vertex color using:
Node* node = m_scene->CreateChild("SimpleTriangle");
Model* model = new Model(context_);
StaticModel* staticModel = node->CreateComponent<StaticModel>();
model->SetNumGeometries( 1 );
//Urho3D::BoundingBox bb;
Urho3D::SharedPtr<Urho3D::Geometry> newGeometry(new Urho3D::Geometry(context_));
Urho3D::Vector<float> vertexData;
Urho3D::Vector<unsigned short> indexData;
vertexData.Push(0); vertexData.Push(0); vertexData.Push(0); vertexData.Push(Color::RED.ToUInt());
vertexData.Push(0); vertexData.Push(100); vertexData.Push(0); vertexData.Push(Color::RED.ToUInt());
vertexData.Push(100); vertexData.Push(0); vertexData.Push(0); vertexData.Push(Color::RED.ToUInt());
indexData.Push(0); indexData.Push(1); indexData.Push(2);
Urho3D::SharedPtr<Urho3D::VertexBuffer> vertexBuffer(new Urho3D::VertexBuffer(context_));
vertexBuffer->SetShadowed(true);
vertexBuffer->SetSize( 3, Urho3D::MASK_POSITION|Urho3D::MASK_COLOR);
vertexBuffer->SetData(&vertexData[0]);
// create index buffer
Urho3D::SharedPtr<Urho3D::IndexBuffer> indexBuffer(new Urho3D::IndexBuffer(context_));
indexBuffer->SetShadowed(true);
indexBuffer->SetSize(indexData.Size(), false );
indexBuffer->SetData(&indexData[0]);
// add buffers to geometry
newGeometry->SetVertexBuffer(0, vertexBuffer); // , vertexDecl
newGeometry->SetIndexBuffer(indexBuffer);
newGeometry->SetDrawRange(Urho3D::TRIANGLE_LIST, 0, indexData.Size());
model->SetGeometry(0, 0, newGeometry);
model->SetNumGeometryLodLevels(0,1);
staticModel->SetModel(model);
but the triangle is all dark/black/brown.
I have tried:
- to add vertex normals
- to manually create a material and to set it : material->SetTechnique(0, cache->GetResource(“Techniques/NoTextureNormal.xml”) );
- to add a global scene light
Would anyone know how to simply display a colorful triangle using vertex colors in the vertex buffer ?
Cheers
Thanks
S.