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

📄 indexedlinestriparrayretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: IndexedLineStripArrayRetained.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:04 $ * $State: Exp $ */package javax.media.j3d;import javax.vecmath.*;import java.lang.Math;/** * The IndexedLineStripArray object draws an array of vertices as a set of * connected line strips.  An array of per-strip vertex counts specifies * where the separate strips appear in the vertex array. * For every strip in the set, each vertex, beginning with * the second vertex in the array, defines a line segment to be drawn * from the previous vertex to the current vertex. */class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained {	    IndexedLineStripArrayRetained() {        geoType = GEO_TYPE_INDEXED_LINE_STRIP_SET;    }    boolean intersect(PickShape pickShape, PickInfo pickInfo, int flags, Point3d iPnt,                      GeometryRetained geom, int geomIndex) {	Point3d pnts[] = new Point3d[2];	double sdist[] = new double[1];	double minDist = Double.MAX_VALUE;	double x = 0, y = 0, z = 0;	int scount, j, i = 0;	int count = 0;        int[] vtxIndexArr = new int[2];        	pnts[0] = new Point3d();	pnts[1] = new Point3d();    	switch (pickShape.getPickType()) {	case PickShape.PICKRAY:	    PickRay pickRay= (PickRay) pickShape;	   while (i < stripIndexCounts.length) {                vtxIndexArr[0] = indexCoord[count];		getVertexData(indexCoord[count++], pnts[0]);		scount = stripIndexCounts[i++];		for (j=1; j < scount; j++) {                    vtxIndexArr[1] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[1]);		    if (intersectLineAndRay(pnts[0], pnts[1], pickRay.origin,					    pickRay.direction, 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[0].set(pnts[1]);                    vtxIndexArr[0] = vtxIndexArr[1];		}	    }	    break;	case PickShape.PICKSEGMENT:	    PickSegment pickSegment = (PickSegment) pickShape;	    Vector3d dir = 		new Vector3d(pickSegment.end.x - pickSegment.start.x, 			     pickSegment.end.y - pickSegment.start.y,			     pickSegment.end.z - pickSegment.start.z);	    	    while (i < stripIndexCounts.length) {                  vtxIndexArr[0] = indexCoord[count];		getVertexData(indexCoord[count++], pnts[0]);		scount =  stripIndexCounts[i++];		for (j=1; j < scount; j++) {	                     vtxIndexArr[1] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[1]);		    if (intersectLineAndRay(pnts[0], pnts[1],					    pickSegment.start, 					    dir, sdist, iPnt) &&			(sdist[0] <= 1.0)) {			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[0].set(pnts[1]);                    vtxIndexArr[0] = vtxIndexArr[1];		}	    }	    break;	case PickShape.PICKBOUNDINGBOX:	    BoundingBox bbox = (BoundingBox) 		               ((PickBounds) pickShape).bounds;	    while (i < stripIndexCounts.length) {                  vtxIndexArr[0] = indexCoord[count];		getVertexData(indexCoord[count++], pnts[0]);		scount =  stripIndexCounts[i++];		for (j=1; j < scount; j++) {	                     vtxIndexArr[1] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[1]);		    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[0].set(pnts[1]);                    vtxIndexArr[0] = vtxIndexArr[1];		}	    }	    break;	case PickShape.PICKBOUNDINGSPHERE:	    BoundingSphere bsphere = (BoundingSphere) 		                     ((PickBounds) pickShape).bounds;	    while (i < stripIndexCounts.length) {                  vtxIndexArr[0] = indexCoord[count];		getVertexData(indexCoord[count++], pnts[0]);		scount =  stripIndexCounts[i++];		for (j=1; j < scount; j++) {                    vtxIndexArr[1] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[1]);		    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[0].set(pnts[1]);                    vtxIndexArr[0] = vtxIndexArr[1];		}	    }	    break;	case PickShape.PICKBOUNDINGPOLYTOPE:	    BoundingPolytope bpolytope = (BoundingPolytope) 		                      ((PickBounds) pickShape).bounds;	    while (i < stripIndexCounts.length) {                  vtxIndexArr[0] = indexCoord[count];		getVertexData(indexCoord[count++], pnts[0]);		scount =  stripIndexCounts[i++];		for (j=1; j < scount; j++) {                    vtxIndexArr[1] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[1]);		    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[0].set(pnts[1]);                    vtxIndexArr[0] = vtxIndexArr[1];		}	    }	    break;	case PickShape.PICKCYLINDER:	    PickCylinder pickCylinder= (PickCylinder) pickShape;	    while (i < stripIndexCounts.length) {                  vtxIndexArr[0] = indexCoord[count];		getVertexData(indexCoord[count++], pnts[0]);		scount =  stripIndexCounts[i++];		for (j=1; j < scount; j++) {                    vtxIndexArr[1] = indexCoord[count];		    getVertexData(indexCoord[count++], pnts[1]);		    if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) {

⌨️ 快捷键说明

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