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


Java Matrix4f类代码示例

本文整理汇总了Java中com.jme3.math.Matrix4f的典型用法代码示例。如果您正苦于以下问题:Java Matrix4f类的具体用法?Java Matrix4f怎么用?Java Matrix4f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Matrix4f类属于com.jme3.math包,在下文中一共展示了Matrix4f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: controlRender

import com.jme3.math.Matrix4f; //导入依赖的package包/类
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
    if (!wasMeshUpdated) {
        resetToBind(); // reset morph meshes to bind pose

        Matrix4f[] offsetMatrices = skeleton.computeSkinningMatrices();

        // if hardware skinning is supported, the matrices and weight buffer
        // will be sent by the SkinningShaderLogic object assigned to the shader
        for (int i = 0; i < targets.length; i++) {
            // only update targets with bone-vertex assignments
            if (targets[i].getBuffer(Type.BoneIndex) != null) {
                softwareSkinUpdate(targets[i], offsetMatrices);
            }
        }

        wasMeshUpdated = true;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:SkeletonControl.java

示例2: getOffsetTransform

import com.jme3.math.Matrix4f; //导入依赖的package包/类
/**
 * Stores the skinning transform in the specified Matrix4f.
 * The skinning transform applies the animation of the bone to a vertex.
 * @param m
 */
void getOffsetTransform(Matrix4f m, Quaternion tmp1, Vector3f tmp2, Vector3f tmp3, Matrix3f rotMat) {

    //Computing scale
    Vector3f scale = worldScale.mult(worldBindInverseScale, tmp3);

    //computing rotation
    Quaternion rotate = worldRot.mult(worldBindInverseRot, tmp1);

    //computing translation
    //translation depend on rotation and scale
    Vector3f translate = worldPos.add(rotate.mult(scale.mult(worldBindInversePos, tmp2), tmp2), tmp2);

    //populating the matrix
    m.loadIdentity();
    m.setTransform(translate, scale, rotate.toRotationMatrix(rotMat));

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:Bone.java

示例3: getWorldCoordinates

import com.jme3.math.Matrix4f; //导入依赖的package包/类
/**
 * @see Camera#getWorldCoordinates
 */
public Vector3f getWorldCoordinates(Vector2f screenPosition,
        float zPos, Vector3f store) {
    if (store == null) {
        store = new Vector3f();
    }

    Matrix4f inverseMat = new Matrix4f(viewProjectionMatrix);
    inverseMat.invertLocal();

    store.set(
            (screenPosition.x / getWidth() - viewPortLeft) / (viewPortRight - viewPortLeft) * 2 - 1,
            (screenPosition.y / getHeight() - viewPortBottom) / (viewPortTop - viewPortBottom) * 2 - 1,
            zPos * 2 - 1);

    float w = inverseMat.multProj(store, store);
    store.multLocal(1f / w);

    return store;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:Camera.java

示例4: computeWorldMatrix

import com.jme3.math.Matrix4f; //导入依赖的package包/类
/**
 * Recomputes the matrix returned by {@link Geometry#getWorldMatrix() }.
 * This will require a localized transform update for this geometry.
 */
public void computeWorldMatrix() {
    // Force a local update of the geometry's transform
    checkDoTransformUpdate();

    // Compute the cached world matrix
    cachedWorldMat.loadIdentity();
    cachedWorldMat.setRotationQuaternion(worldTransform.getRotation());
    cachedWorldMat.setTranslation(worldTransform.getTranslation());

    TempVars vars = TempVars.get();
    Matrix4f scaleMat = vars.tempMat4;
    scaleMat.loadIdentity();
    scaleMat.scale(worldTransform.getScale());
    cachedWorldMat.multLocal(scaleMat);
    vars.release();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:Geometry.java

示例5: computeBoundForPoints

import com.jme3.math.Matrix4f; //导入依赖的package包/类
/**
 * Compute bounds from an array of points
 * @param pts
 * @param mat
 * @return 
 */
public static BoundingBox computeBoundForPoints(Vector3f[] pts, Matrix4f mat) {
    Vector3f min = new Vector3f(Vector3f.POSITIVE_INFINITY);
    Vector3f max = new Vector3f(Vector3f.NEGATIVE_INFINITY);
    Vector3f temp = new Vector3f();

    for (int i = 0; i < pts.length; i++) {
        float w = mat.multProj(pts[i], temp);

        temp.x /= w;
        temp.y /= w;
        // Why was this commented out?
        temp.z /= w;

        min.minLocal(temp);
        max.maxLocal(temp);
    }

    Vector3f center = min.add(max).multLocal(0.5f);
    Vector3f extent = max.subtract(min).multLocal(0.5f);
    //Nehon 08/18/2010 : Added an offset to the extend to avoid banding artifacts when the frustum are aligned
    return new BoundingBox(center, extent.x + 2.0f, extent.y + 2.0f, extent.z + 2.5f);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:ShadowUtil.java

示例6: doTransformVerts

import com.jme3.math.Matrix4f; //导入依赖的package包/类
private static void doTransformVerts(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f pos = new Vector3f();

    // offset is given in element units
    // convert to be in component units
    offset *= 3;

    for (int i = 0; i < inBuf.capacity() / 3; i++) {
        pos.x = inBuf.get(i * 3 + 0);
        pos.y = inBuf.get(i * 3 + 1);
        pos.z = inBuf.get(i * 3 + 2);

        transform.mult(pos, pos);

        outBuf.put(offset + i * 3 + 0, pos.x);
        outBuf.put(offset + i * 3 + 1, pos.y);
        outBuf.put(offset + i * 3 + 2, pos.z);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:GeometryBatchFactory.java

示例7: doTransformNorms

import com.jme3.math.Matrix4f; //导入依赖的package包/类
private static void doTransformNorms(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f norm = new Vector3f();

    // offset is given in element units
    // convert to be in component units
    offset *= 3;

    for (int i = 0; i < inBuf.capacity() / 3; i++) {
        norm.x = inBuf.get(i * 3 + 0);
        norm.y = inBuf.get(i * 3 + 1);
        norm.z = inBuf.get(i * 3 + 2);

        transform.multNormal(norm, norm);

        outBuf.put(offset + i * 3 + 0, norm.x);
        outBuf.put(offset + i * 3 + 1, norm.y);
        outBuf.put(offset + i * 3 + 2, norm.z);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:GeometryBatchFactory.java

示例8: setEye

import com.jme3.math.Matrix4f; //导入依赖的package包/类
public void setEye(ChannelHandlerContext ctx, Cmds.SetEye cmd) {
	todo("setEye", (rc)-> {
		CameraNode cam = rc.cam;
		Quaternion rot = toJME(cmd.getRotation());
		cam.setLocalRotation(rot.clone());
		cam.setLocalTranslation(toJME(cmd.getLocation()));
		//if (cmd.hasNear()) cam0.setFrustumNear(cmd.getNear())
		//if (cmd.hasFar()) cam0.setFrustumFar(cmd.getFar())
		if (cmd.hasProjection()) {
			Matrix4f proj = toJME(cmd.getProjection());
			cam.getCamera().setParallelProjection(cmd.getProjMode() == ProjMode.orthographic);
			if (cmd.getProjMode() == ProjMode.orthographic) {
				float[] lr = pairOf(proj.m00, proj.m03);
				float[] bt = pairOf(proj.m11, proj.m13);
				float[] nf = pairOf(-proj.m22, proj.m23);
				cam.getCamera().setFrustum(nf[0], nf[1], lr[0], lr[1], bt[1], bt[0]);
			} else {
				float fovY = 2f * FastMath.RAD_TO_DEG * FastMath.atan(1f / proj.m11);
				float aspect = proj.m11 / proj.m00;
				cam.getCamera().setFrustumPerspective(fovY, aspect, cmd.getNear(), cmd.getFar());
			}
		}
		cam.getCamera().update();
		cam.setEnabled(true);
	});
}
 
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:27,代码来源:ReqHandler.java

示例9: toJME

import com.jme3.math.Matrix4f; //导入依赖的package包/类
public static Matrix4f toJME(Mat4 src) {
	if(src==null)return new Matrix4f();
	Matrix4f dst=new Matrix4f();
	dst.m00=src.getC00();
	dst.m10=src.getC10();
	dst.m20=src.getC20();
	dst.m30=src.getC30();
	dst.m01=src.getC01();
	dst.m11=src.getC11();
	dst.m21=src.getC21();
	dst.m31=src.getC31();
	dst.m02=src.getC02();
	dst.m12=src.getC12();
	dst.m22=src.getC22();
	dst.m32=src.getC32();
	dst.m03=src.getC03();
	dst.m13=src.getC13();
	dst.m23=src.getC23();
	dst.m33=src.getC33();
	return dst;
}
 
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:22,代码来源:PrimitiveExt.java

示例10: changeParent

import com.jme3.math.Matrix4f; //导入依赖的package包/类
/**
 * Changes the parent of a prefab while keeping the world transformation of
 * the prefab.
 * @param toChange the prefab to change.
 * @param newParent the new parent of the prefab.
 * @return the local transformation of the child, relative to the new parent.
 */
public static Matrix4f changeParent(Node toChange, Node newParent) {
    Matrix4f parentMatrix = new Matrix4f();
    parentMatrix.setTranslation(newParent.getWorldTranslation());
    parentMatrix.setRotationQuaternion(newParent.getWorldRotation());
    parentMatrix.setScale(newParent.getWorldScale());
    parentMatrix.invertLocal();

    Vector3f wtrans = toChange.getWorldTranslation().clone();
    Quaternion wrot = toChange.getWorldRotation().clone();
    Vector3f wscale = toChange.getWorldScale().clone();

    Matrix4f childMatrix = new Matrix4f();
    childMatrix.setTranslation(wtrans);
    childMatrix.setRotationQuaternion(wrot);
    childMatrix.setScale(wscale);

    Matrix4f local = parentMatrix.mult(childMatrix);
    return local;
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:27,代码来源:MathUtil.java

示例11: testRotateTranslateRotate

import com.jme3.math.Matrix4f; //导入依赖的package包/类
public void testRotateTranslateRotate() {
	Vector3f v = new Vector3f();
	Transform t1 = new LOrientation(Vector3f.UNIT_Y, (float) -Math.PI / 2).getTransformation(); // 90
	Transform t2 = new LOrientation(new Vector3f(2, 0, 0)).getTransformation(); // 90
	Transform t3 = new LOrientation(Vector3f.UNIT_Y, (float) Math.PI / 2).getTransformation(); // 90

	Matrix4f m1 = t3.toTransformMatrix();
	m1.multLocal(t2.toTransformMatrix());
	m1.multLocal(t1.toTransformMatrix());

	//
	m1.mult(new Vector3f(1, 0, 0), v);

	assertClose(1.0, v.x);
	assertClose(0.0, v.y);
	assertClose(-2.0, v.z);
}
 
开发者ID:CollabThings,项目名称:collabthings,代码行数:18,代码来源:TestTransformation.java

示例12: controlUpdate

import com.jme3.math.Matrix4f; //导入依赖的package包/类
@Override
    protected void controlUpdate(float tpf) {
        for (int i = 0; i < boneMarkArray.length; i++) {
            Matrix4f m = skeletonControl.getOffsetMatrices()[i].clone();
            PMDBone bone = boneArray[i];
//            if (bone.getBoneName().equals("右腕")) {
            //            Matrix4f m2 = boneMarkArray[i].getLocalToWorldMatrix(new Matrix4f()).clone();
            //            m.invertLocal();
            //            m.loadIdentity();
            Vector3f bonePos = new Vector3f(bone.getBoneHeadPos().x,
                    bone.getBoneHeadPos().y,
                    bone.getBoneHeadPos().z);
//                System.out.println("projectionMatrix = "+projectionMatrix);
//                System.out.println("bonePos1 = "+bonePos);
            m.mult(bonePos, bonePos);
//                System.out.println("bonePos2 = "+bonePos);
            Transform t = new Transform(m.toTranslationVector());
            cam.getScreenCoordinates(bonePos, bonePos);
//                System.out.println("bonePos3 = "+bonePos);
            t.setTranslation(bonePos);
            boneMarkArray[i].setLocalTransform(t);
//            }            
//            System.out.println("m2 = "+m2);
        }
    }
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:26,代码来源:PMDBoneMarkControl.java

示例13: clone

import com.jme3.math.Matrix4f; //导入依赖的package包/类
@Override
public synchronized PMDMesh clone() {
    PMDMesh newMesh = (PMDMesh) super.clone();
    boneMatricesParamIndex = -1;
    newMesh.boneMatrixArray = new Matrix4f[boneMatrixArray.length];
    for (int i = 0; i < newMesh.boneMatrixArray.length; i++) {
        newMesh.boneMatrixArray[i] = new Matrix4f();
    }
    newMesh.setBuffer(getBuffer(VertexBuffer.Type.BoneIndex));
    newMesh.setBuffer(getBuffer(VertexBuffer.Type.TexCoord));
    releaseSoftwareSkinningBufferes();
    FloatBuffer newBoneMatrixBuffer = BufferUtils.createFloatBuffer(boneMatrixBuffer.capacity());
    boneMatrixBuffer.position(0);
    newBoneMatrixBuffer.put(boneMatrixBuffer);
    newBoneMatrixBuffer.position(0);
    newMesh.setBoneMatrixBuffer(newBoneMatrixBuffer);
    return newMesh;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:19,代码来源:PMDMesh.java

示例14: buildBone

import com.jme3.math.Matrix4f; //导入依赖的package包/类
/**
 * This method builds the bone. It recursively builds the bone's children.
 * 
 * @param bones
 *            a list of bones where the newly created bone will be added
 * @param objectToArmatureMatrix
 *            object to armature transformation matrix
 * @param blenderContext
 *            the blender context
 * @return newly created bone
 */
public Bone buildBone(List<Bone> bones, Matrix4f objectToArmatureMatrix, BlenderContext blenderContext) {
    Long boneOMA = boneStructure.getOldMemoryAddress();
    bone = new Bone(boneName);
    bones.add(bone);
    blenderContext.addLoadedFeatures(boneOMA, boneName, boneStructure, bone);

    Vector3f poseLocation = restMatrix.toTranslationVector();
    Quaternion rotation = restMatrix.toRotationQuat().normalizeLocal();
    Vector3f scale = restMatrix.toScaleVector();
    if (parent == null) {
        Quaternion rotationQuaternion = objectToArmatureMatrix.toRotationQuat().normalizeLocal();
        scale.multLocal(objectToArmatureMatrix.toScaleVector());
        rotationQuaternion.multLocal(poseLocation.addLocal(objectToArmatureMatrix.toTranslationVector()));
        rotation.multLocal(rotationQuaternion);
    }

    bone.setBindTransforms(poseLocation, rotation, scale);
    for (BoneContext child : children) {
        bone.addChild(child.buildBone(bones, objectToArmatureMatrix, blenderContext));
    }

    return bone;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:35,代码来源:BoneContext.java

示例15: doTransformVerts

import com.jme3.math.Matrix4f; //导入依赖的package包/类
private void doTransformVerts(FloatBuffer inBuf, int offset, int start, int end, FloatBuffer outBuf, Matrix4f transform) {
    TempVars vars = TempVars.get();
    Vector3f pos = vars.vect1;

    // offset is given in element units
    // convert to be in component units
    offset *= 3;

    for (int i = start; i < end; i++) {
        pos.x = inBuf.get(i * 3 + 0);
        pos.y = inBuf.get(i * 3 + 1);
        pos.z = inBuf.get(i * 3 + 2);

        transform.mult(pos, pos);

        outBuf.put(offset + i * 3 + 0, pos.x);
        outBuf.put(offset + i * 3 + 1, pos.y);
        outBuf.put(offset + i * 3 + 2, pos.z);
    }
    vars.release();
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:22,代码来源:GeometryBatch.java


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