[2.1] Dynamic geometry - dynamic quantity of vertices

Problems building or running the engine, queries about how to use features etc.
Slicky
Bronze Sponsor
Posts: 592
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 19

[2.1] Dynamic geometry - dynamic quantity of vertices

I am trying to get to the point where I can have a changing amount of vertices. I have a feeling I will need to go through the initialisation each time I change the quantity. For now I am not changing the quantity of vertices and just trying to get it to work.

Questions:
(1) Do I need to reinitialise if I change the quantity of vertices originally declared?
(2) Would it work to initially declare an arbitrary number of vertices but just leave unused ones zeroed?
(3) Related to it not working yet - are the normals critical as far as seeing something rendered?

Slicky
Bronze Sponsor
Posts: 592
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 19

Re: [2.1] Dynamic geometry - dynamic quantity of vertices

OK I made some progress (after a fair amount of time hassling).

It looks like it works to declare an arbitrary number and just use them or not.
For normals I set all of them to 1 since I am doing lines. If I used a lower number like 0.57 they either didn't appear of flickered.

dark_sylinc
OGRE Team Member
Posts: 4451
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 909
Contact:

Re: [2.1] Dynamic geometry - dynamic quantity of vertices

Create your vertex & index buffers big enough to hold the maximum number of elements you expect them to contain (if you later need more, you'll need to recreate the buffers and the VertexArrayObject)

Once you've done that, use VertexArrayObject::setPrimitiveRange to limit how many vertices/indices you're actually using from the buffer.
Related to it not working yet - are the normals critical as far as seeing something rendered?
Yes. PBS requires normals, however Unlit does not.

Slicky
Bronze Sponsor
Posts: 592
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 19

Re: [2.1] Dynamic geometry - dynamic quantity of vertices

I'll have to check but I'm probably using PBS. So far I'm just drawing lines.

(1) Is there a particular value I should use for normals? I know it is often calculated.
(2) Maybe I should look into how to change to unlit.

dark_sylinc
OGRE Team Member
Posts: 4451
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 909
Contact:

Re: [2.1] Dynamic geometry - dynamic quantity of vertices

Slicky wrote:
Sun Oct 28, 2018 6:32 pm
(1) Is there a particular value I should use for normals? I know it is often calculated.
No. It has to be unit-length for proper PBR, but that's all.

For flat shading it's often calculated as (v0 - v1).crossProduct( (v0 - v2) );
Smooth shading tends to average the normals to make its smooth look, but there could be other algorithms.

For non-PBR scenarios, the value of the normal depends on what you're trying to achieve.

Slicky
Bronze Sponsor
Posts: 592
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 19

Re: [2.1] Dynamic geometry - dynamic quantity of vertices

I got unlit working it wasn't too much of a change. The PBS version had black lines probably no material and my bad normals.