Author Topic: HOw to combine 3D objects to reduce draw-calls  (Read 987 times)

Offline tictac

  • Mc. Print
  • *
  • Posts: 21
    • View Profile
    • newLisp Italian blog!
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!
-Alessandro

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
You can either combine them with the modeling program. You can write such a combiner with the X_GETFACE commands.

Offline tictac

  • Mc. Print
  • *
  • Posts: 21
    • View Profile
    • newLisp Italian blog!
Thank you, but I need to combine objects at runtime.

Quote
You can write such a combiner with the X_GETFACE commands.

It means there is no built-in function to make this?
Ok, thank you!
-Alessandro

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1543
    • View Profile
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