当前位置: 首页>>代码示例>>Java>>正文


Java VertexUtils类代码示例

本文整理汇总了Java中org.andengine.opengl.util.VertexUtils的典型用法代码示例。如果您正苦于以下问题:Java VertexUtils类的具体用法?Java VertexUtils怎么用?Java VertexUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VertexUtils类属于org.andengine.opengl.util包,在下文中一共展示了VertexUtils类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkCollision

import org.andengine.opengl.util.VertexUtils; //导入依赖的package包/类
/**
 * @param pVerticesA
 * @param pVertexCountA the number of vertices in pVerticesA
 * @param pVertexOffsetXA
 * @param pVertexOffsetYA
 * @param pVertexStrideA
 * @param pVerticesB
 * @param pVertexCountB the number of vertices in pVerticesB
 * @param pVertexOffsetXB
 * @param pVertexOffsetYB
 * @param pVertexStrideB
 * @return
 */
public static boolean checkCollision(final float[] pVerticesA, final int pVertexCountA, final int pVertexOffsetXA, final int pVertexOffsetYA, final int pVertexStrideA, final float[] pVerticesB, final int pVertexCountB, final int pVertexOffsetXB, final int pVertexOffsetYB, final int pVertexStrideB) {
	/* Check all the lines of A ... */
	for (int a = pVertexCountA - 2; a >= 0; a--) {
		/* ... against all lines in B. */
		if (BaseCollisionChecker.checkCollisionSub(pVerticesA, pVertexOffsetXA, pVertexOffsetYA, pVertexStrideA, a, a + 1, pVerticesB, pVertexCountB, pVertexOffsetXB, pVertexOffsetYB, pVertexStrideB)) {
			return true;
		}
	}
	/* Also check the 'around the corner of the array' line of A against all lines in B. */
	if (BaseCollisionChecker.checkCollisionSub(pVerticesA, pVertexOffsetXA, pVertexOffsetYA, pVertexStrideA, pVertexCountA - 1, 0, pVerticesB, pVertexCountB, pVertexOffsetXB, pVertexOffsetYB, pVertexStrideB)) {
		return true;
	} else {
		/* At last check if one polygon 'contains' the other one by checking
		 * if one vertex of the one vertices is contained by all of the other vertices. */
		if (BaseCollisionChecker.checkContains(pVerticesA, pVertexCountA, VertexUtils.getVertex(pVerticesB, pVertexOffsetXB, pVertexStrideB, 0), VertexUtils.getVertex(pVerticesB, pVertexOffsetYB, pVertexStrideB, 0))) {
			return true;
		} else if (BaseCollisionChecker.checkContains(pVerticesB, pVertexCountB, VertexUtils.getVertex(pVerticesA, pVertexOffsetXA, pVertexStrideA, 0), VertexUtils.getVertex(pVerticesA, pVertexOffsetYA, pVertexStrideA, 0))) {
			return true;
		} else {
			return false;
		}
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:37,代码来源:BaseCollisionChecker.java

示例2: 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;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:33,代码来源:BaseCollisionChecker.java

示例3: checkCollision

import org.andengine.opengl.util.VertexUtils; //导入依赖的package包/类
/**
 * @param pVerticesA
 * @param pVertexCountA the number of vertices in pVerticesA
 * @param pVertexOffsetXA
 * @param pVertexOffsetYA
 * @param pVertexStrideA
 * @param pVerticesB
 * @param pVertexCountB the number of vertices in pVerticesB
 * @param pVertexOffsetXB
 * @param pVertexOffsetYB
 * @param pVertexStrideB
 * @return
 */
public static boolean checkCollision(final float[] pVerticesA, final int pVertexCountA, final int pVertexOffsetXA, final int pVertexOffsetYA, final int pVertexStrideA, final float[] pVerticesB, final int pVertexCountB, final int pVertexOffsetXB, final int pVertexOffsetYB, final int pVertexStrideB) {
	/* Check all the lines of A ... */
	for(int a = pVertexCountA - 2; a >= 0; a--) {
		/* ... against all lines in B. */
		if(ShapeCollisionChecker.checkCollisionSub(pVerticesA, pVertexOffsetXA, pVertexOffsetYA, pVertexStrideA, a, a + 1, pVerticesB, pVertexCountB, pVertexOffsetXB, pVertexOffsetYB, pVertexStrideB)){
			return true;
		}
	}
	/* Also check the 'around the corner of the array' line of A against all lines in B. */
	if(ShapeCollisionChecker.checkCollisionSub(pVerticesA, pVertexOffsetXA, pVertexOffsetYA, pVertexStrideA, pVertexCountA - 1, 0, pVerticesB, pVertexCountB, pVertexOffsetXB, pVertexOffsetYB, pVertexStrideB)){
		return true;
	} else {
		/* At last check if one polygon 'contains' the other one by checking
		 * if one vertex of the one vertices is contained by all of the other vertices. */
		if(ShapeCollisionChecker.checkContains(pVerticesA, pVertexCountA, VertexUtils.getVertex(pVerticesB, pVertexOffsetXB, pVertexStrideB, 0), VertexUtils.getVertex(pVerticesB, pVertexOffsetYB, pVertexStrideB, 0))) {
			return true;
		} else if(ShapeCollisionChecker.checkContains(pVerticesB, pVertexCountB, VertexUtils.getVertex(pVerticesA, pVertexOffsetXA, pVertexStrideA, 0), VertexUtils.getVertex(pVerticesA, pVertexOffsetYA, pVertexStrideA, 0))) {
			return true;
		} else {
			return false;
		}
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:37,代码来源:ShapeCollisionChecker.java

示例4: 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;
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:33,代码来源:ShapeCollisionChecker.java


注:本文中的org.andengine.opengl.util.VertexUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。