0
\$\begingroup\$

I am making a 3D game in OpenGL from scratch. In this game I have a ship with stuff inside it. How can I attach the stuff to the ship in the CAD program and maintain that hierarchy in my own game?

For example say I have a fire extinguisher in my ship that mounts on the wall. There are two approaches both with problems.

Solution 1: Save fire extinguisher and ship as separate obj files.

Problem: How can I place the fire extinguisher in the proper place inside my ship in my game? With hundreds of objects manually placing them is completely infeasible. I want to arrange stuff in my CAD and load it into the game and be done.

Solution 2: Save fire extinguisher as its own group inside the ship obj file.

Problem: Now I can't reuse the fire extinguisher in other ships. The obj files for game assets will balloon out of control in size with new instances of reused sub-objects.

Is there some way I can specify the position of an external object? A 3d point in my ship obj file representing the origin of another obj model?

\$\endgroup\$
  • 1
    \$\begingroup\$ Use another file format that allows you to reference other objects instead of cloning them. I don't know any common ones used in game dev, unfortunately. I know OpenSceneGraphs (osg) and OpenFlight (flt) do it like that. \$\endgroup\$ – Vaillancourt Sep 13 '17 at 14:11
  • \$\begingroup\$ AlexandreVaillancourt I could easily design my own. Maybe if I specified an exact group naming convention and then wrote a program to scan obj files. But how can I convert object centric vertex coordinates to instance location vertex coordinates? \$\endgroup\$ – Alex Sep 13 '17 at 14:48
  • \$\begingroup\$ "Use another file format that allows you to reference other objects..." That is the perfect answer. The details depend on what you want to/ can use. \$\endgroup\$ – Trilarion Sep 15 '17 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.