Hi,
i have a large amount of vertices to render and want to explore the best way of rendering them. (Around 4 million points). The amount of data is growing in each frame so i add a new Component each frame. I looked up the DynamicGeometry Example but this does not work in my case.
CustomGeometry* localcloud = cloudnode->CreateComponent<CustomGeometry>();
localcloud->SetMaterial(cloudmat);
localcloud->BeginGeometry(0, POINT_LIST);
for (int i = 0; i < vertexValues.size(); i++) {
localcloud->DefineVertex(Vector3(vertexValues[i].position[0],
vertexValues[i].position[1],
-vertexValues[i].position[2]));
localcloud->DefineNormal(Vector3(vertexValues[i].normal[0],
vertexValues[i].normal[1],
-vertexValues[i].normal[2]));
localcloud->DefineColor(Color(vertexValues[i].color[0],
vertexValues[i].color[1],
vertexValues[i].color[2]));
}
localcloud->Commit();
The problem i have is that adding the vertices this way is a large overhead. My vertexValues are already in structure which is easy to bind through a normal vbo in opengl. I want to do this as well in Urho3D, so i tryed the VertexElements stuff. In my scene creation i initialize
model = new Model(context_);
vertexBuffer = new VertexBuffer(context_);
geometry = new Geometry(context_);
elements.Push(VertexElement(TYPE_VECTOR3, SEM_POSITION));
elements.Push(VertexElement(TYPE_VECTOR3, SEM_NORMAL));
elements.Push(VertexElement(TYPE_VECTOR3, SEM_COLOR));
Node* node = scene_->CreateChild("container");
auto* object = node->CreateComponent<StaticModel>();
object->SetModel(model);
object->SetMaterial(cloudmat);
Then i wanted to fill the vertexbuffer with only the actual data in each frame so i added to my frame update
vertexBuffer->SetSize(vertexValues.size(), elements, true);
vertexBuffer->SetData(vertexValues.data());
geometry->SetVertexBuffer(0, vertexBuffer);
geometry->SetDrawRange(POINT_LIST, 0, 0, 0, vertexValues.size());
model->SetNumGeometries(1);
model->SetGeometry(0,0,geometry);
I read out the vertexBuffer and saw that it’s size is allocated correctly, but in the result i don’t see anything rendered. I also don’t get any error message.