0

I'm working on a 3D game and now I have to place every object in code. So is there a way to make a editor to place objects in Java OpenGL?

And is it best to make the whole world (it's kind of huge) one big mesh or is it better to do another way?

Christian Rau
  • 45,360
  • 10
  • 108
  • 185
AndroidXTr3meN
  • 399
  • 2
  • 9
  • 19

2 Answers2

3

So is there a way to make a editor to place objects in Java OpenGL?

There are no objects in OpenGL. Confused?

OpenGL just draws things, it's given some sort of "canvas" by the operating system and you can tell it to draw points, lines and triangles to your desire.

Anything related to a scene or managing objects is your burden, or that of an additional toolkit.

I'm working on a 3D game and now I have to place every object in code.

Think about it: Instead of hardcode your data, read it from a file and use the file's contents to build a scene, which is then drawn using OpenGL. This is not much unlike reading, say a text file and printing text to the user. Same principle, only different kind of data.

There are plenty of 3D modellers. An excellent, open source one is Blender. Export the model and/or scene to some file format you can read (either by implementing an existing one, or inventing your own one and write an exporter) and render it using your code.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
2

It is certainly possible to make a level editor in java and openGL but this is normally quite a large project all on its own.

Perhaps the simplest way to load your objects into the game is to make an XML file(or some other type of data file) that has the position, orientation, mesh, texture and any other data relevant to objects in your game world and edit it manually though this could be tedious if you have lots of objects to place. This can then be read at run time and your scene will be able to render these object. Later on this file format can be used by a level editor should you choose to make one.

As for the 2nd part of your question it depends. Rarely however is it a good idea to make the whole world one mesh. If your world is made up of many meshes culling becomes easier because you can just drop whole objects from your render calls rather than culling individual vertices.

Brendan
  • 161
  • 1
  • 6