當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。