I want to render an object imported from wavefront obj file. The object has multiple groups and materials:
# group one
g one
v ...
vt ...
vn ...
# material A
usemtl ...
f ...
# material B
usemtl ...
f ..
# second group
g two
v ...
vt ...
vn ...
# material C
usemtl ...
f ...
# material D
usemtl ...
f ...
The different parts of the model need to be rendered separately, as they have different materials.
I will build a container with an information about the model and I would like to know what is the best/common way to organize the "queue" of the objects to render.
My idea, which I don't know if it's good is the following (with pseudocode): for each group g
store all vertex information in object VertexInformation g1, g2
and for each usemtl
store information about faces (and the used material) in FaceInformation f1, f2, f3, f4
.
Then the rendering would look as follows:
load vertices g1
render f1 f2
load vertices g2
render f3 f4
Or maybe better to load all the vertices from g1
and g2
at once?
Is that the way? Or it has some giant drawbacks?