本文整理汇总了Java中org.joml.Vector3f.mul方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.mul方法的具体用法?Java Vector3f.mul怎么用?Java Vector3f.mul使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joml.Vector3f
的用法示例。
在下文中一共展示了Vector3f.mul方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.joml.Vector3f; //导入方法依赖的package包/类
/**
*
* @param screen
* @param viewMatrix
* @param light
*/
public void update(Screen screen, Matrix4f viewMatrix, DirectionalLight light) {
float aspectRatio = (float) screen.getWidth() / (float) screen.getHeight();
// Build view matrix for this shadow cascade.
this.projectionViewMatrix.setPerspective(Screen.FOV, aspectRatio, zNear, zFar);
this.projectionViewMatrix.mul(viewMatrix);
// Calculate frustum corners in space
float maxZ = Float.MIN_VALUE;
float minZ = Float.MAX_VALUE;
for (int i = 0; i < FRUSTUM_CORNERS; i++) {
Vector3f corner = this.frustumCorners[i];
corner.set(0, 0, 0);
this.projectionViewMatrix.frustumCorner(i, corner);
this.centr.add(corner);
this.centr.div(8.0f);
minZ = Math.min(minZ, corner.z);
maxZ = Math.max(maxZ, corner.z);
}
Vector3f lightDir = light.getDirection();
Vector3f lightPosInc = new Vector3f().set(lightDir);
float distance = maxZ - minZ;
lightPosInc.mul(distance);
Vector3f lightPos = new Vector3f();
lightPos.set(this.centr);
lightPos.add(lightPosInc);
updateLightViewMatrix(lightDir, lightPos);
updateLightProjectionMatrix();
}
示例2: getScale
import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getScale(Vector3f dst)
{
this.parent.getScale(dst);
dst.mul(super.scale);
return dst;
}
示例3: getScale
import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getScale(Vector3f dst)
{
this.parent.getScale(dst);
dst.mul(super.scale3());
return dst;
}
示例4: generateMesh
import org.joml.Vector3f; //导入方法依赖的package包/类
private static Mesh generateMesh(MD5Model md5Model, MD5Mesh md5Mesh) {
List<AnimVertex> vertices = new ArrayList<>();
List<Integer> indices = new ArrayList<>();
List<MD5Mesh.MD5Vertex> md5Vertices = md5Mesh.getVertices();
List<MD5Mesh.MD5Weight> weights = md5Mesh.getWeights();
List<MD5JointInfo.MD5JointData> joints = md5Model.getJointInfo().getJoints();
for (MD5Mesh.MD5Vertex md5Vertex : md5Vertices) {
AnimVertex vertex = new AnimVertex();
vertices.add(vertex);
vertex.position = new Vector3f();
vertex.textCoords = md5Vertex.getTextCoords();
int startWeight = md5Vertex.getStartWeight();
int numWeights = md5Vertex.getWeightCount();
vertex.jointIndices = new int[numWeights];
Arrays.fill(vertex.jointIndices, -1);
vertex.weights = new float[numWeights];
Arrays.fill(vertex.weights, -1);
for (int i = startWeight; i < startWeight + numWeights; i++) {
MD5Mesh.MD5Weight weight = weights.get(i);
MD5JointInfo.MD5JointData joint = joints.get(weight.getJointIndex());
Vector3f rotatedPos = new Vector3f(weight.getPosition()).rotate(joint.getOrientation());
Vector3f acumPos = new Vector3f(joint.getPosition()).add(rotatedPos);
acumPos.mul(weight.getBias());
vertex.position.add(acumPos);
vertex.jointIndices[i - startWeight] = weight.getJointIndex();
vertex.weights[i - startWeight] = weight.getBias();
}
}
for (MD5Mesh.MD5Triangle tri : md5Mesh.getTriangles()) {
indices.add(tri.getVertex0());
indices.add(tri.getVertex1());
indices.add(tri.getVertex2());
// Normals
AnimVertex v0 = vertices.get(tri.getVertex0());
AnimVertex v1 = vertices.get(tri.getVertex1());
AnimVertex v2 = vertices.get(tri.getVertex2());
Vector3f pos0 = v0.position;
Vector3f pos1 = v1.position;
Vector3f pos2 = v2.position;
Vector3f normal = (new Vector3f(pos2).sub(pos0)).cross(new Vector3f(pos1).sub(pos0));
v0.normal.add(normal);
v1.normal.add(normal);
v2.normal.add(normal);
}
// Once the contributions have been added, normalize the result
for (AnimVertex v : vertices) {
v.normal.normalize();
}
Mesh mesh = createMesh(vertices, indices);
return mesh;
}