本文整理汇总了Java中com.ra4king.opengl.util.math.Vector3类的典型用法代码示例。如果您正苦于以下问题:Java Vector3类的具体用法?Java Vector3怎么用?Java Vector3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector3类属于com.ra4king.opengl.util.math包,在下文中一共展示了Vector3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: offsetOrientation
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
private void offsetOrientation(Vector3 axis, float angle) {
angle = angle * (float)Math.PI / 180;
axis.normalize().mult((float)Math.sin(angle / 2));
Quaternion offset = new Quaternion(axis.x(), axis.y(), axis.z(), (float)Math.cos(angle / 2));
switch(offsetRelative) {
case MODEL_RELATIVE:
orientation.mult(offset);
break;
case WORLD_RELATIVE:
orientation = offset.mult(orientation);
break;
case CAMERA_RELATIVE:
Matrix4 camMat = calcLookAtMatrix(resolveCamPosition(), camTarget, new Vector3(0, 1, 0));
Quaternion viewQuat = camMat.toQuaternion();
orientation = new Quaternion(viewQuat).conjugate().mult(offset).mult(viewQuat).mult(orientation);
break;
}
orientation.normalize();
}
示例2: loadCube
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
public static float[] loadCube(Vector3 sideLength, Vector3 center, boolean interleaved, boolean vec4, Matrix4 modelMatrix) {
float[] buffer = vec4 ? (interleaved ? cubeVec4interleaved : cubeVec4) : (interleaved ? cubeVec3interleaved : cubeVec3);
for(int a = 0; a < cubeData.length / 2; a += 3) {
int position = (a / 3) * ((interleaved ? 3 : 0) + (vec4 ? 4 : 3));
Vector4 pos = new Vector4();
if(modelMatrix == null) {
pos.set(center.x() + cubeData[a] * sideLength.x(), center.y() + cubeData[a + 1] * sideLength.y(), center.z() + cubeData[a + 2] * sideLength.z(), 1);
} else {
modelMatrix.mult4(new Vector4(center.x() + cubeData[a] * sideLength.x(), center.y() + cubeData[a + 1] * sideLength.y(), center.z() + cubeData[a + 2] * sideLength.z(), 1), pos);
}
buffer[position + 0] = pos.x();
buffer[position + 1] = pos.y();
buffer[position + 2] = pos.z();
}
return buffer;
}
示例3: loadPlane
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
public static float[] loadPlane(Vector2 sideLength, Vector3 center, boolean interleaved, boolean vec4, Matrix4 modelMatrix) {
float[] buffer = vec4 ? (interleaved ? planeVec4interleaved : planeVec4) : (interleaved ? planeVec3interleaved : planeVec3);
for(int a = 0; a < planeData.length / 2; a += 3) {
int position = (a / 3) * ((interleaved ? 3 : 0) + (vec4 ? 4 : 3));
Vector4 pos = new Vector4();
if(modelMatrix == null) {
pos.set(center.x() + cubeData[a] * sideLength.x(), center.y() + cubeData[a + 1] * sideLength.y(), center.z() + cubeData[a + 2], 1);
} else {
modelMatrix.mult4(new Vector4(center.x() + cubeData[a] * sideLength.x(), center.y() + cubeData[a + 1] * sideLength.y(), center.z() + cubeData[a + 2], 1), pos);
}
buffer[position + 0] = pos.x();
buffer[position + 1] = pos.y();
buffer[position + 2] = pos.z();
}
return buffer;
}
示例4: isRectPrismInsideFrustum
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
public boolean isRectPrismInsideFrustum(Vector3 corner, float width, float height, float depth) {
for(Plane p : Plane.values) {
if(distanceFromPoint(p, corner) >= 0)
continue;
if(distanceFromPoint(p, new Vector3(corner).add(width, 0, 0)) >= 0)
continue;
if(distanceFromPoint(p, new Vector3(corner).add(0, height, 0)) >= 0)
continue;
if(distanceFromPoint(p, new Vector3(corner).add(0, 0, depth)) >= 0)
continue;
if(distanceFromPoint(p, new Vector3(corner).add(width, height, 0)) >= 0)
continue;
if(distanceFromPoint(p, new Vector3(corner).add(width, 0, depth)) >= 0)
continue;
if(distanceFromPoint(p, new Vector3(corner).add(0, height, depth)) >= 0)
continue;
if(distanceFromPoint(p, new Vector3(corner).add(width, height, depth)) >= 0)
continue;
return false;
}
return true;
}
示例5: render
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
private void render(MatrixStack matrixStack, float angle, int curDepth, FloatBuffer buffer) {
float radius = (float)Math.pow(pow, getDepth() - curDepth + change * timePassed / SPLIT_TIME) / SIZE_CONSTANT;
matrixStack.getTop().translate(0, radius, 0);
try {
buffer.put(PolygonLoader.loadPlane(new Vector2(0.1f, 2 * radius), new Vector3(0, 0, 0), true, false, matrixStack.getTop()));
} catch(Exception exc) {
System.out.println(getDepth() + " " + getTotal() + " " + (getTotal() * 72) + " " + buffer.capacity());
throw exc;
}
matrixStack.getTop().translate(0, radius, 0);
if(curDepth < getDepth() && curDepth < MAX_DEPTH) {
matrixStack.pushMatrix();
matrixStack.getTop().rotate((float)(-Math.PI / 2 + angle), 0, 0, 1);
render(matrixStack, angle, curDepth + 1, buffer);
matrixStack.popMatrix();
matrixStack.pushMatrix();
matrixStack.getTop().rotate(angle, 0, 0, 1);
render(matrixStack, angle, curDepth + 1, buffer);
matrixStack.popMatrix();
}
}
示例6: intersects
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
public boolean intersects(Vector3 position, Vector3 delta) {
Vector3 prevPos = new Vector3(position).sub(delta);
Vector3 normal = orientation.mult3(Vector3.FORWARD, new Vector3()).normalize();
float t = new Vector3(this.position).sub(prevPos).dot(normal) / delta.dot(normal);
if(t < 0f || t > 1f) {
return false;
}
Vector3 intersection = new Vector3(delta).mult(t).add(prevPos).sub(this.position);
Quaternion inverse = new Quaternion(orientation).inverse();
Vector3 offset = inverse.mult3(intersection, intersection);
offset.mult(2.0f).sub(new Vector3(size, 0.0f)).divide(new Vector3(size, 1.0f));
return offset.dot(offset) <= 1.0f; // oval portal
// rectangular portal
// return offset.x() >= 0f && offset.x() < size.x() &&
// offset.y() > 0f && offset.y() < size.y();
}
示例7: main
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
public static void main(String[] args) {
Vector3 v = new Vector3(1, 2, 3);
System.out.println(v.toString());
Vector3[] array = {
new Vector3(2, 3, 4),
new Vector3(3, 4, 5),
new Vector3(4, 5, 6)
};
for(int a = 0; a < array.length; a++) {
System.out.println(array[a].toString());
}
Test1 test1 = new Test1();
Test2 test2 = test1.new Test2();
test2.myMethod();
System.out.println(test1.v.toString());
}
示例8: update
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
@Override
public void update(long deltaTime) {
float speed = 90 * deltaTime / (float)1e9;
if(Keyboard.isKeyDown(Keyboard.KEY_W))
offsetOrientation(new Vector3(1, 0, 0), speed);
if(Keyboard.isKeyDown(Keyboard.KEY_S))
offsetOrientation(new Vector3(1, 0, 0), -speed);
if(Keyboard.isKeyDown(Keyboard.KEY_A))
offsetOrientation(new Vector3(0, 0, 1), speed);
if(Keyboard.isKeyDown(Keyboard.KEY_D))
offsetOrientation(new Vector3(0, 0, 1), -speed);
if(Keyboard.isKeyDown(Keyboard.KEY_Q))
offsetOrientation(new Vector3(0, 1, 0), speed);
if(Keyboard.isKeyDown(Keyboard.KEY_E))
offsetOrientation(new Vector3(0, 1, 0), -speed);
}
示例9: getSphereOrbitPosition
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
private Vector3 getSphereOrbitPosition(MatrixStack modelMatrix, Vector3 orbitCenter, Vector3 orbitAxis, float orbitRadius, float orbitAlpha) {
modelMatrix.pushMatrix();
try {
modelMatrix.getTop().translate(orbitCenter);
modelMatrix.getTop().rotateDeg(360 * orbitAlpha, orbitAxis);
Vector3 offsetDir = orbitAxis.copy().cross(new Vector3(0, 1, 0));
if(offsetDir.length() < 0.001f)
offsetDir = orbitAxis.copy().cross(new Vector3(1, 0, 0));
offsetDir.normalize();
modelMatrix.getTop().translate(offsetDir.mult(orbitRadius));
return new Vector3(modelMatrix.getTop().mult(new Vector4(0, 0, 0, 1)));
} finally {
modelMatrix.popMatrix();
}
}
示例10: setupRotateAxis
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
private void setupRotateAxis(Matrix4 m) {
float angle = computeAngle(2);
float cos = (float)Math.cos(angle);
float sin = (float)Math.sin(angle);
float invCos = 1 - cos;
Vector3 v = new Vector3(1, 1, 1).normalize();
m.clearToIdentity()
.put(0, v.x() * v.x() + (1 - v.x() * v.x()) * cos)
.put(4, v.x() * v.y() * invCos - v.z() * sin)
.put(8, v.x() * v.z() * invCos + v.y() * sin)
.put(1, v.y() * v.x() * invCos + v.z() * sin)
.put(5, v.y() * v.y() + (1 - v.y() * v.y()) * cos)
.put(9, v.y() * v.z() * invCos - v.x() * sin)
.put(2, v.z() * v.x() * invCos - v.y() * sin)
.put(6, v.z() * v.y() * invCos + v.x() * sin)
.put(10, v.z() * v.z() + (1 - v.z() * v.z()) * cos)
.put(12, 5)
.put(13, -5)
.put(14, -25);
}
示例11: drawWrist
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
private void drawWrist(MatrixStack modelToCameraStack) {
modelToCameraStack.pushMatrix();
modelToCameraStack.getTop().translate(posWrist);
modelToCameraStack.getTop().rotate(angleWristRoll * (float)Math.PI / 180, 0, 0, 1);
modelToCameraStack.getTop().rotate(angleWristPitch * (float)Math.PI / 180, 1, 0, 0);
modelToCameraStack.pushMatrix();
modelToCameraStack.getTop().scale(new Vector3(widthWrist / 2, widthWrist / 2, lenWrist / 2));
glUniformMatrix4(modelToCameraMatrixUniform, false, modelToCameraStack.getTop().toBuffer());
glDrawElements(GL_TRIANGLES, indices.length, GL_UNSIGNED_SHORT, 0);
modelToCameraStack.popMatrix();
drawFingers(modelToCameraStack);
modelToCameraStack.popMatrix();
}
示例12: drawLowerArm
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
private void drawLowerArm(MatrixStack modelToCameraStack) {
modelToCameraStack.pushMatrix();
modelToCameraStack.getTop().translate(posLowerArm);
modelToCameraStack.getTop().rotate(angleLowerArm * (float)Math.PI / 180, 1, 0, 0);
modelToCameraStack.pushMatrix();
modelToCameraStack.getTop().translate(new Vector3(0, 0, lenLowerArm / 2));
modelToCameraStack.getTop().scale(new Vector3(widthLowerArm / 2, widthLowerArm / 2, lenLowerArm / 2));
glUniformMatrix4(modelToCameraMatrixUniform, false, modelToCameraStack.getTop().toBuffer());
glDrawElements(GL_TRIANGLES, indices.length, GL_UNSIGNED_SHORT, 0);
modelToCameraStack.popMatrix();
drawWrist(modelToCameraStack);
modelToCameraStack.popMatrix();
}
示例13: drawUpperArm
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
private void drawUpperArm(MatrixStack modelToCameraStack) {
modelToCameraStack.pushMatrix();
modelToCameraStack.getTop().rotate(angleUpperArm * (float)Math.PI / 180, 1, 0, 0);
{
modelToCameraStack.pushMatrix();
modelToCameraStack.getTop().translate(new Vector3(0, 0, (sizeUpperArm / 2) - 1));
modelToCameraStack.getTop().scale(new Vector3(1, 1, sizeUpperArm / 2));
glUniformMatrix4(modelToCameraMatrixUniform, false, modelToCameraStack.getTop().toBuffer());
glDrawElements(GL_TRIANGLES, indices.length, GL_UNSIGNED_SHORT, 0);
modelToCameraStack.popMatrix();
}
drawLowerArm(modelToCameraStack);
modelToCameraStack.popMatrix();
}
示例14: calcMatrix
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
@Override
@CopyStruct
public Matrix4 calcMatrix() {
Matrix4 mat = new Matrix4().clearToIdentity();
mat.translate(0, 0, -currView.radius);
Quaternion fullRotation = Utils.angleAxisDeg(currView.degSpinRotation, new Vector3(0, 0, 1)).mult(currView.orient);
mat.mult(fullRotation.toMatrix(new Matrix4()));
mat.translate(new Vector3(currView.targetPos).mult(-1));
return mat;
}
示例15: processXYChange
import com.ra4king.opengl.util.math.Vector3; //导入依赖的package包/类
public void processXYChange(int diffX, int diffY) {
float degXAngleDiff = diffX * viewScale.rotationScale;
float degYAngleDiff = diffY * viewScale.rotationScale;
currView.orient = startDragOrient.copy().mult(Utils.angleAxisDeg(degXAngleDiff, new Vector3(0, 1, 0)));
currView.orient = Utils.angleAxisDeg(degYAngleDiff, new Vector3(1, 0, 0)).mult(currView.orient);
}