GLBasic forum

Main forum => GLBasic - en => Topic started by: tictac on 2011-Feb-16

Title: HOw to combine 3D objects to reduce draw-calls
Post by: tictac on 2011-Feb-16
Hello,

I need to create a lot of basic objects at runtime, in 3D, so I need to "group" (combine) objects to reduce the draw-calls.
Is there any native function in GLBasic to do that? Or is there someone who was able to create such function?

Thank you for help!
Title: Re: HOw to combine 3D objects to reduce draw-calls
Post by: Kitty Hello on 2011-Feb-17
You can either combine them with the modeling program. You can write such a combiner with the X_GETFACE commands.
Title: Re: HOw to combine 3D objects to reduce draw-calls
Post by: tictac on 2011-Feb-17
Thank you, but I need to combine objects at runtime.

QuoteYou can write such a combiner with the X_GETFACE commands.

It means there is no built-in function to make this?
Ok, thank you!
Title: Re: HOw to combine 3D objects to reduce draw-calls
Post by: matchy on 2011-Feb-17
There's no real way of grouping vertex or poly objects but you can merge the creation process by calling X_OBJSTART only once for the new object id, and then add parts to it.

For example, for a kitchen table model (psuedo) from five part to one like Ikea;

open a new vertex object for a table, no merge
merge the table top vertex object, with merge
merge the four legs vertex object, with merge
close the table vertex object
:rtfm:
Code (glbasic) Select

FUNCTION make_object: obj AS vertex_object, object_merge
IF object_merge THEN X_OBJSTART obj.num
X_OBJADDVERTEX ...
...
X_OBJNEWGROUP
IF object_merge THEN X_OBJEND
ENDFUNCTION