Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.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
Java 如何定义多边形顶点以适合纹理?_Java_Android_Libgdx_Collision Detection_Polygon - Fatal编程技术网

Java 如何定义多边形顶点以适合纹理?

Java 如何定义多边形顶点以适合纹理?,java,android,libgdx,collision-detection,polygon,Java,Android,Libgdx,Collision Detection,Polygon,我在高中时没有做过很多数学,但经过大量的研究,我明白了要画一个多边形,我们需要定义一个浮点数组作为它的顶点。但是我不知道如何使多边形适合纹理 我做了很多研究,但找不到答案,也找不到简单的演示,比如人们如何映射他们的纹理,从而使多边形正确匹配。我所能看到的只是浮子阵列的直接演示,而不是它们是如何得到每个点的 至于现在,我正在使用大约8个矩形来填充我的纹理以进行碰撞检测,这不是很有效。这是我很久以前编写的一些代码的注释,这些代码使用lwjgl将纹理绑定到矩形,lwjgl使用Java OpenGL /

我在高中时没有做过很多数学,但经过大量的研究,我明白了要画一个多边形,我们需要定义一个浮点数组作为它的顶点。但是我不知道如何使多边形适合纹理

我做了很多研究,但找不到答案,也找不到简单的演示,比如人们如何映射他们的纹理,从而使多边形正确匹配。我所能看到的只是浮子阵列的直接演示,而不是它们是如何得到每个点的


至于现在,我正在使用大约8个矩形来填充我的纹理以进行碰撞检测,这不是很有效。

这是我很久以前编写的一些代码的注释,这些代码使用lwjgl将纹理绑定到矩形,lwjgl使用Java OpenGL

/* For each corner of the quad we define the coordinates of both the texture
             * and the vertex. 
             * 
             * -    The vertex coordinates are the coordinates on the screen that
             *      they are drawn to. 
             * -    The texture coordinates tell which portion of the texture is used.
             * 
             * Texture coordinates are represented in the textureBounds array as follows:
             * [<leftmost x>, <bottommost y>, <rightmost x>, <topmost y>]
             * 
             * -    Texture coordinates [0.0, 0.0, 1.0, 1.0] mean the whole texture is drawn.
             * 
             * -    [0.0f, 0.0f, 0.5f, 1.0f] means that only the left half of texture is drawn. 
             * 
             * -    [0.0f, 0.5f, 2.0f, 1.0f] means that the top half (y is from 0.5 to 1.0)
             *      of the texture is drawn side-by-side twice (x is from 0.0 to 2.0)
             * 
             * */

您可能想查看此相关问题:。