counter-clockwise order

Started by Vitaly, July 25, 2005, 05:05:37 PM

Previous topic - Next topic

Vitaly

Greetings,

have a problem using jPCT. I load the scene from .ase file and some objects are showing but some are invisible. I tried to understand where is the reason and I have only one version - when calling addTriangle for Object3D I have counter-clockwise order broken. Can someone suggest how to check and correct this condition?

Thanks.

EgonOlsen

Try to disable backface culling by using the setCulling()-method in Object3D. Do the objects show then? This is of course not a good solution, just a quick test if vertex ordering is really your problem.

Vitaly

Thanks for advise. Problem is nearly here. I tried to disable backface culling - some objects become visible, but some other - hide!!! Also I find criteria for determining ccw order:

(p1.x-p0.x)*(p2.y-p0.y) - (p2.x-p0.x)*(p1.y-p0.y)

if this is > 0 then we have ccw order. I tried to "normalize" triangles but still have problems :( It just changes what objects are hiding and showing...
More, the visibility depends on camera position and direction - some objects are visible from one camera and hidden from second...

Tried to load the same file using xith3d - all looks good... Have anyone any ideas?

EgonOlsen

Could be that Config.maxPolysVisible is set to low so that some polygons are being discarded. Try to increase this value (before creating a World) and see if it helps.

Anonymous

Egon, thanks a lot, the reason was that limit of visible polygons. By the way, I think it would be reasonable to print some diagnostic message - it can help to easily find the problem. Maybe you can suggest how to align camera to z-axis? In other libs it's done be specifying "vector pointing up" along with position and destination points.

Thanks one more time.

EgonOlsen

What exactly do you mean by "align with z-axis"? The camera is aligned with the the z-axis by default. If you want to align it with the z-axis of an (rotated) object, there is an align()-method in Camera. If you want to align it with any vector, you can do something like this:

// Look up
camera.setBack((new SimpleVector(0,-1,0)).getRotationMatrix().invert3x3());


But it's cheaper to do the rotations directly on the camera instead of aligning it afterwards. Or did i get you wrong?

About the message: You are right. I've avoided this until now, because i don't really see it as an error. But i'll add a one-time warning once you are exceeding the limit (to not spam the console with such messages).

Vitaly

It seems you mean something different. Let me explain. Camera is determined by two obvious parameters - position (look-from point) and destination (look-at point).
But there is one more important thing that I called "vector pointing up". You can see from the same position and at the same target but upside down or beding head left or right and the picture would be different. My question was how to implemet it in jPCT. All methods we discussed change at least target point and this is wrong behaviour.

Thanks.

EgonOlsen

In jPCT, the camera is defined by its position and a rotation matrix, not by "look at" and "up" vectors. If you want the camera to "tilt", just do a rotateZ(<float>) on it. This will work even if it's not aligned with the worlds z-axis.