⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indexedtrianglefanarrayretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: IndexedTriangleFanArrayRetained.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.6 $ * $Date: 2007/02/09 17:18:05 $ * $State: Exp $ */package javax.media.j3d;import javax.vecmath.*;import java.lang.Math;/** * The IndexedTriangleFanArray object draws an array of vertices as a set of * connected triangle fans.  An array of per-strip * vertex counts specifies where the separate strips (fans) appear * in the vertex array.  For every strip in the set, * each vertex, beginning with the third vertex in the array, * defines a triangle to be drawn using the current vertex, * the previous vertex and the first vertex.  This can be thought of * as a collection of convex polygons. */class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained {      IndexedTriangleFanArrayRetained(){	geoType = GEO_TYPE_INDEXED_TRI_FAN_SET;    }    boolean intersect(PickShape pickShape, PickInfo pickInfo, int flags, Point3d iPnt,                      GeometryRetained geom, int geomIndex) {	Point3d pnts[] = new Point3d[3];	double sdist[] = new double[1];	double minDist = Double.MAX_VALUE;	double x = 0, y = 0, z = 0;	int i = 0;	int j, scount, count = 0;        pnts[0] = new Point3d();	pnts[1] = new Point3d();	pnts[2] = new Point3d();            int[] vtxIndexArr = new int[3];	switch (pickShape.getPickType()) {	case PickShape.PICKRAY:	    PickRay pickRay= (PickRay) pickShape;	            while (i < stripIndexCounts.length) {                for(int k=0; k<2; k++) {                    vtxIndexArr[k] = indexCoord[count];                    getVertexData(indexCoord[count++], pnts[k]);                }		scount = stripIndexCounts[i++];		for (j=2; j < scount; j++) {                    vtxIndexArr[2] = indexCoord[count];                    getVertexData(indexCoord[count++], pnts[2]);		    if (intersectRay(pnts, pickRay, sdist, iPnt)) {			if (flags == 0) {			    return true;			}			if (sdist[0] < minDist) {			    minDist = sdist[0];                            x = iPnt.x;                            y = iPnt.y;                            z = iPnt.z;                            if((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) {                                storeInterestData(pickInfo, flags, geom, geomIndex,                                                   vtxIndexArr, iPnt, sdist[0]);                            }                        }                        if((flags & PickInfo.ALL_GEOM_INFO) != 0) {                            storeInterestData(pickInfo, flags, geom, geomIndex,                                               vtxIndexArr, iPnt, sdist[0]);                             		        }                    }		    pnts[1].set(pnts[2]);                    vtxIndexArr[1] = vtxIndexArr[2];		}	    }	    break;	case PickShape.PICKSEGMENT:	    PickSegment pickSegment = (PickSegment) pickShape;	    while (i < stripIndexCounts.length) {                  for(int k=0; k<2; k++) {                    vtxIndexArr[k] = indexCoord[count];                    getVertexData(indexCoord[count++], pnts[k]);                }		scount = stripIndexCounts[i++];		for (j=2; j < scount; j++) {                    vtxIndexArr[2] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[2]);		    if (intersectSegment(pnts, pickSegment.start, 					 pickSegment.end, sdist, iPnt)) {			if (flags == 0) {			    return true;			}			if (sdist[0] < minDist) {			    minDist = sdist[0];                            x = iPnt.x;                            y = iPnt.y;                            z = iPnt.z;                            if((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) {                                storeInterestData(pickInfo, flags, geom, geomIndex,                                                   vtxIndexArr, iPnt, sdist[0]);                            }                        }                        if((flags & PickInfo.ALL_GEOM_INFO) != 0) {                            storeInterestData(pickInfo, flags, geom, geomIndex,                                               vtxIndexArr, iPnt, sdist[0]);                             		        }                    }		    pnts[1].set(pnts[2]);                    vtxIndexArr[1] = vtxIndexArr[2];		}	    }	    break;	case PickShape.PICKBOUNDINGBOX:	    BoundingBox bbox = (BoundingBox) 		((PickBounds) pickShape).bounds;	    while (i < stripIndexCounts.length) {                  for(int k=0; k<2; k++) {                    vtxIndexArr[k] = indexCoord[count];                    getVertexData(indexCoord[count++], pnts[k]);                }		scount = stripIndexCounts[i++];		for (j=2; j < scount; j++) {                    vtxIndexArr[2] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[2]);		    if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) {			if (flags == 0) {			    return true;			}			if (sdist[0] < minDist) {			    minDist = sdist[0];                            x = iPnt.x;                            y = iPnt.y;                            z = iPnt.z;                            if((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) {                                storeInterestData(pickInfo, flags, geom, geomIndex,                                                   vtxIndexArr, iPnt, sdist[0]);                            }                        }                        if((flags & PickInfo.ALL_GEOM_INFO) != 0) {                            storeInterestData(pickInfo, flags, geom, geomIndex,                                               vtxIndexArr, iPnt, sdist[0]);                             		        }                    }		    pnts[1].set(pnts[2]);                    vtxIndexArr[1] = vtxIndexArr[2];		}	    }	    break;	case PickShape.PICKBOUNDINGSPHERE:	    BoundingSphere bsphere = (BoundingSphere) 		                     ((PickBounds) pickShape).bounds;	    while (i < stripIndexCounts.length) {                  for(int k=0; k<2; k++) {                    vtxIndexArr[k] = indexCoord[count];                    getVertexData(indexCoord[count++], pnts[k]);                }		scount = stripIndexCounts[i++];		for (j=2; j < scount; j++) {                    vtxIndexArr[2] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[2]);		    if (intersectBoundingSphere(pnts, bsphere, sdist,						iPnt)) { 			if (flags == 0) {			    return true;			}			if (sdist[0] < minDist) {			    minDist = sdist[0];                            x = iPnt.x;                            y = iPnt.y;                            z = iPnt.z;                            if((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) {                                storeInterestData(pickInfo, flags, geom, geomIndex,                                                   vtxIndexArr, iPnt, sdist[0]);                            }                        }                        if((flags & PickInfo.ALL_GEOM_INFO) != 0) {                            storeInterestData(pickInfo, flags, geom, geomIndex,                                               vtxIndexArr, iPnt, sdist[0]);                             		        }                    }		    pnts[1].set(pnts[2]);                    vtxIndexArr[1] = vtxIndexArr[2];		}	    }	    break;	case PickShape.PICKBOUNDINGPOLYTOPE:	    BoundingPolytope bpolytope = (BoundingPolytope) 		((PickBounds) pickShape).bounds;	    while (i < stripIndexCounts.length) {                  for(int k=0; k<2; k++) {                    vtxIndexArr[k] = indexCoord[count];                    getVertexData(indexCoord[count++], pnts[k]);                }		scount = stripIndexCounts[i++];		for (j=2; j < scount; j++) {                    vtxIndexArr[2] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[2]);		    if (intersectBoundingPolytope(pnts, bpolytope,						  sdist, iPnt)) {			if (flags == 0) {			    return true;			}			if (sdist[0] < minDist) {			    minDist = sdist[0];                            x = iPnt.x;                            y = iPnt.y;                            z = iPnt.z;                            if((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) {                                storeInterestData(pickInfo, flags, geom, geomIndex,                                                   vtxIndexArr, iPnt, sdist[0]);                            }                        }                        if((flags & PickInfo.ALL_GEOM_INFO) != 0) {                            storeInterestData(pickInfo, flags, geom, geomIndex,                                               vtxIndexArr, iPnt, sdist[0]);                             		        }                    }		    pnts[1].set(pnts[2]);                    vtxIndexArr[1] = vtxIndexArr[2];		}	    }	    break;	case PickShape.PICKCYLINDER:	    PickCylinder pickCylinder= (PickCylinder) pickShape;	    while (i < stripIndexCounts.length) {                  for(int k=0; k<2; k++) {                    vtxIndexArr[k] = indexCoord[count];                    getVertexData(indexCoord[count++], pnts[k]);                }		scount = stripIndexCounts[i++];		for (j=2; j < scount; j++) {                    vtxIndexArr[2] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[2]);		    if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) {			if (flags == 0) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -