I've also tried to go to those shape3ds directly,
like this :
SceneGraphPath sc = new
SceneGraphPath();
while ((!found) && (i<=5))
{ objShape = (Shape3D) SphereObj.getChild(i);
if (objShape != null)
{ Transform3D tr = new Transform3D();
objShape.getLocalToVworld(tr);
double[] distance = new double[3];
found = objShape.intersect(sc,pickRay,distance);
}
i++;
}
while ((!found) && (i<=5))
{ objShape = (Shape3D) SphereObj.getChild(i);
if (objShape != null)
{ Transform3D tr = new Transform3D();
objShape.getLocalToVworld(tr);
double[] distance = new double[3];
found = objShape.intersect(sc,pickRay,distance);
}
i++;
}
No intersection happened, but those shape3d are not
null anyway.
I made each shape3d for area by constructing
trianglestriparray for geometry. I got coordinates for this geometry by finding
first rho and theta.
this is one example of that shape3d's construction
:
// construct triangle
array
int[] stripLength = {continent[i].NumVertices};
TriangleStripArray geoNA = new TriangleStripArray(continent[i].NumVertices,TriangleStripArray.NORMALS|TriangleStripArray.COORDINATES|TriangleStripArray.TEXTURE_COORDINATE_2,stripLength);
geoNA.setCapability(TriangleStripArray.ALLOW_COORDINATE_READ);
geoNA.setCapability(TriangleStripArray.ALLOW_INTERSECT);
// coordinates
// for each pair of coordx and coordy
for (int k=0;k<=continent[i].NumVertices-1;k++ )
{ //coordx
s = (double) (continent[i].coordx[k]/width);
theta = (s/ds) * dtheta;
int[] stripLength = {continent[i].NumVertices};
TriangleStripArray geoNA = new TriangleStripArray(continent[i].NumVertices,TriangleStripArray.NORMALS|TriangleStripArray.COORDINATES|TriangleStripArray.TEXTURE_COORDINATE_2,stripLength);
geoNA.setCapability(TriangleStripArray.ALLOW_COORDINATE_READ);
geoNA.setCapability(TriangleStripArray.ALLOW_INTERSECT);
// coordinates
// for each pair of coordx and coordy
for (int k=0;k<=continent[i].NumVertices-1;k++ )
{ //coordx
s = (double) (continent[i].coordx[k]/width);
theta = (s/ds) * dtheta;
vx = -Math.sin(theta) *
Math.sin(rho);
vy = Math.cos(theta) * Math.sin(rho);
vz = sign * Math.cos(rho);
Point3d coords = new Point3d(vx,vy,vz);
geoNA.setCoordinate(k,coords);
Point2f tc = new Point2f((float)s,(float)t);
geoNA.setTextureCoordinate(k,tc);
} // end of for
vy = Math.cos(theta) * Math.sin(rho);
vz = sign * Math.cos(rho);
Point3d coords = new Point3d(vx,vy,vz);
geoNA.setCoordinate(k,coords);
Point2f tc = new Point2f((float)s,(float)t);
geoNA.setTextureCoordinate(k,tc);
} // end of for
Shape3D shapeNA = new
Shape3D(geoNA);
shapeNA.setPickable(true);
shapeNA.setCapability(Shape3D.ALLOW_LOCAL_TO_VWORLD_READ);
shapeNA.setUserData(continent[i]);
this.addChild(shapeNA);
shapeNA.setPickable(true);
shapeNA.setCapability(Shape3D.ALLOW_LOCAL_TO_VWORLD_READ);
shapeNA.setUserData(continent[i]);
this.addChild(shapeNA);
please tell me what's wrong with this. I've read
through all tutorial and specification but still I got difficulty with
this.
Thanks
Tria
