Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JOGL - Loading a 3d model(request)  (Read 10232 times)
0 Members and 1 Guest are viewing this topic.
Offline Tainted

Junior Newbie

« Posted 2012-08-08 08:35:43 »

If, someone could post a very simple code how to load a 3d models into my code with JOGL.


P.s. No custom libraries just JOGL
Offline Danny02
« Reply #1 - Posted 2012-08-08 09:57:23 »

sry but nobody can just post simple code for that^^

When you want to display model on the screen you must go through some steps, which are not really hard, but some work.

First you need a model file which is in a specific format, you want to use a format which is widly used and supported so you can use common tools to create your models. Most you because of this the OBJ format at first, because it is really easy to parse yourself and is very basic and nearly every tool supports it.

After that you will have some model data in your memory which needs to be converted to some data which can be used with OpenGL.
When you ave this you finally have to choose how to render it, i.e. glBegin or Buffer Objects and how to you handle materials(textures, properties like shininess).

I started out myself parsing OBJ and now finished(btw Smiley) a lib to read the OpenCTM format, take a look how I did it DarwinsBox: geometrie/io
Offline Giovanni

Junior Devvie


« Reply #2 - Posted 2012-08-08 18:19:00 »

The user "TheCodingUniverse" has created an object loader for .obj models. You can check out the source code here:
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Tainted

Junior Newbie

« Reply #3 - Posted 2012-08-08 19:12:59 »

Thanks, now I'm on track!
Offline ags1

JGO Kernel

Medals: 120
Projects: 4
Exp: 5 years

Make code not war!

« Reply #4 - Posted 2012-08-08 21:16:14 »


What is a model when it is loaded anyway? What is an animation when it is loaded?

Are we just talking about a bunch of verteces and attributes. In the case of an animation, a sequence of sets of verteces and attributes?

Offline gouessej
« Reply #5 - Posted 2012-08-10 16:44:36 »


Please could you be more precise? JOGL-utils is not very big and supports several model formats. I wrote an MD3 loader using JOGL several years ago.

Offline ags1

JGO Kernel

Medals: 120
Projects: 4
Exp: 5 years

Make code not war!

« Reply #6 - Posted 2012-08-10 19:28:19 »

I have an idea of what would go in a model file, and I know that OpenGL treats everything as verteces, so all I'm really asking is what sort of logic underlies the translation between the model file and the vertex array in OpenGL. How do animations work? How is the process optimised?

Offline gouessej
« Reply #7 - Posted 2012-08-10 21:33:29 »

It depends on several aspects. There are models with hierarchies and models without any hierarchy. The former can contain "sub models" whereas the latter can't. Each sub model contains some data (vertices, indices, textures coordinates, ...) that you can store into vertex arrays or VBOs.

On the other hand, your animations can be skeletal or key frame based. For the former, the real geometry is computed by using the bones. For the latter, when you play an animation, you display a model corresponding to a given frame, obviously you can interpolate two predefined models corresponding to the closest key frames to get a smoother result.

There are tons of ways to optimize animations or even the meshes (make a quick search with the keywords "mesh optimization").

The user "TheCodingUniverse" has created an object loader for .obj models. You can check out the source code here:
You don't answer his question, he's looking for an example using JOGL and yours only supports a very limited subset of the WaveFront OBJ format, it doesn't even handle texture coordinates.

There is a 3DS loader here, in JOGL-utils:

There is an OBJ loader here (using JOGL 1.1.1 unfortunately):

Offline ags1

JGO Kernel

Medals: 120
Projects: 4
Exp: 5 years

Make code not war!

« Reply #8 - Posted 2012-08-10 21:44:46 »

Thanks gouessej, it gives me something to think about. Sorry for the thread hijack.

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Jesse (11 views)
2015-07-29 04:35:27

Riven (33 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (28 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (26 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!