Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Java3D中从IndexeGeometryArray读取顶点坐标和三角形索引?_Java_Opengl - Fatal编程技术网

如何在Java3D中从IndexeGeometryArray读取顶点坐标和三角形索引?

如何在Java3D中从IndexeGeometryArray读取顶点坐标和三角形索引?,java,opengl,Java,Opengl,我现在正在做网格存储工作,即,简单地说,将未索引网格转换为索引网格。工作原理如下: GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); gi.setCoordinates(points); gi.setStripCounts(strips); gi.setContourCounts(contours); gi.convertToIndexedTriangles(); IndexedGeometryArray ga = g

我现在正在做网格存储工作,即,简单地说,将未索引网格转换为索引网格。工作原理如下:

GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(points);
gi.setStripCounts(strips);
gi.setContourCounts(contours);
gi.convertToIndexedTriangles();
IndexedGeometryArray ga = gi.getIndexedGeometryArray(true);
GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(points);
gi.setStripCounts(strips);
gi.setContourCounts(contours);
gi.convertToIndexedTriangles();
IndexedGeometryArray ga = gi.getIndexedGeometryArray(true);

double [] originalVertices = new double [ga.getVertexCount() * 3];
for(int i = 0; i < ga.getVertexCount(); i++ ){
   double [] coord = new double [3];
   ga.getCoordinate(i, coord);
   for(int j = 0; j < 3; j++)
      originalVertices[i*3+j] = coord[j];
   }//next i
}//next
int[] triangles = new int[ga.getValidIndexCount()];
ga.getCoordinateIndices(0, triangles);
我想现在是读取和存储顶点和三角形信息的好时机,这些信息应该以
[[xyz]、[xyz]、[xyz]]的形式作为顶点
[[abc]、[abc]、[abc]、[abc]]的形式作为三角形
,而这些新顶点的数量应该比未编制索引的要少得多

然而,我读得越多,我就越困惑。从GeometryArray继承的方法
GetCoordinations()
似乎会导致旧的顶点,而
GetCoordinationIndicates()
的新方法很难理解,就像
GetCoordinationIndicates(0,索引)
一样。为什么是0?这些索引中存储了什么?如果两者都错了,那么应该采用哪种方法


谢谢

几分钟后,我想到了这样的事情:

GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(points);
gi.setStripCounts(strips);
gi.setContourCounts(contours);
gi.convertToIndexedTriangles();
IndexedGeometryArray ga = gi.getIndexedGeometryArray(true);
GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(points);
gi.setStripCounts(strips);
gi.setContourCounts(contours);
gi.convertToIndexedTriangles();
IndexedGeometryArray ga = gi.getIndexedGeometryArray(true);

double [] originalVertices = new double [ga.getVertexCount() * 3];
for(int i = 0; i < ga.getVertexCount(); i++ ){
   double [] coord = new double [3];
   ga.getCoordinate(i, coord);
   for(int j = 0; j < 3; j++)
      originalVertices[i*3+j] = coord[j];
   }//next i
}//next
int[] triangles = new int[ga.getValidIndexCount()];
ga.getCoordinateIndices(0, triangles);
GeometryInfo gi=新的GeometryInfo(GeometryInfo.POLYGON_数组);
gi.设定坐标(点);
gi.设置TripCounts(条带);
gi.轮廓计数(轮廓);
gi.convertToIndexedTriangles();
IndexedGeometryArray ga=gi.getIndexedGeometryArray(true);
double[]originalVertices=新的double[ga.getVertexCount()*3];
对于(int i=0;i

我不太明白为什么,但它在某种程度上起作用,实际上相当不错。

几分钟后,我发现它是这样的:

GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(points);
gi.setStripCounts(strips);
gi.setContourCounts(contours);
gi.convertToIndexedTriangles();
IndexedGeometryArray ga = gi.getIndexedGeometryArray(true);
GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(points);
gi.setStripCounts(strips);
gi.setContourCounts(contours);
gi.convertToIndexedTriangles();
IndexedGeometryArray ga = gi.getIndexedGeometryArray(true);

double [] originalVertices = new double [ga.getVertexCount() * 3];
for(int i = 0; i < ga.getVertexCount(); i++ ){
   double [] coord = new double [3];
   ga.getCoordinate(i, coord);
   for(int j = 0; j < 3; j++)
      originalVertices[i*3+j] = coord[j];
   }//next i
}//next
int[] triangles = new int[ga.getValidIndexCount()];
ga.getCoordinateIndices(0, triangles);
GeometryInfo gi=新的GeometryInfo(GeometryInfo.POLYGON_数组);
gi.设定坐标(点);
gi.设置TripCounts(条带);
gi.轮廓计数(轮廓);
gi.convertToIndexedTriangles();
IndexedGeometryArray ga=gi.getIndexedGeometryArray(true);
double[]originalVertices=新的double[ga.getVertexCount()*3];
对于(int i=0;i
我不太明白为什么,但它在某种程度上起作用,实际上相当好