本文整理汇总了Java中org.andengine.opengl.util.VertexUtils.getVertex方法的典型用法代码示例。如果您正苦于以下问题:Java VertexUtils.getVertex方法的具体用法?Java VertexUtils.getVertex怎么用?Java VertexUtils.getVertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.opengl.util.VertexUtils
的用法示例。
在下文中一共展示了VertexUtils.getVertex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkContains
import org.andengine.opengl.util.VertexUtils; //导入方法依赖的package包/类
/**
* Works with complex polygons!
*
* @see <a href="http://alienryderflex.com/polygon/">alienryderflex.com/polygon/</a>
*
* @param pVertices
* @param pVertexCount the number of vertices in pVertices
* @param pVertexOffsetX
* @param pVertexOffsetY
* @param pVertexStride
* @param pX
* @param pY
* @return <code>true</code> when the point defined by <code>(pX, pY)</code> is inside the polygon defined by <code>pVertices</code>, <code>false</code>. If the point is exactly on the edge of the polygon, the result can be <code>true</code> or <code>false</code>.
*/
public static boolean checkContains(final float[] pVertices, final int pVertexCount, final int pVertexOffsetX, final int pVertexOffsetY, final int pVertexStride, final float pX, final float pY) {
boolean odd = false;
int j = pVertexCount - 1;
for (int i = 0; i < pVertexCount; i++) {
final float vertexXI = VertexUtils.getVertex(pVertices, pVertexOffsetX, pVertexStride, i);
final float vertexYI = VertexUtils.getVertex(pVertices, pVertexOffsetY, pVertexStride, i);
final float vertexXJ = VertexUtils.getVertex(pVertices, pVertexOffsetX, pVertexStride, j);
final float vertexYJ = VertexUtils.getVertex(pVertices, pVertexOffsetY, pVertexStride, j);
if ((((vertexYI < pY) && (vertexYJ >= pY)) || ((vertexYJ < pY) && (vertexYI >= pY))) && ((vertexXI <= pX) || (vertexXJ <= pX))) {
odd ^= ((vertexXI + (((pY - vertexYI) / (vertexYJ - vertexYI)) * (vertexXJ - vertexXI))) < pX);
}
j = i;
}
return odd;
}
示例2: checkContains
import org.andengine.opengl.util.VertexUtils; //导入方法依赖的package包/类
/**
* Works with complex polygons!
*
* @see http://alienryderflex.com/polygon/
*
* @param pVertices
* @param pVertexCount the number of vertices in pVertices
* @param pVertexOffsetX
* @param pVertexOffsetY
* @param pVertexStride
* @param pX
* @param pY
* @return <code>true</code> when the point defined by <code>(pX, pY)</code> is inside the polygon defined by <code>pVertices</code>, <code>false</code>. If the point is exactly on the edge of the polygon, the result can be <code>true</code> or <code>false</code>.
*/
public static boolean checkContains(final float[] pVertices, final int pVertexCount, final int pVertexOffsetX, final int pVertexOffsetY, final int pVertexStride, final float pX, final float pY) {
boolean odd = false;
int j = pVertexCount - 1;
for(int i = 0; i < pVertexCount; i++) {
final float vertexXI = VertexUtils.getVertex(pVertices, pVertexOffsetX, pVertexStride, i);
final float vertexYI = VertexUtils.getVertex(pVertices, pVertexOffsetY, pVertexStride, i);
final float vertexXJ = VertexUtils.getVertex(pVertices, pVertexOffsetX, pVertexStride, j);
final float vertexYJ = VertexUtils.getVertex(pVertices, pVertexOffsetY, pVertexStride, j);
if((((vertexYI < pY) && (vertexYJ >= pY)) || ((vertexYJ < pY) && (vertexYI >= pY))) && ((vertexXI <= pX) || (vertexXJ <= pX))) {
odd ^= ((vertexXI + (((pY - vertexYI) / (vertexYJ - vertexYI)) * (vertexXJ - vertexXI))) < pX);
}
j = i;
}
return odd;
}