Model import produces strange results

Started by zed, May 08, 2008, 06:31:05 PM

Previous topic - Next topic

zed

Hey there!

I'm new to jPCT and just trying to get into the basics. Therefore I just tried to adapt the Hello-World example, that comes with the API, so that it loads and shows an external model instead of the box, usually displayed. I got myself a high poly model of an elephant (which can be found here: http://graphics.im.ntu.edu.tw/~robin/courses/cg03/model/) and imported it using the following code:

char c=File.separatorChar;
Object3D [] buffer = Loader.loadOBJ("models" + c + "elepham.obj", null, 0.05f);
elephant = buffer[0];

elephant.calcNormals();
elephant.rotateX((float)Math.PI);

world.addObject(elephant);


So far, so good. Everything compiles well and I can run the example, but the output is totally weird, as you might see in the image. What's wrong here? Is it possible, that the normals get screwed up somewhere? I have to use Software-Rendering, could this be the reason? I'm really stuck here, so I appreciate every kind of advice! Thanks!

zed



EgonOlsen

Maybe the model's vertices have mixed orientations (some clock wise, some counter clock wise). jPCT relies on a model using one orientation to do the culling. You may try to disable culling (http://www.jpct.net/doc/com/threed/jpct/Object3D.html#setCulling(boolean)) and see if that helps. However, even if it does, it hurts performance.
Another question is, if the model is really defined in one part, i.e. if buffer.length is really 1.

raft

i'm somewhat familiar with that appearance. check Config.maxPolysVisible ;)

JavaMan

I see you calculated the normals, but did you call build on the object?

Jman

paulscode

Like raft said, this really looks like you have run out of visible polys.  Check Java output to see if it says anything about that.  See if adding the line:

Config.maxPolysVisible = 60000;   // or some large number

Before creating the world.

zed

Hey guys. Sorry for not replying for a while, but I've been busy elsewhere. Thanks for your advice, it indeed was Config.maxPolysVisible that solved my problems.

@Kearnan: Are there any special reasons, why you prefer 3ds over obj? What tools do you use to convert them?

Greetz!

zed

EgonOlsen

#6
Quote from: Kearnan on May 15, 2008, 05:40:01 AM
I'd trust JPCT knows more about 3DS than OBJ.
Yes, that's true. The 3DS-format (as far as jPCT supports it) has only one flaw with polygon colors, where the format can either be float or int and while the specs tell you how to detect that, this doesn't work for every model...which is why jPCT makes a guess at this point. Most of the time, this works fine. If it doesn't, you can disable it in Config... ;)
About OBJ: It's a strange format IMHO, because it supports object groups and such, but within a group, you can reference vertices from outside this group but only if they were defined ealier in the file. This makes parts of a group, which should be local IMHO, kind of global. I find this completely unintuitive. There are some other quirks with material definitions that belong to a group (so you expect them to be used in that group) but can be accessed from anyway later in the file. So it all comes down to one problem: A group in OBJ looks like a group but doesn't really act as one. That's what i dislike about it and what made it hard to make the loader work.

Edit: Some more references here:

http://www.jpct.net/forum2/index.php/topic,990.0.html
http://www.jpct.net/forum2/index.php/topic,923.0.html