Java 无法绘制模型

Java 无法绘制模型,java,opengl,opengl-es,lwjgl,opengl-3,Java,Opengl,Opengl Es,Lwjgl,Opengl 3,有必要确定模型(鹰)的三角形是否在矩形平面内。我写了这个程序,但由于某些原因,它运行得很差。原因是什么 matrCoord-三角形的顶点,projMatrCopy-投影矩阵p*V*M。我得到模型三角形顶点的新坐标: private Vector3f getVector(int pos) { Matrix4f projMatrCopy = new Matrix4f().set(proj); Matrix4f matrCoord = new Matrix4f(new

有必要确定模型(鹰)的三角形是否在矩形平面内。我写了这个程序,但由于某些原因,它运行得很差。原因是什么

matrCoord
-三角形的顶点,
projMatrCopy
-投影矩阵p*V*M。我得到模型三角形顶点的新坐标:

private Vector3f getVector(int pos) {
        Matrix4f projMatrCopy = new Matrix4f().set(proj);
        Matrix4f matrCoord = new Matrix4f(new Vector4f(positions[pos], positions[pos + 1], positions[pos + 2], 1.0f),
                new Vector4f(0, 0, 0, 0),
                new Vector4f(0, 0, 0, 0),
                new Vector4f(0,0,0, 0));
        Vector4f p1 = new Vector4f();
        projMatrCopy.mul(matrCoord).getColumn(0, p1);
        return new Vector3f(p1.x, p1.y, p1.z);
    }
然后我检查这个顶点,看它是否在一个矩形区域内。我是这样做的:

private boolean intersectsPlaneToPoint(Vector3f point, List<Vector4f> planes) {

        Float d1 = Intersectionf.distancePointPlane(point.x, point.y, point.z,planes.get(0).x,planes.get(0).y,planes.get(0).z,planes.get(0).w);
        Float d2 = Intersectionf.distancePointPlane(point.x, point.y, point.z, planes.get(1).x,planes.get(1).y,planes.get(1).z,planes.get(1).w);
        Float d3 = Intersectionf.distancePointPlane(point.x, point.y, point.z, planes.get(2).x,planes.get(2).y,planes.get(2).z,planes.get(2).w);
        Float d4 = Intersectionf.distancePointPlane(point.x, point.y, point.z, planes.get(3).x,planes.get(3).y,planes.get(3).z,planes.get(3).w);
        Float d5 = Intersectionf.distancePointPlane(point.x, point.y, point.z, planes.get(4).x,planes.get(4).y,planes.get(4).z,planes.get(4).w);
        Float d6 = Intersectionf.distancePointPlane(point.x, point.y, point.z,planes.get(5).x,planes.get(5).y,planes.get(5).z,planes.get(5).w);
        return d1 < 0 && d2 < 0 && d3 < 0 && d4 >= 0 && d5 < 0 && d6 >= 0;
    }
专用布尔相交平面点(向量3F点,列表平面){
浮点d1=相交F.距离点平面(点x,点y,点z,平面.get(0).x,平面.get(0).y,平面.get(0).z,平面.get(0).w);
Float d2=相交F.距离点平面(点x,点y,点z,平面.get(1).x,平面.get(1).y,平面.get(1).z,平面.get(1).w);
浮点d3=相交F.距离点平面(点x,点y,点z,平面.get(2).x,平面.get(2).y,平面.get(2).z,平面.get(2).w);
浮点d4=相交F.距离点平面(点x,点y,点z,平面.get(3).x,平面.get(3).y,平面.get(3).z,平面.get(3).w);
Float d5=相交F.距离点平面(点x,点y,点z,平面.get(4).x,平面.get(4).y,平面.get(4).z,平面.get(4).w);
浮点d6=相交F.距离点平面(点x,点y,点z,平面.get(5).x,平面.get(5).y,平面.get(5).z,平面.get(5).w);
返回d1<0&&d2<0&&d3<0&&d4>=0&&d5<0&&d6>=0;
}
planes.get(0).x,planes.get(0).y,planes.get(0).z,planes.get(0).w
是平面的a b c d组件

必须输出:


它的哪些方面效果不佳?它是否运行缓慢或给出不正确的结果?请详细说明。@Sean更新的问题我仍然不明白问题是什么。怎么了?具体需要修复的是什么?@Sean在屏幕截图中,你可以看到并不是所有的三角形都是绿色的。问题:如何修复它?那么你是说绿色三角形应该在蓝色正方形(平截头体?)的“内部”?