Jump to content

[SOLVED] Draw static lines


photo

Recommended Posts

Posted

Hello,

 

I want to draw many static lines in unigine, I found two methods: one to use fpf class, but it seems need to re-submit lines every frame, it cost too much. Two is use ObjectMesh, but it seems only can draw triangles. Is there is any other approchs to draw static lines effienctly? Please give some suggestions, thanks!

Posted

ObjectDynamic can be used for lines rendering.

The simple shader for rendering is required.

Check the objects/dynamic_05 sample.

Posted

I check the ObjectDynamic class, it can render lines, but only in script, in c++API I have not found such class, I also check the ObjectmeshDynamic class, but it hasn`t lines rendering interface. May be I could create new object class and re-Implement the render()  with help of Ffp class.

Posted

ObjectDynamic has absolutely same functionality inside c++ api.

Posted

Ok, I missed it, I only check the chm document and did not find, and found it in the includes folder, thanks.

Posted

I tried the ObjectDynamic but did not archived to show it, below is my code:

 

ObjectDynamciPtr obj = ObjectDynamic::create();

ObjectDynmaic::Attribute attrib;

attrib.offset = 0;

attrib.size = 3;

attrib.type = ObjectDynamic::TYPE_FLOAT;

obj->setVertexFormat(attrib,1);

obj->addVertexFloat(0, vec3(0.0,0.0,0.0).get(), 3);

obj->addVertexFloat(0, vec3(0.0,5.0,5.0).get(), 3);

obj->addVertexFloat(0, vec3(0.0,5.0,0.0).get(), 3);

obj->addIndex(0);

obj->addIndex(1);

obj->addIndex(2);

obj->setSurfaceMode(ObjectDynamic::MODE_TRIANGLES, 0);

obj->setMaterial("mesh_base", "*");

obj->setBoundBox(vec3(-10.0,-10.0,-10.0),vec3(10.0,10.0,10.0));

obj->flush();

 

No triangle was shown, where is the problem?

Posted

Solved, the material shader need to be bind to "dynamic" type.

×
×
  • Create New...