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


Java Vector3f.mul方法代码示例

本文整理汇总了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();
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:41,代码来源:ShadowCascade.java

示例2: getScale

import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getScale(Vector3f dst)
{
	this.parent.getScale(dst);
	dst.mul(super.scale);
	return dst;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:8,代码来源:DerivedTransform3.java

示例3: getScale

import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getScale(Vector3f dst)
{
	this.parent.getScale(dst);
	dst.mul(super.scale3());
	return dst;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:8,代码来源:DerivedTransform2.java

示例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;
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:63,代码来源:MD5Loader.java


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