本文整理匯總了Java中org.lwjgl.util.vector.Vector4f類的典型用法代碼示例。如果您正苦於以下問題:Java Vector4f類的具體用法?Java Vector4f怎麽用?Java Vector4f使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Vector4f類屬於org.lwjgl.util.vector包,在下文中一共展示了Vector4f類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderWithoutWater
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
public void renderWithoutWater(final PerspectiveCamera camera, final boolean renderReflected) {
shader.bind();
shader.update(camera, directionalLight);
if(renderReflected) {
shader.setUniform("clip_plane", new Vector4f(0, 1, 0, -WaterRegion.WATER_HEIGHT));
} else {
shader.setUniform("clip_plane", new Vector4f(0, 0, 0, 0));
}
if(skybox != null) {
skybox.render(camera);
}
for(Entry<String, Region> region : regions.entrySet()) {
region.getValue().render(shader);
}
}
示例2: createQuad
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
private BakedQuad createQuad(QuadHolder holder, EnumFacing facing) {
Vector4f uv = holder.uv;
Vector3 a = holder.a;
Vector3 b = holder.b;
Vector3 c = holder.c;
Vector3 d = holder.d;
Vector3 normal = c.copy().subtract(b).cross(a.copy().subtract(b)).normalize();
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
putVertex(builder, normal, a.x, a.y, a.z, holder.sprite, uv.y, uv.w, hasBrightness);
putVertex(builder, normal, b.x, b.y, b.z, holder.sprite, uv.y, uv.z, hasBrightness);
putVertex(builder, normal, c.x, c.y, c.z, holder.sprite, uv.x, uv.z, hasBrightness);
putVertex(builder, normal, d.x, d.y, d.z, holder.sprite, uv.x, uv.w, hasBrightness);
builder.setQuadOrientation(facing);
builder.setTexture(holder.sprite);
return builder.build();
}
示例3: render
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
public void render(List<Light> lights, Camera camera, Vector4f clipPlane) {
prepare();
shader.start();
shader.loadClipPlane(clipPlane);
shader.loadSkyColour(RED, GREEN, BLUE);
shader.loadLights(lights);
shader.loadViewMatrix(camera);
renderer.render(entities);
shader.stop();
normalMapRenderer.render(normalMapEntities, clipPlane, lights, camera);
terrainShader.start();
terrainShader.loadClipPlane(clipPlane);
terrainShader.loadSkyColour(RED, GREEN, BLUE);
terrainShader.loadLights(lights);
terrainShader.loadViewMatrix(camera);
terrainRenderer.render(terrains);
terrainShader.stop();
skyboxRenderer.render(camera, RED, GREEN, BLUE);
terrains.clear();
entities.clear();
normalMapEntities.clear();
}
示例4: generateRandomUnitVectorWithinCone
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
private static Vector3f generateRandomUnitVectorWithinCone(Vector3f coneDirection, float angle) {
float cosAngle = (float) Math.cos(angle);
Random random = new Random();
float theta = (float) (random.nextFloat() * 2f * Math.PI);
float z = cosAngle + (random.nextFloat() * (1 - cosAngle));
float rootOneMinusZSquared = (float) Math.sqrt(1 - z * z);
float x = (float) (rootOneMinusZSquared * Math.cos(theta));
float y = (float) (rootOneMinusZSquared * Math.sin(theta));
Vector4f direction = new Vector4f(x, y, z, 1);
if (coneDirection.x != 0 || coneDirection.y != 0 || (coneDirection.z != 1 && coneDirection.z != -1)) {
Vector3f rotateAxis = Vector3f.cross(coneDirection, new Vector3f(0, 0, 1), null);
rotateAxis.normalise();
float rotateAngle = (float) Math.acos(Vector3f.dot(coneDirection, new Vector3f(0, 0, 1)));
Matrix4f rotationMatrix = new Matrix4f();
rotationMatrix.rotate(-rotateAngle, rotateAxis);
Matrix4f.transform(rotationMatrix, direction, direction);
} else if (coneDirection.z == -1) {
direction.z *= -1;
}
return new Vector3f(direction);
}
示例5: render
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
public void render(List<Light> lights, Camera camera, Vector4f clipPlane) {
prepare();
shader.start();
shader.loadClipPlane(clipPlane);
shader.loadSkyClourVariable(fogColour.x, fogColour.y, fogColour.z);
shader.loadLights(lights);
shader.loadViewMatrix(camera);
entityRenderer.render(entities, shadowMapRenderer.getToShadowMapSpaceMatrix());
shader.stop();
terrainShader.start();
terrainShader.loadClipPlane(clipPlane);
terrainShader.loadSkyColorVariable(fogColour.x, fogColour.y, fogColour.z);
terrainShader.loadLights(lights);
terrainShader.loadViewMatrix(camera);
terrainRenderer.render(terrains, shadowMapRenderer.getToShadowMapSpaceMatrix());
terrainShader.stop();
skyboxRenderer.render(camera, fogColour.x, fogColour.y, fogColour.z);
GL11.glShadeModel(GL11.GL_SMOOTH);
entities.clear();
terrains.clear();
}
示例6: generateRandomUnitVectorWithinCone
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
private static Vector3f generateRandomUnitVectorWithinCone(Vector3f coneDirection, float angle) {
float cosAngle = (float) Math.cos(angle);
Random random = new Random();
float theta = (float) (random.nextFloat() * 2f * Math.PI);
float z = cosAngle + (random.nextFloat() * (1 - cosAngle));
float rootOneMinusZSquared = (float) Math.sqrt(1 - z * z);
float x = (float) (rootOneMinusZSquared * Math.cos(theta));
float y = (float) (rootOneMinusZSquared * Math.sin(theta));
Vector4f direction = new Vector4f(x, y, z, 1);
if (coneDirection.x != 0 || coneDirection.y != 0 || (coneDirection.z != 1 && coneDirection.z != -1)) {
Vector3f rotateAxis = Vector3f.cross(coneDirection, new Vector3f(0, 0, 1), null);
rotateAxis.normalise();
float rotateAngle = (float) Math.acos(Vector3f.dot(coneDirection, new Vector3f(0, 0, 1)));
Matrix4f rotationMatrix = new Matrix4f();
rotationMatrix.rotate(-rotateAngle, rotateAxis);
Matrix4f.transform(rotationMatrix, direction, direction);
} else if (coneDirection.z == -1) {
direction.z *= -1;
}
return new Vector3f(direction);
}
示例7: calculateFrustumVertices
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
private Vector4f[] calculateFrustumVertices(Matrix4f rotation, Vector3f forwardVector, Vector3f centerNear, Vector3f centerFar) {
Vector3f upVector = new Vector3f(Matrix4f.transform(rotation, UP, null));
Vector3f rightVector = Vector3f.cross(forwardVector, upVector, null);
Vector3f downVector = new Vector3f(-upVector.x, -upVector.y, -upVector.z);
Vector3f leftVector = new Vector3f(-rightVector.x, -rightVector.y, -rightVector.z);
Vector3f farTop = Vector3f.add(centerFar, new Vector3f(upVector.x * farHeight, upVector.y * farHeight, upVector.z * farHeight), null);
Vector3f farBottom = Vector3f.add(centerFar, new Vector3f(downVector.x * farHeight, downVector.y * farHeight, downVector.z * farHeight), null);
Vector3f nearTop = Vector3f.add(centerNear, new Vector3f(upVector.x * nearHeight, upVector.y * nearHeight, upVector.z * nearHeight), null);
Vector3f nearBottom = Vector3f.add(centerNear, new Vector3f(downVector.x * nearHeight, downVector.y * nearHeight, downVector.z * nearHeight), null);
Vector4f[] points = new Vector4f[8];
points[0] = calculateLightSpaceFrustumCorner(farTop, rightVector, farWidth);
points[1] = calculateLightSpaceFrustumCorner(farTop, leftVector, farWidth);
points[2] = calculateLightSpaceFrustumCorner(farBottom, rightVector, farWidth);
points[3] = calculateLightSpaceFrustumCorner(farBottom, leftVector, farWidth);
points[4] = calculateLightSpaceFrustumCorner(nearTop, rightVector, nearWidth);
points[5] = calculateLightSpaceFrustumCorner(nearTop, leftVector, nearWidth);
points[6] = calculateLightSpaceFrustumCorner(nearBottom, rightVector, nearWidth);
points[7] = calculateLightSpaceFrustumCorner(nearBottom, leftVector, nearWidth);
return points;
}
示例8: calculateFrustumVertices
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
/**
* Calculates the position of the vertex at each corner of the view frustum
* in light space (8 vertices in total, so this returns 8 positions).
*
* @param rotation
* - camera's rotation.
* @param forwardVector
* - the direction that the camera is aiming, and thus the
* direction of the frustum.
* @param centerNear
* - the center point of the frustum's near plane.
* @param centerFar
* - the center point of the frustum's (possibly adjusted) far
* plane.
* @return The positions of the vertices of the frustum in light space.
*/
private Vector4f[] calculateFrustumVertices(Matrix4f rotation, Vector3f forwardVector, Vector3f centerNear,
Vector3f centerFar) {
Vector3f upVector = new Vector3f(Matrix4f.transform(rotation, UP, null));
Vector3f rightVector = Vector3f.cross(forwardVector, upVector, null);
Vector3f downVector = new Vector3f(-upVector.x, -upVector.y, -upVector.z);
Vector3f leftVector = new Vector3f(-rightVector.x, -rightVector.y, -rightVector.z);
Vector3f farTop = Vector3f.add(centerFar,
new Vector3f(upVector.x * farHeight, upVector.y * farHeight, upVector.z * farHeight), null);
Vector3f farBottom = Vector3f.add(centerFar,
new Vector3f(downVector.x * farHeight, downVector.y * farHeight, downVector.z * farHeight), null);
Vector3f nearTop = Vector3f.add(centerNear,
new Vector3f(upVector.x * nearHeight, upVector.y * nearHeight, upVector.z * nearHeight), null);
Vector3f nearBottom = Vector3f.add(centerNear,
new Vector3f(downVector.x * nearHeight, downVector.y * nearHeight, downVector.z * nearHeight), null);
Vector4f[] points = new Vector4f[8];
points[0] = calculateLightSpaceFrustumCorner(farTop, rightVector, farWidth);
points[1] = calculateLightSpaceFrustumCorner(farTop, leftVector, farWidth);
points[2] = calculateLightSpaceFrustumCorner(farBottom, rightVector, farWidth);
points[3] = calculateLightSpaceFrustumCorner(farBottom, leftVector, farWidth);
points[4] = calculateLightSpaceFrustumCorner(nearTop, rightVector, nearWidth);
points[5] = calculateLightSpaceFrustumCorner(nearTop, leftVector, nearWidth);
points[6] = calculateLightSpaceFrustumCorner(nearBottom, rightVector, nearWidth);
points[7] = calculateLightSpaceFrustumCorner(nearBottom, leftVector, nearWidth);
return points;
}
示例9: render
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
public void render(List<Light> lights, Camera camera, Vector4f clipPlane) {
prepare();
shader.start();
shader.loadClipPlane(clipPlane);
shader.loadSkyColour(RED, GREEN, BLUE);
shader.loadLights(lights);
shader.loadViewMatrix(camera);
renderer.render(entities, shadowMapRenderer.getToShadowMapSpaceMatrix());
shader.stop();
normalMapRenderer.render(normalMapEntities, clipPlane, lights, camera);
terrainShader.start();
terrainShader.loadClipPlane(clipPlane);
terrainShader.loadSkyColour(RED, GREEN, BLUE);
terrainShader.loadLights(lights);
terrainShader.loadViewMatrix(camera);
terrainRenderer.render(terrains, shadowMapRenderer.getToShadowMapSpaceMatrix());
terrainShader.stop();
skyboxRenderer.render(camera, RED, GREEN, BLUE);
terrains.clear();
entities.clear();
normalMapEntities.clear();
}
示例10: isAbove
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
public Vector4f isAbove(Vector3f pointToCheck) {
float len = (this.length - 2*margin) * wl;
float wid = (Wall.width - 2*margin) * wl;
Vector2f p1 = new Vector2f(this.position.x,this.position.z-margin);
Vector2f p2,p3,p4;
if(isLeftWall()){
p2 = new Vector2f(p1.x + wid, p1.y - wid);
p3 = new Vector2f(p2.x - len, p2.y - len);
p4 = new Vector2f(p1.x - len, p1.y - len);
}
else{
p2 = new Vector2f(p1.x + wid, p1.y + wid);
p3 = new Vector2f(p2.x + len, p2.y - len);
p4 = new Vector2f(p1.x + len, p1.y - len);
}
Vector2f point = new Vector2f(pointToCheck.x,pointToCheck.z);
int x1 = Maths.orientation(p1, p2, point);
int x2 = Maths.orientation(p2, p3, point);
int x3 = Maths.orientation(p3, p4, point);
int x4 = Maths.orientation(p4, p1, point);
Vector4f pointPosition = new Vector4f(x1,x2,x3,x4);
return pointPosition;
}
示例11: copyState
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
public void copyState(Manipulator origin) {
this.accuratePosition = origin.accuratePosition.clone();
this.position = new Vector4f(origin.position);
this.xAxis = new Vector4f(origin.xAxis);
this.yAxis = new Vector4f(origin.yAxis);
this.zAxis = new Vector4f(origin.zAxis);
this.accurateXaxis = origin.accurateXaxis.clone();
this.accurateYaxis = origin.accurateYaxis.clone();
this.accurateZaxis = origin.accurateZaxis.clone();
this.result.load(origin.result);
this.scale.load(origin.scale);
this.accurateResult = new Matrix(origin.accurateResult);
this.accurateScale = new Matrix(origin.accurateScale);
this.accurateRotationX = origin.accurateRotationX;
this.accurateRotationY = origin.accurateRotationY;
this.accurateRotationZ = origin.accurateRotationZ;
this.modified = origin.modified;
}
示例12: drawProtractorGL33
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
public void drawProtractorGL33(Composite3D c3d, GLShader shader, BigDecimal x1c, BigDecimal y1c, BigDecimal z1c, BigDecimal x2c, BigDecimal y2c, BigDecimal z2c, BigDecimal x3c, BigDecimal y3c, BigDecimal z3c) {
GL20.glUniform3f(shader.getUniformLocation("color"), r, g, b); //$NON-NLS-1$
final java.text.DecimalFormat NUMBER_FORMAT2F = new java.text.DecimalFormat(View.NUMBER_FORMAT2F, new DecimalFormatSymbols(MyLanguage.LOCALE));
final float zoom = 1f / c3d.getZoom();
final Vector4f textOrigin = new Vector4f(x1, y1, z1, 1f);
Matrix4f.transform(c3d.getRotation(), textOrigin, textOrigin);
Vector3d va = new Vector3d(x1c, y1c, z1c);
Vector3d vb = new Vector3d(x2c, y2c, z2c);
Vector3d vc = new Vector3d(x3c, y3c, z3c);
vb = Vector3d.sub(va, vb);
vc = Vector3d.sub(va, vc);
double angle = Vector3d.angle(vb, vc);
BigDecimal ang = new BigDecimal(angle);
String angle_s = NUMBER_FORMAT2F.format(ang) + "°"; //$NON-NLS-1$
drawNumberGL33(angle_s, textOrigin.x, textOrigin.y, textOrigin.z, zoom);
}
示例13: checkNormal
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
private GData3 checkNormal(GData3 g3, Matrix4f vport) {
Vertex[] v = triangles.get(g3);
Vector4f n = new Vector4f();
n.setW(1f);
n.setX((v[2].y - v[0].y) * (v[1].z - v[0].z) - (v[2].z - v[0].z) * (v[1].y - v[0].y));
n.setY((v[2].z - v[0].z) * (v[1].x - v[0].x) - (v[2].x - v[0].x) * (v[1].z - v[0].z));
n.setZ((v[2].x - v[0].x) * (v[1].y - v[0].y) - (v[2].y - v[0].y) * (v[1].x - v[0].x));
Matrix4f.transform(vport, n, n);
Vector4f.sub(n, new Vector4f(vport.m03, vport.m13, vport.m23, 0f), n);
if (n.z > 0f ^ Editor3DWindow.getWindow().hasBfcToggle()) {
return new GData3(g3.colourNumber, g3.r, g3.g, g3.b, g3.a, v[0], v[2], v[1], View.DUMMY_REFERENCE, linkedDatFile, g3.isTriangle);
} else {
return null;
}
}
示例14: isShown
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
public void isShown(Matrix4f viewport, ThreadsafeHashMap<GData1, Matrix4f> CACHE_viewByProjection, float zoom) {
if (wasShown) {
return;
}
final Matrix4f M2 = CACHE_viewByProjection.get(parent);
if (M2 == null) {
Matrix4f.mul(viewport, parent.productMatrix, M);
CACHE_viewByProjection.put(parent, M);
} else {
M = M2;
}
// Calculate the real coordinates
Matrix4f.transform(M, A2, A);
Matrix4f.transform(M, B2, B);
Matrix4f.transform(M, C2, C);
Matrix4f.transform(M, D2, D);
N.x = A.y - B.y;
N.y = B.x - A.x;
N.z = 0f;
N.w = 1f;
wasShown = zoom / Vector4f.dot(N, Vector4f.sub(C, A, null)) * Vector4f.dot(N, Vector4f.sub(D, A, null)) > -1e-20f;
}
示例15: adjustTranslate
import org.lwjgl.util.vector.Vector4f; //導入依賴的package包/類
private void adjustTranslate(float old, float zoom2) {
float dx = 0;
float dy = 0;
dx = 0f / viewport_pixel_per_ldu;
dy = 0f / viewport_pixel_per_ldu;
Vector4f xAxis4f_translation = new Vector4f(dx, 0, 0, 1.0f);
Vector4f yAxis4f_translation = new Vector4f(0, dy, 0, 1.0f);
Vector3f xAxis3 = new Vector3f(xAxis4f_translation.x, xAxis4f_translation.y, xAxis4f_translation.z);
Vector3f yAxis3 = new Vector3f(yAxis4f_translation.x, yAxis4f_translation.y, yAxis4f_translation.z);
Matrix4f.load(old_viewport_translation, viewport_translation);
Matrix4f.translate(xAxis3, old_viewport_translation, viewport_translation);
Matrix4f.translate(yAxis3, viewport_translation, viewport_translation);
viewport_translation.m30 = 0f;
if (viewport_translation.m13 > 0f) viewport_translation.m13 = 0f;
if (-viewport_translation.m31 > maxY) viewport_translation.m31 = -maxY;
}