Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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 7497 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.

Thanks!

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 Duke




chop!


« 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:

https://github.com/OskarVeerhoek/YouTube-tutorials/blob/master/src/utility/OBJLoader.java
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 Wizard


Medals: 67
Projects: 3
Exp: 5 years


Make code not war!


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

MEMO FROM DUMB QUESTIONS DEPARTMENT:
==================================

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 »

Hi

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 Wizard


Medals: 67
Projects: 3
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:

https://github.com/OskarVeerhoek/YouTube-tutorials/blob/master/src/utility/OBJLoader.java
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:
https://github.com/sgothel/jogl-utils/tree/master/src/net/java/joglutils/ThreeDS

There is an OBJ loader here (using JOGL 1.1.1 unfortunately):
http://code.google.com/p/joglobj/

Offline ags1

JGO Wizard


Medals: 67
Projects: 3
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (38 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!