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


Java Vector2f.sub方法代码示例

本文整理汇总了Java中org.lwjgl.util.vector.Vector2f.sub方法的典型用法代码示例。如果您正苦于以下问题:Java Vector2f.sub方法的具体用法?Java Vector2f.sub怎么用?Java Vector2f.sub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.util.vector.Vector2f的用法示例。


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

示例1: render

import org.lwjgl.util.vector.Vector2f; //导入方法依赖的package包/类
public void render(ICamera camera, Vector3f sunWorldPos) {
	Vector2f sunCoords = convertToScreenSpace(sunWorldPos, camera.getViewMatrix(), camera.getProjectionMatrix());
	if(sunCoords == null){
		return;
	}
	Vector2f sunToCenter = Vector2f.sub(CENTER_SCREEN, sunCoords, null);
	float brightness = 1 - (sunToCenter.length() / 1.4f);//number doubled
	if(brightness > 0){
		calcFlarePositions(sunToCenter, sunCoords);
		renderer.render(sunCoords, flareTextures, brightness);
	}
}
 
开发者ID:TheThinMatrix,项目名称:OcclusionQueries,代码行数:13,代码来源:FlareManager.java

示例2: getIndicators

import org.lwjgl.util.vector.Vector2f; //导入方法依赖的package包/类
/**
 * Gets the 4 indicator values for a certain vertex. This is done by
 * calculating the vector from the current vertex to each of the other two
 * vertices in the current triangle.
 * 
 * The 3 vertex positions are taken from the "vertexPositions" array, and
 * then the offset vectors are calculated by subtracting the current vertex
 * position from the other vertex position.
 * 
 * The offsets are then stored in an array as bytes (not converted to bytes,
 * but simply cast to bytes) and returned. The size of each grid square must
 * be an integer value for this to work, otherwise the offsets wouldn't be
 * able to be represented correctly as bytes.
 * 
 * @param currentVertex
 *            - The index of the current vertex in the current grid square
 *            (A number between 0 and 3).
 * @param vertexPositions
 *            - The 4 corner positions of the current grid square, stored in
 *            the following order: 0 = top left, 1 = bottom left, 2 = top
 *            right, 3 = bottom right
 * @param vertex1
 *            - The index of one of the other vertices in the triangle
 *            (number between 0 and 3).
 * @param vertex2
 *            - The index of the other vertex in the triangle (number
 *            between 0 and 3).
 * @return
 */
private static byte[] getIndicators(int currentVertex, Vector2f[] vertexPositions, int vertex1, int vertex2) {
	Vector2f currentVertexPos = vertexPositions[currentVertex];
	Vector2f vertex1Pos = vertexPositions[vertex1];
	Vector2f vertex2Pos = vertexPositions[vertex2];
	Vector2f offset1 = Vector2f.sub(vertex1Pos, currentVertexPos, null);
	Vector2f offset2 = Vector2f.sub(vertex2Pos, currentVertexPos, null);
	return new byte[] { (byte) offset1.x, (byte) offset1.y, (byte) offset2.x, (byte) offset2.y };
}
 
开发者ID:TheThinMatrix,项目名称:LowPolyWater,代码行数:38,代码来源:WaterGenerator.java

示例3: getIndicators

import org.lwjgl.util.vector.Vector2f; //导入方法依赖的package包/类
/**
 * Gets the 4 indicator values for a certain vertex. This is done by
 * calculating the vector from the current vertex to each of the other two
 * vertices in the current triangle.
 * <p>
 * The 3 vertex positions are taken from the "vertexPositions" array, and
 * then the offset vectors are calculated by subtracting the current vertex
 * position from the other vertex position.
 * <p>
 * The offsets are then stored in an array as bytes (not converted to bytes,
 * but simply cast to bytes) and returned. The size of each grid square must
 * be an integer value for this to work, otherwise the offsets wouldn't be
 * able to be represented correctly as bytes.
 *
 * @param currentVertex   - The index of the current vertex in the current grid square
 *                        (A number between 0 and 3).
 * @param vertexPositions - The 4 corner positions of the current grid square, stored in
 *                        the following order: 0 = top left, 1 = bottom left, 2 = top
 *                        right, 3 = bottom right
 * @param vertex1         - The index of one of the other vertices in the triangle
 *                        (number between 0 and 3).
 * @param vertex2         - The index of the other vertex in the triangle (number
 *                        between 0 and 3).
 * @return
 */
private static byte[] getIndicators(int currentVertex, Vector2f[] vertexPositions, int vertex1, int vertex2) {
    Vector2f currentVertexPos = vertexPositions[currentVertex];
    Vector2f vertex1Pos = vertexPositions[vertex1];
    Vector2f vertex2Pos = vertexPositions[vertex2];
    Vector2f offset1 = Vector2f.sub(vertex1Pos, currentVertexPos, null);
    Vector2f offset2 = Vector2f.sub(vertex2Pos, currentVertexPos, null);
    return new byte[]{(byte) offset1.x, (byte) offset1.y, (byte) offset2.x, (byte) offset2.y};
}
 
开发者ID:GryPLOfficial,项目名称:EcoSystem-Official,代码行数:34,代码来源:WaterGenerator.java


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