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


Java Matrix4类代码示例

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


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

示例1: setModelMatrix

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
/**
 * Sets the model matrix. The model matrix holds the object's local coordinates.
 *
 * @param modelMatrix
 */
public void setModelMatrix(Matrix4 modelMatrix) {
    mModelMatrix = modelMatrix;//.getFloatValues();
    mVertexShader.setModelMatrix(mModelMatrix);

    mNormalMatrix.setAll(modelMatrix).setToNormalMatrix();
    float[] matrix = mNormalMatrix.getFloatValues();

    mNormalFloats[0] = matrix[0];
    mNormalFloats[1] = matrix[1];
    mNormalFloats[2] = matrix[2];
    mNormalFloats[3] = matrix[4];
    mNormalFloats[4] = matrix[5];
    mNormalFloats[5] = matrix[6];
    mNormalFloats[6] = matrix[8];
    mNormalFloats[7] = matrix[9];
    mNormalFloats[8] = matrix[10];

    mVertexShader.setNormalMatrix(mNormalFloats);
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:25,代码来源:Material.java

示例2: unProject

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
public Vector3 unProject(double x, double y, double z) {
    x = mDefaultViewportWidth - x;
    y = mDefaultViewportHeight - y;

    final double[] in = new double[4], out = new double[4];

    Matrix4 MVPMatrix = getCurrentCamera().getProjectionMatrix().multiply(getCurrentCamera().getViewMatrix());
    MVPMatrix.inverse();

    in[0] = (x / mDefaultViewportWidth) * 2 - 1;
    in[1] = (y / mDefaultViewportHeight) * 2 - 1;
    in[2] = 2 * z - 1;
    in[3] = 1;

    Matrix.multiplyMV(out, 0, MVPMatrix.getDoubleValues(), 0, in, 0);

    if (out[3] == 0)
        return null;

    out[3] = 1 / out[3];
    return new Vector3(out[0] * out[3], out[1] * out[3], out[2] * out[3]);
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:23,代码来源:RajawaliRenderer.java

示例3: transform

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
public void transform(final Matrix4 matrix) {
	mTransformedMin.setAll(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
	mTransformedMax.setAll(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
	
	for(mI=0; mI<8; ++mI) {
		Vector3 o = mPoints[mI];
		Vector3 d = mTmp[mI];
		d.setAll(o);
		d.multiply(matrix);
		
		if(d.x < mTransformedMin.x) mTransformedMin.x = d.x;
		if(d.y < mTransformedMin.y) mTransformedMin.y = d.y;
		if(d.z < mTransformedMin.z) mTransformedMin.z = d.z;
		if(d.x > mTransformedMax.x) mTransformedMax.x = d.x;
		if(d.y > mTransformedMax.y) mTransformedMax.y = d.y;
		if(d.z > mTransformedMax.z) mTransformedMax.z = d.z;
	}
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:19,代码来源:BoundingBox.java

示例4: getViewMatrix

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
@Override
public Matrix4 getViewMatrix() {
    Matrix4 m = super.getViewMatrix();

    if(mTarget != null) {
        mScratchMatrix.identity();
        mScratchMatrix.translate(mTarget.getPosition());
        m.multiply(mScratchMatrix);
    }

    mScratchMatrix.identity();
    mScratchMatrix.rotate(mEmpty.getOrientation());
    m.multiply(mScratchMatrix);

    if(mTarget != null) {
        mScratchVector.setAll(mTarget.getPosition());
        mScratchVector.inverse();

        mScratchMatrix.identity();
        mScratchMatrix.translate(mScratchVector);
        m.multiply(mScratchMatrix);
    }

    return m;
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:26,代码来源:ArcballCamera.java

示例5: update

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
public void update(Matrix4 inverseProjectionView) {
	float[] m = inverseProjectionView.getFloatValues();
	
	mPlanes[0].setComponents(m[Matrix4.M30] - m[Matrix4.M00], m[Matrix4.M31] - m[Matrix4.M01], m[Matrix4.M32] - m[Matrix4.M02], m[Matrix4.M33] - m[Matrix4.M03]);
	mPlanes[1].setComponents(m[Matrix4.M30] + m[Matrix4.M00], m[Matrix4.M31] + m[Matrix4.M01], m[Matrix4.M32] + m[Matrix4.M02], m[Matrix4.M33] + m[Matrix4.M03]);
	mPlanes[2].setComponents(m[Matrix4.M30] + m[Matrix4.M10], m[Matrix4.M31] + m[Matrix4.M11], m[Matrix4.M32] + m[Matrix4.M12], m[Matrix4.M33] + m[Matrix4.M13]);
	mPlanes[3].setComponents(m[Matrix4.M30] - m[Matrix4.M10], m[Matrix4.M31] - m[Matrix4.M11], m[Matrix4.M32] - m[Matrix4.M12], m[Matrix4.M33] - m[Matrix4.M13]);
	mPlanes[4].setComponents(m[Matrix4.M30] - m[Matrix4.M20], m[Matrix4.M31] - m[Matrix4.M21], m[Matrix4.M32] - m[Matrix4.M22], m[Matrix4.M33] - m[Matrix4.M23]);
	mPlanes[5].setComponents(m[Matrix4.M30] + m[Matrix4.M20], m[Matrix4.M31] + m[Matrix4.M21], m[Matrix4.M32] + m[Matrix4.M22], m[Matrix4.M33] + m[Matrix4.M23]);
	
	mPlanes[0].normalize();
	mPlanes[1].normalize();
	mPlanes[2].normalize();
	mPlanes[3].normalize();
	mPlanes[4].normalize();
	mPlanes[5].normalize();
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:18,代码来源:Frustum.java

示例6: matrixToTangoPose

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
/**
 * Converts a transform in Matrix4 format to TangoPoseData.
 */
public static TangoPoseData matrixToTangoPose(Matrix4 transform) {
    // Get translation and rotation components from the transformation matrix.
    Vector3 p = transform.getTranslation();
    Quaternion q = new Quaternion();
    q.fromMatrix(transform);

    TangoPoseData tangoPose = new TangoPoseData();
    double[] t = tangoPose.translation = new double[3];
    t[0] = p.x;
    t[1] = p.y;
    t[2] = p.z;
    double[] r = tangoPose.rotation = new double[4];
    r[0] = q.x;
    r[1] = q.y;
    r[2] = q.z;
    r[3] = q.w;

    return tangoPose;
}
 
开发者ID:inovex,项目名称:tango-ar-navigation-example,代码行数:23,代码来源:ScenePoseCalculator.java

示例7: calculateProjectionMatrix

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
/**
 * Use Tango camera intrinsics to calculate the projection Matrix for the Rajawali scene.
 */
public static Matrix4 calculateProjectionMatrix(int width, int height, double fx, double fy,
                                                double cx, double cy) {
    // Uses frustumM to create a projection matrix taking into account calibrated camera
    // intrinsic parameter.
    // Reference: http://ksimek.github.io/2013/06/03/calibrated_cameras_in_opengl/
    double near = 0.1;
    double far = 100;

    double xScale = near / fx;
    double yScale = near / fy;
    double xOffset = (cx - (width / 2.0)) * xScale;
    // Color camera's coordinates has y pointing downwards so we negate this term.
    double yOffset = -(cy - (height / 2.0)) * yScale;

    double m[] = new double[16];
    Matrix.frustumM(m, 0,
            xScale * -width / 2.0 - xOffset,
            xScale * width / 2.0 - xOffset,
            yScale * -height / 2.0 - yOffset,
            yScale * height / 2.0 - yOffset,
            near, far);
    return new Matrix4(m);
}
 
开发者ID:inovex,项目名称:tango-ar-navigation-example,代码行数:27,代码来源:ScenePoseCalculator.java

示例8: planeFitToTangoWorldPose

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
/**
 * Given a point and a normal in depth camera frame and the device pose in start of service
 * frame at the time the point and normal were acquired, calculate a Pose object which
 * represents the position and orientation of the fitted plane with its Y vector pointing
 * up in the gravity vector, represented in the Tango start of service frame.
 *
 * @param point     Point in depth frame where the plane has been detected.
 * @param normal    Normal of the detected plane.
 * @param tangoPose Device pose with respect to start of service at the time the plane was
 *                  fitted.
 */
public static TangoPoseData planeFitToTangoWorldPose(
        double[] point, double[] normal, TangoPoseData tangoPose, DeviceExtrinsics extrinsics) {
    Matrix4 startServiceTdevice = tangoPoseToMatrix(tangoPose);

    // Calculate the UP vector in the depth frame at the provided measurement pose.
    Vector3 depthUp = TANGO_WORLD_UP.clone();
    startServiceTdevice.clone().multiply(extrinsics.getDeviceTDepthCamera())
            .inverse().rotateVector(depthUp);

    // Calculate the transform in depth frame corresponding to the plane fitting information.
    Matrix4 depthTplane = matrixFromPointNormalUp(point, normal, depthUp);

    // Convert to OpenGL frame.
    Matrix4 tangoWorldTplane = startServiceTdevice.multiply(extrinsics.getDeviceTDepthCamera()).
            multiply(depthTplane);

    return matrixToTangoPose(tangoWorldTplane);
}
 
开发者ID:inovex,项目名称:tango-ar-navigation-example,代码行数:30,代码来源:ScenePoseCalculator.java

示例9: unProject

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
public Vector3 unProject(double x, double y, double z) {
    x = mDefaultViewportWidth - x;
    y = mDefaultViewportHeight - y;

    final double[] in = new double[4], out = new double[4];

    Matrix4 projectionMatrix = getCurrentCamera().getProjectionMatrix().clone();
    Matrix4 MVPMatrix = projectionMatrix.multiply(getCurrentCamera().getViewMatrix());
    MVPMatrix.inverse();

    in[0] = (x / mDefaultViewportWidth) * 2 - 1;
    in[1] = (y / mDefaultViewportHeight) * 2 - 1;
    in[2] = 2 * z - 1;
    in[3] = 1;

    Matrix.multiplyMV(out, 0, MVPMatrix.getDoubleValues(), 0, in, 0);

    if (out[3] == 0)
        return null;

    out[3] = 1 / out[3];
    return new Vector3(out[0] * out[3], out[1] * out[3], out[2] * out[3]);
}
 
开发者ID:godstale,项目名称:VR-Defense-Game,代码行数:24,代码来源:Renderer.java

示例10: addWallMeasurement

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
/**
 * Add a new WallMeasurement.
 * A new cube will be added at the plane position and orientation to represent the measurement.
 */
public synchronized void addWallMeasurement(WallMeasurement wallMeasurement) {
    float[] openGlTWall = wallMeasurement.getPlaneTransform();
    Matrix4 openGlTWallMatrix = new Matrix4(openGlTWall);
    mNewPoseList.add(new Pose(openGlTWallMatrix.getTranslation(),
            new Quaternion().fromMatrix(openGlTWallMatrix).conjugate()));
    mObjectPoseUpdated = true;
}
 
开发者ID:tdb-alcorn,项目名称:defect-party,代码行数:12,代码来源:FloorplanRenderer.java

示例11: createLightViewProjectionMatrix

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
private Matrix4 createLightViewProjectionMatrix(DirectionalLight light) {
	//
	// -- Get the frustum corners in world space
	//
	mCamera.getFrustumCorners(mFrustumCorners, true);
	//
	// -- Get the frustum centroid
	//
	mFrustumCentroid.setAll(0, 0, 0);
	for(int i=0; i<8; i++)
		mFrustumCentroid.add(mFrustumCorners[i]);
	mFrustumCentroid.divide(8.0);
	
	//
	// -- 
	//
	
	BoundingBox lightBox = new BoundingBox(mFrustumCorners);
	double distance = mFrustumCentroid.distanceTo(lightBox.getMin());
	Vector3 lightDirection = light.getDirectionVector().clone();
	lightDirection.normalize();
	Vector3 lightPosition = Vector3.subtractAndCreate(mFrustumCentroid, Vector3.multiplyAndCreate(lightDirection, distance));
          
	//
	// -- 
	//
	
	mLightViewMatrix.setToLookAt(lightPosition, mFrustumCentroid, Vector3.Y);
	
	for(int i=0; i<8; i++)
		mFrustumCorners[i].multiply(mLightViewMatrix);
          
          BoundingBox b = new BoundingBox(mFrustumCorners);
          mLightProjectionMatrix.setToOrthographic(b.getMin().x, b.getMax().x, b.getMin().y, b.getMax().y, -b.getMax().z, -b.getMin().z);

          mLightModelViewProjectionMatrix.setAll(mLightProjectionMatrix);
          mLightModelViewProjectionMatrix.multiply(mLightViewMatrix);
	return mLightModelViewProjectionMatrix;
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:40,代码来源:ShadowMapMaterial.java

示例12: multiply

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
/**
 * Multiplies this {@link Vector3} and the provided 4x4 matrix.
 *
 * @param matrix double[16] representation of a 4x4 matrix.
 *
 * @return A reference to this {@link Vector3} to facilitate chaining.
 */
public Vector3 multiply(final double[] matrix) {
    double vx = x, vy = y, vz = z;
    x = vx * matrix[Matrix4.M00] + vy * matrix[Matrix4.M01] + vz * matrix[Matrix4.M02] + matrix[Matrix4.M03];
    y = vx * matrix[Matrix4.M10] + vy * matrix[Matrix4.M11] + vz * matrix[Matrix4.M12] + matrix[Matrix4.M13];
    z = vx * matrix[Matrix4.M20] + vy * matrix[Matrix4.M21] + vz * matrix[Matrix4.M22] + matrix[Matrix4.M23];
    return this;
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:15,代码来源:Vector3.java

示例13: project

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
/**
 * Multiplies this {@link Vector3} by the provided 4x4 matrix and divides by w.
 * Typically this is used for project/un-project of a {@link Vector3}.
 *
 * @param matrix double[16] array representation of a 4x4 matrix to project with.
 *
 * @return A reference to this {@link Vector3} to facilitate chaining.
 */
public Vector3 project(final double[] matrix) {
    double l_w = x * matrix[Matrix4.M30] + y * matrix[Matrix4.M31] + z * matrix[Matrix4.M32] + matrix[Matrix4.M33];

    return setAll(
        (x * matrix[Matrix4.M00] + y * matrix[Matrix4.M01] + z * matrix[Matrix4.M02] + matrix[Matrix4.M03]) / l_w,
        (x * matrix[Matrix4.M10] + y * matrix[Matrix4.M11] + z * matrix[Matrix4.M12] + matrix[Matrix4.M13]) / l_w,
        (x * matrix[Matrix4.M20] + y * matrix[Matrix4.M21] + z * matrix[Matrix4.M22] + matrix[Matrix4.M23]) / l_w);
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:17,代码来源:Vector3.java

示例14: calculateModelMatrix

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
@Override
public void calculateModelMatrix(final Matrix4 parentMatrix) {
	super.calculateModelMatrix(parentMatrix);

	if(mInverseZScale)
		mMMatrix.scale(1, 1, -1);
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:8,代码来源:SkeletalAnimationChildObject3D.java

示例15: init

import org.rajawali3d.math.Matrix4; //导入依赖的package包/类
private void init(boolean createVBOs) {
	mCamera = new Camera2D();
	mCamera.setProjectionMatrix(0, 0);
	mVPMatrix = new Matrix4();
	
	float[] vertices = new float[] {
			-.5f, .5f, 0,
			.5f, .5f, 0,
			.5f, -.5f, 0,
			-.5f, -.5f, 0
	};
	float[] textureCoords = new float[] {
			0, 1, 1, 1, 1, 0, 0, 0
	};
	float[] normals = new float[] {
			0, 0, 1,
			0, 0, 1,
			0, 0, 1,
			0, 0, 1
	};
	int[] indices = new int[] { 0, 2, 1, 0, 3, 2 };
	
	setData(vertices, normals, textureCoords, null, indices, createVBOs);
	
	vertices = null;
	normals = null;
	textureCoords = null;
	indices = null;
	
	mEnableDepthTest = false;
	mEnableDepthMask = false;
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:33,代码来源:ScreenQuad.java


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