www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: stormp on June 14, 2007, 11:24:20 AM

Title: building custom plane: is there an addTriangle() order?
Post by: stormp on June 14, 2007, 11:24:20 AM
Hi,

I was experimenting with building a custom plane.  Is there any order which the addTriangle() or the vectors must be added?

This works:

objSurface.addTriangle(new SimpleVector(-8.0f,  8.0f, 0.0f),
                       new SimpleVector( 8.0f,  8.0f, 0.0f),
                       new SimpleVector( 8.0f, -8.0f, 0.0f));

objSurface.addTriangle(new SimpleVector( 8.0f, -8.0f, 0.0f),
                       new SimpleVector(-8.0f, -8.0f, 0.0f),
                       new SimpleVector(-8.0f,  8.0f, 0.0f));


Where as this doesn't work:

       
objSurface.addTriangle(new SimpleVector(-8.0f, 8.0f, 0.0f),
                       new SimpleVector( 8.0f,  8.0f, 0.0f),
                       new SimpleVector( 8.0f, -8.0f, 0.0f));

objSurface.addTriangle(new SimpleVector(-8.0f,  8.0f, 0.0f),
                       new SimpleVector(-8.0f, -8.0f, 0.0f),
                       new SimpleVector( 8.0f, -8.0f, 0.0f));



Can someone explain? :)

Thanks.
Title: Re: building custom plane: is there an addTriangle() order?
Post by: EgonOlsen on June 14, 2007, 12:25:26 PM
Quote from: stormp on June 14, 2007, 11:24:20 AM
Can someone explain? :)
The docs for addTriangle already do so:

Quote
The vertices have to be defined counter-clockwise because jPCT backface culls them by default.

Your second code works...it's just that the object will be visible from the other side.
Title: Re: building custom plane: is there an addTriangle() order?
Post by: stormp on June 14, 2007, 12:39:29 PM
Doh! I cant believe i didn't notice that.  thx.