3ds model texture behavior

Started by Nick, December 15, 2010, 11:05:22 PM

Previous topic - Next topic

Nick

Hello,

I'm having difficulties with displaying and texturing some 3ds models, made in sketchup. When displaying and rotating  the camera, at different angles some models are seen through other models. Turning the camera stops it at some angles. I've added some screenshots for better explanation.

The "wrong" angle: http://img810.imageshack.us/i/wrongb.png/

The "good" angle: http://img217.imageshack.us/i/gooddv.png/

This is the code which I use to import 3ds files and edit them a bit.
private Object3D getBuilding(String link, float x, float y, float z, float rotate, String texture) {

Object3D obj = null;
Object3D[] imports = Loader.load3DS(link, 1f);
if (imports.length > 0) {
obj = imports[0];
}
obj.rotateX((float) -Math.PI / 2f);
obj.rotateY((float) ((rotate / 180) * Math.PI));
obj.translateMesh();
obj.rotateMesh();
obj.setTranslationMatrix(new Matrix());
obj.setRotationMatrix(new Matrix());
obj.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
obj.setEnvmapped(Object3D.ENVMAP_ENABLED);
obj.setTexture(texture);
obj.translate(x, y, z);
obj.build();

return obj;
}


Does somebody know why this behavior is taking place?

Greetings,

Nick

paulscode

#1
From the picture, it seems like there are parallel faces that are too close to each other (the floor vs. the ground), and that is causing some interference over which ones are closer to the camera and should be drawn.  Try raising the house up from the ground a bit to see if that helps.

--EDIT-- if that brown texture is part of the house model, you might have to edit the model a bit to increase the distance between those polys and the wall's polys.

fireside

Another thing you might want to do is mess around with the scale a bit.  Generally a larger scale will have less problems with separations like that.  I did it in the game I'm currently working on because at a lower scale, the objects couldn't be as close together, relatively speaking.
click here->Fireside 7 Games<-

Nick

@paulscode
I'm using different objects, so the dark gray/brown color is another model, behind the light gray model. But i'm also finding troubles when looking to just one object, then I'll see through it and can see the other side (Just at some angles, also like above screenshots)

@fireside
I've been messing around with the scaling, but it doesn't seem to help. Also when having objects farther from each other I can look through them.

Also tried to turn off fogging, but didn't help.

Also very funny when compiling the objects, it's even getting worse! Look at the screenshot:

http://img46.imageshack.us/i/compiledp.png/

Does anybody have some tips or have (had) the same problems?

Greetings,

Nick

fireside

Have you checked to see all your normals are going in the right direction?
click here->Fireside 7 Games<-

paulscode

The best way to determine exactly what is causing your problem, is to to have just the one object in the scene (with a black, empty background), and then look at it from the inside at various angles.  If you can still see through it at certain angles, then it is probably a problem with the normals.  If you are instead seeing odd triangles showing up that are not black, then it is probably due to some stray polygons in your model that shouldn't be there, which are protruding through the model, and only visible from certain angles.  If everything looks fine from whatever angle, then it is probably a problem with parallel faces being too close to each other.

EgonOlsen

Any transparency used on these objects?

Nick

@EgonOlsen
I'm not using transparency on one of the objects.

@fireside and pauslcode
I've made a new scene with only one object in it, and it still happens, like above screenshot in my last post. You both say it then must be a problem with my normals. What do you actually mean with that? I know normals are vectors that are perpendicular to a surface, but I can't connect that with my problem.

Thanks for your time,

Nick

paulscode

The usual problem with normals is reversed normals, which results in the backface culling taking out polys that you expect to be visible.  The easiest way to check for this is to call setCulling(false) on your object and see if the behavior is still there.

Nick

#9
Hmm, tried the setCulling to false, but nothing helped. I'm now trying to edit an object to make smaller triangles, maybe that helps. I could just give it a try though...

EDIT: Coming back on what paulscode said before: faces which are almost parallel to each other are probably the problem. I was working with generated triangles, but the triangles where not that logical placed. Made one object already with my own triangles, and it's not flickering anymore. And another difference is the size of the 3ds file, it's increased by 20%. I will edit this post if I done with the tests.