Hi,

maybe, you can fix it like this:

    PickIntersection info = ...
    Vector3d normal = calculateNormal( info.getPrimitiveCoordinates() );

and

    private Vector3d calculateNormal(Point3d[] verts) {
        if ( verts.length < 3 ) {
            return null;
        } else {
            Vector3d d0 = new Vector3d();
            Vector3d d1 = new Vector3d();

            d0.sub(verts[1], verts[0]);
            d1.sub(verts[2], verts[0]);

            Vector3d norm = new Vector3d();
            norm.cross(d0, d1);
            norm.normalize();

            return norm;
        }
    }

Regards,
Marc

> Hello everybody!
> I'm trying to implement collision detection in j3d 1.2 API using
> picking. The problem is the following: when I use a CylinderShape for
> intersection test with the geometry of the picking scope, I always get a
> null pointer for the normal vector in the intersection point. Any other
> data (closest vertex to the intersection point, its normal, distance
> from the pick shape starting point to intersection point, etc) is
> retrieved correctly. I remark that for terrain following purpose I need
> the normal to the picked polygon (triangle in particular). Does anyone
> have an idea to fix the problem?
> Thanks...
> Max

Marc Nienhaus


      ) echtzeit AG REALITY BUSINESS

            berlin | cologne | san francisco


            Marc Nienhaus
            Software Engineer (Computer Graphics)


            telefon +49 30 884586 0
            telefax +49 30 884586 22


            http://www.echtzeit.de

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to