Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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  
  ObjLoader  (Read 2034 times)
0 Members and 1 Guest are viewing this topic.
Offline williamsellick

Senior Newbie





« Posted 2006-01-09 14:58:20 »

Hi,

I am working on loading an OBJ file in Xith created by the Terragen application. I know a lot about how this is
achieved using Java3D and am trying to apply my knowledge to Xith.

In my Java3D layout the loader extracts the Shape3D object from the BranchGroup (created from the OBJ file)
I was wondering if this is possible from the xith loader. I realise I don't fully understand how the loader works
in either Java3D or Xith so I feel quite limited in what I am trying to achieve. Undecided

Could anyone please either explain how I can create a Shape3D object from an OBJ file or suggest a better way of
loading a Terragen OBJ file into Xith.

Thanks
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #1 - Posted 2006-01-09 18:34:30 »

I don't know if the OBJ created by Terragen is in a specific format, what I know is the Xith OBJ Loader returns in fact a BranchGroup containing different Shape3D (containing Geoms and Appearances) and the interesting fact is all about node factories. But you may take a look at the source code of the loader, it's really easy to understand.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline williamsellick

Senior Newbie





« Reply #2 - Posted 2006-01-09 22:19:31 »

Thanks for the reply.

I was wondering if you could expand on the BranchGroup returned by the OBJ Loader.

I've had a look at the source code but am still a bit unsure about what it contains.
When I ran a portion of my code intergrated with the ObjLoader, the BranchGroup
had one child node  (a Group object) could you explain how this relates to a
Shape3D object?


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #3 - Posted 2006-01-10 19:09:47 »

then the Group is probably a TransformGroup and that one contains your Shape3D

:: JOODE :: Xith3d :: OdeJava ::
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #4 - Posted 2006-01-11 14:13:18 »

arne, yes it's probably like that.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline williamsellick

Senior Newbie





« Reply #5 - Posted 2006-01-11 23:43:31 »

Thanks everyone for your advice. I think I am starting to understand how it all fits together.
It turned out to be the child node after the one above that was the Shape3D object so if any
one else is ever trying to load an OBJ file created by Terragen try
1  
2  
3  
        Node grandParentNode = objBranchGroup.getChild(0);
        Node parentNode = ((com.xith3d.scenegraph.Group) grandParentNode).getChild(0);
        Node node = ((com.xith3d.scenegraph.Group) parentNode).getChild(0);

and the 'node' object is the Shape3D

I have another query if anyone has any ideas.  I was wondering about the objloader and
the boundaries created in the Shape3D object. For instance when you load an OBJ file
using the loader how does it define what type of bounds are used within the Shape3D.

My question relates to what I am working on at present as after I have the Shape3D object
from the branchgroup I want to get the boundary values from it (hopefully by using a
BoundingBox) however the boundary object returned by the Shape3d is a BoundingSphere.
I'd like to change where this is set if possible and if not try to convert it.
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #6 - Posted 2006-01-12 14:12:47 »

I'm sorry I don't know that much about boundary-thingies in Xith3D, cause I don't use it (maybe it's used in the renderer, but anyway I don't mind about it).
But you may really easily compute the bounding box of your model based on your Geometry (that is contained in your Shape3D). I think you should do you own class for BoundingBox

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #7 - Posted 2006-01-12 14:57:01 »

Quote
I have another query if anyone has any ideas.  I was wondering about the objloader and
the boundaries created in the Shape3D object. For instance when you load an OBJ file
using the loader how does it define what type of bounds are used within the Shape3D.

I believe it uses BoundingSphere by default.

Is there any need, why you need BoundingBoxes? BoundingSpheres work also pretty well.

:: JOODE :: Xith3d :: OdeJava ::
Offline williamsellick

Senior Newbie





« Reply #8 - Posted 2006-01-19 23:03:23 »

Sorry it's taken me so long to reply. Been so busy at work.

I am trying to load a terrain map and as this is a cuboid type shape I thought the best bounding object would be
a BoundingBox. I'm trying to use the BoundingBox to get the landlength (length of the x side) and the max and min
height along the z axis.

There must be a way to get these values from the geometry but it escapes me  Huh Sorry for being such a noobie,
I'm trying to get better. Could anyone enlighten me on either how I could get these values from a BoundingSphere
or the Geometry.
Offline hawkwind

Junior Member




Java games rock!


« Reply #9 - Posted 2006-01-20 00:33:52 »

Dang

   Hate to say it but I think when I hit this I had to iterate over the vertex values storing min and max info...sorry
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline otelo

Junior Member





« Reply #10 - Posted 2006-02-04 11:08:04 »

Dang

   Hate to say it but I think when I hit this I had to iterate over the vertex values storing min and max info...sorry

Exactly, it's very easy. take your Shape3D, use getGeometry() to extract the geometry from it and iterate throug all of it's vertices with getVertex(int i, Point3f)  I think.

I'm also using .obj models with Xith, and the immaturity of it's .obj loaders actually forced me to write my own to get the functionality I needed. It's really very easy to do so, once you understand the few tags that are used there. It's llike parsing HTML files but even more straightforward. Smiley
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #11 - Posted 2006-02-04 14:01:37 »

otelo, if you have improved the OBJ loader, you may post your code here, and I'll commit it to the Xith-tk. Or even better, you can do it yourself  Grin just register at https://xith-tk.dev.java.net/
William will probably give you Developer access soon and then you can commit your changes.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline otelo

Junior Member





« Reply #12 - Posted 2006-02-04 14:24:18 »

I didn't really improve it, I just wrote my own .obj file parser to get the functionality I needed, it sure is nothing groundbreaking.

I'd like to encourage other people to do the same, having full control and understanding of the loading process is a great thing and dealing with the .obj format is just too simple to pass on the opportunity.
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36

Riven (45 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
Resources for WIP games
by CogWheelz
2014-08-01 18:19:50

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

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37
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!