Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  Help the Noob Load an obj =)  (Read 1871 times)
0 Members and 1 Guest are viewing this topic.
Offline Morlem

Junior Newbie




Java games rock!


« Posted 2003-12-01 00:16:12 »

Hi!
I'm making a simple scene to navigate for a class and was wondering if anyone could help me load an obj I exported from Wings3d of Trogdor from Strongbad's emails.  Any quick hints on how to color or texture him would be appreciated too, but that's not really integral for what I wanna do.  I read the tut on loading ase files, but being a poor college student I can't afford the likes of 3dsmax.  Tongue

thanks!
 -Morlem

-edit-  I'm asking b/c the site mentions a loader for objs, which I thought would let me avoid porting a class that I made thatreads in all the vertices and then makes the faces listed in the obj file.  
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2003-12-01 01:23:19 »

A good start would be to download the third party loader if you havn't already from the Xith toolkit site:
https://xith-tk.dev.java.net/servlets/ProjectDocumentList?folderID=390

Have a play with that and see what you come up with.

Cheers,

Will.

Offline Morlem

Junior Newbie




Java games rock!


« Reply #2 - Posted 2003-12-03 03:43:57 »

Hey! thanks.  that was really helpful.  But just to further prove that I really don't know what Im doing, here is another problem I can't figure out.

I'm tring to compile and execute the OBJTest.java which is the example that was provided with the code, but everytime I get this message:
1  
Loading: othermodels/tiletest/tile1.obj

then:
1  
2  
java.lang.NullPointerException
        at java.io.Reader.<init>(Reader.java:61)... etc...

Which I'm thinking is approptiate b.c there is no tile1.obj, or that folder .  deleted the class file a couple times to make sure it was actiually compiling...

I couldn't figure that out so I tried making a completely new folder and everything with the files there too, and now I've run into a new problem.  I either get the NullPointerException or a String out of bound exception and i think I know why, but I don't know what to do about it.
Here's some code from the OBJLoader
1  
2  
3  
    public BranchGroup load(String objFile,NodeFactory factory,Vector3f vec) throws IOException {
        System.out.println("Loading: "+objFile);
        String basePath = objFile.substring(0,objFile.lastIndexOf("/"));

given that it sets the basepath to everything preceding a / does that mean it would only work on a Unix type file system since Windows uses \ instead of / ??  I'm getting the String out of Bounds exception b.c I took out the /'s so it never found one OR I'm getting the null pointer exception b.c I am including \'s to show where my directory is and it's never finding the file b.c this is Windows.  That's my current theory anyway.  Could I just extract that line from the jar, change the line, recompile and stick it back in??  Thanks again for tolerating my inexperience!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 171
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2003-12-03 04:59:17 »

I wrote the OBJ loader, so I know it runs on Windows.  Grin

The problem is that the String passed in should a reference in the class path and not a reference to a file path. Hence "/" is right all platforms since its a URL Smiley

However, I'm starting to think that I need to support loading from direct file since I've had a bunch of reports of problems with this same issue. I'll try and add it (to all the loaders) tonight. However, I do think its odd that people are loading from files and not from the classpath. It'll make life hard when you come to deployment.

Kev

Offline Morlem

Junior Newbie




Java games rock!


« Reply #4 - Posted 2003-12-03 11:26:19 »

Ahhhhh!! thanks!  I think I would've been ok If I knew enough to realize it was loading from the classpath.  I just assumed it loaded from a file, b/c I've never loaded a file from the classpath before. Live and learn!  Grin
Thanks again,
 for the loader and helping me figure out how to use it!
   -Morlem
Offline kevglass

JGO Kernel


Medals: 171
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2003-12-03 15:12:01 »

Added direct file support to OBJ and 3DS loaders. Not tested yet but its available at the same place..

I'll produce the Java Doc for the whole lot pretty soon. Just as soon as I get a spare day or so Smiley

Kev

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2003-12-03 21:50:21 »

Quote

Hey! thanks.  that was really helpful.


No probs - I think I shall start plugging those links a bit more Smiley

Quote

However, I do think its odd that people are loading from files and not from the classpath. It'll make life hard when you come to deployment.


Support for both is definitally a good idea IMHO.  I use regular paths myself if I am just testing something out.  Only if it becomes serious do I switch and whip up an ant script.

Will.

Offline Morlem

Junior Newbie




Java games rock!


« Reply #7 - Posted 2003-12-03 22:51:38 »

Sorry to be a nuisance, but I really don't think I've emphasised just how inexperienced I really am.  I got the OBJ loader to work on the galleon example, but I've yet to be able to load one of my own.  I've tried a few things, but I'll not go into that and just ask..  How do I get my obj onto the classpath?
 thanks yet again,
   -Morlem
Offline kevglass

JGO Kernel


Medals: 171
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #8 - Posted 2003-12-04 05:11:55 »

No worries,

Each directory or jar specified in your class path is taken as "base path". Any model you specify should be relative to one of these base paths. So, if you class path was

".;models;build"

And you referenced a model at "people/bob.obj" then the following locations would be checked:

./people/bob.obj
models/people/bob.obj
build/people/bob.obj

In that order. Now, the nice bit is when you work with classpaths that you can equally stick a jar file in your class path. Java will then try to access resources in the jar. This means you can distribute all your models/resources/etc in a compressed jar file with no extra work Smiley

If you start this way it stops you having to make a bunch of changes at deployment and its actually just as easy to work from the classpath as it is to work from direct files.

However, like I said, I've added file support to the loader now (and the 3DS loader). I don't really think this is the way to go but if you're still stuck then you could try that instead. If you are still stuck tho, feel free to come back and post again.

Kev

Offline Morlem

Junior Newbie




Java games rock!


« Reply #9 - Posted 2003-12-05 02:30:51 »

Hey!  I think I figured out the problem. When I copy your obj into one of my own it works fine, but it doesn't work on mine.   What program was your obj generated with?  Wings seems to output with a different structure, it the same basic syntax.  Maybe I can just load my obj into whatever program you used and then export a new Obj.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 171
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #10 - Posted 2003-12-05 05:03:14 »

I've been using Art of Illusion mostly. If its ok could you send your OBJ over.. I'd like to find out whats wrong and fix it up..

Kev

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.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (40 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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

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

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!