本文整理匯總了Java中org.lwjgl.util.vector.Matrix4f.mul方法的典型用法代碼示例。如果您正苦於以下問題:Java Matrix4f.mul方法的具體用法?Java Matrix4f.mul怎麽用?Java Matrix4f.mul使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.util.vector.Matrix4f
的用法示例。
在下文中一共展示了Matrix4f.mul方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processTransforms
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
private void processTransforms(String jointName, String[] rawData, KeyFrameData[] keyFrames, boolean root){
FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
float[] matrixData = new float[16];
for(int i=0;i<keyFrames.length;i++){
for(int j=0;j<16;j++){
matrixData[j] = Float.parseFloat(rawData[i*16 + j]);
}
buffer.clear();
buffer.put(matrixData);
buffer.flip();
Matrix4f transform = new Matrix4f();
transform.load(buffer);
transform.transpose();
if(root){
//because up axis in Blender is different to up axis in game
Matrix4f.mul(CORRECTION, transform, transform);
}
keyFrames[i].addJointTransform(new JointTransformData(jointName, transform));
}
}
示例2: getProjectionViewMatrix
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
@Override
public Matrix4f getProjectionViewMatrix() {
if(reflected){
return Matrix4f.mul(projectionMatrix, reflectedMatrix, null);
}else{
return Matrix4f.mul(projectionMatrix, viewMatrix, null);
}
}
示例3: extractMainJointData
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
private JointData extractMainJointData(XmlNode jointNode, boolean isRoot){
String nameId = jointNode.getAttribute("id");
int index = boneOrder.indexOf(nameId);
String[] matrixData = jointNode.getChild("matrix").getData().split(" ");
Matrix4f matrix = new Matrix4f();
matrix.load(convertData(matrixData));
matrix.transpose();
if(isRoot){
//because in Blender z is up, but in our game y is up.
Matrix4f.mul(CORRECTION, matrix, matrix);
}
jointCount++;
return new JointData(index, nameId, matrix);
}
示例4: getProjectionViewMatrix
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
@Override
public Matrix4f getProjectionViewMatrix() {
if (reflected) {
return Matrix4f.mul(projectionMatrix, reflectedMatrix, null);
} else {
return Matrix4f.mul(projectionMatrix, viewMatrix, null);
}
}
示例5: calculateMvpMatrix
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
private Matrix4f calculateMvpMatrix(Sun sun, ICamera camera) {
Matrix4f modelMatrix = new Matrix4f();
Vector3f sunPos = sun.getWorldPosition(camera.getPosition());
Matrix4f.translate(sunPos, modelMatrix, modelMatrix);
Matrix4f modelViewMat = applyViewMatrix(modelMatrix, camera.getViewMatrix());
Matrix4f.scale(new Vector3f(sun.getScale(), sun.getScale(), sun.getScale()), modelViewMat, modelViewMat);
return Matrix4f.mul(camera.getProjectionMatrix(), modelViewMat, null);
}
示例6: applyViewMatrix
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
/**
* Check the particle tutorial for explanations of this. Basically we remove
* the rotation effect of the view matrix, so that the sun quad is always
* facing the camera.
*
* @param modelMatrix
* @param viewMatrix
* @return The model-view matrix.
*/
private Matrix4f applyViewMatrix(Matrix4f modelMatrix, Matrix4f viewMatrix) {
modelMatrix.m00 = viewMatrix.m00;
modelMatrix.m01 = viewMatrix.m10;
modelMatrix.m02 = viewMatrix.m20;
modelMatrix.m10 = viewMatrix.m01;
modelMatrix.m11 = viewMatrix.m11;
modelMatrix.m12 = viewMatrix.m21;
modelMatrix.m20 = viewMatrix.m02;
modelMatrix.m21 = viewMatrix.m12;
modelMatrix.m22 = viewMatrix.m22;
return Matrix4f.mul(viewMatrix, modelMatrix, null);
}
示例7: updateViewMatrix
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
private void updateViewMatrix() {
viewMatrix.setIdentity();
Matrix4f.rotate((float) Math.toRadians(180), new Vector3f(0, 0, 1), viewMatrix, viewMatrix);
Matrix4f.rotate((float) Math.toRadians(pitch), new Vector3f(1, 0, 0), viewMatrix, viewMatrix);
Matrix4f.rotate((float) Math.toRadians(yaw), new Vector3f(0, 1, 0), viewMatrix, viewMatrix);
Vector3f negativeCameraPos = new Vector3f(-center.x, -center.y, -center.z);
Matrix4f.translate(negativeCameraPos, viewMatrix, viewMatrix);
Matrix4f.mul(projectionMatrix, viewMatrix, projectionViewMatrix);
}
示例8: rotate
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
public static synchronized Matrix4f rotate(Matrix4f mat, Quat4 rot){
rot.quatToMatrix4f(ROT_MAT);
return Matrix4f.mul(mat, ROT_MAT, mat);
//return rotateXYZ(mat, new Vec3f().set(rot));
}
示例9: getProjectionViewMatrix
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
@Override
public Matrix4f getProjectionViewMatrix() {
return Matrix4f.mul(projectionMatrix, viewMatrix, null);
}
示例10: getProjectionViewMatrix
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
@Override
public Matrix4f getProjectionViewMatrix() {
// TODO Auto-generated method stub
return Matrix4f.mul(projectionMatrix, viewMatrix, null);
}
示例11: applyPoseToJoints
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
/**
* This is the method where the animator calculates and sets those all-
* important "joint transforms" that I talked about so much in the tutorial.
*
* This method applies the current pose to a given joint, and all of its
* descendants. It does this by getting the desired local-transform for the
* current joint, before applying it to the joint. Before applying the
* transformations it needs to be converted from local-space to model-space
* (so that they are relative to the model's origin, rather than relative to
* the parent joint). This can be done by multiplying the local-transform of
* the joint with the model-space transform of the parent joint.
*
* The same thing is then done to all the child joints.
*
* Finally the inverse of the joint's bind transform is multiplied with the
* model-space transform of the joint. This basically "subtracts" the
* joint's original bind (no animation applied) transform from the desired
* pose transform. The result of this is then the transform required to move
* the joint from its original model-space transform to it's desired
* model-space posed transform. This is the transform that needs to be
* loaded up to the vertex shader and used to transform the vertices into
* the current pose.
*
* @param currentPose
* - a map of the local-space transforms for all the joints for
* the desired pose. The map is indexed by the name of the joint
* which the transform corresponds to.
* @param joint
* - the current joint which the pose should be applied to.
* @param parentTransform
* - the desired model-space transform of the parent joint for
* the pose.
*/
private void applyPoseToJoints(Map<String,Matrix4f> currentPose, Joint joint, Matrix4f parentTransform){
Matrix4f currentLocalTransform=currentPose.get(joint.name);
Matrix4f currentTransform=Matrix4f.mul(parentTransform, currentLocalTransform, null);
for(Joint childJoint:joint.children){
applyPoseToJoints(currentPose, childJoint, currentTransform);
}
Matrix4f.mul(currentTransform, joint.getInverseBindTransform(), currentTransform);
joint.setAnimationTransform(currentTransform);
}
示例12: getLocalTransform
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
/**
* In this method the bone-space transform matrix is constructed by
* translating an identity matrix using the position variable and then
* applying the rotation. The rotation is applied by first converting the
* quaternion into a rotation matrix, which is then multiplied with the
* transform matrix.
*
* @return This bone-space joint transform as a matrix. The exact same
* transform as represented by the position and rotation in this
* instance, just in matrix form.
*/
protected Matrix4f getLocalTransform(){
Matrix4f matrix=new Matrix4f();
matrix.translate(position);
Matrix4f.mul(matrix, rotation.toRotationMatrix(), matrix);
return matrix;
}
示例13: calcInverseBindTransform
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
/**
* This is called during set-up, after the joints hierarchy has been
* created. This calculates the model-space bind transform of this joint
* like so: </br>
* </br>
* {@code bindTransform = parentBindTransform * localBindTransform}</br>
* </br>
* where "bindTransform" is the model-space bind transform of this joint,
* "parentBindTransform" is the model-space bind transform of the parent
* joint, and "localBindTransform" is the bone-space bind transform of this
* joint. It then calculates and stores the inverse of this model-space bind
* transform, for use when calculating the final animation transform each
* frame. It then recursively calls the method for all of the children
* joints, so that they too calculate and store their inverse bind-pose
* transform.
*
* @param parentBindTransform
* - the model-space bind transform of the parent joint.
*/
protected void calcInverseBindTransform(Matrix4f parentBindTransform){
Matrix4f bindTransform=Matrix4f.mul(parentBindTransform, localBindTransform, null);
Matrix4f.invert(bindTransform, inverseBindTransform);
for(Joint child:children){
child.calcInverseBindTransform(bindTransform);
}
}
示例14: applyPoseToJoints
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
/**
* This is the method where the animator calculates and sets those all-
* important "joint transforms" that I talked about so much in the tutorial.
*
* This method applies the current pose to a given joint, and all of its
* descendants. It does this by getting the desired local-transform for the
* current joint, before applying it to the joint. Before applying the
* transformations it needs to be converted from local-space to model-space
* (so that they are relative to the model's origin, rather than relative to
* the parent joint). This can be done by multiplying the local-transform of
* the joint with the model-space transform of the parent joint.
*
* The same thing is then done to all the child joints.
*
* Finally the inverse of the joint's bind transform is multiplied with the
* model-space transform of the joint. This basically "subtracts" the
* joint's original bind (no animation applied) transform from the desired
* pose transform. The result of this is then the transform required to move
* the joint from its original model-space transform to it's desired
* model-space posed transform. This is the transform that needs to be
* loaded up to the vertex shader and used to transform the vertices into
* the current pose.
*
* @param currentPose
* - a map of the local-space transforms for all the joints for
* the desired pose. The map is indexed by the name of the joint
* which the transform corresponds to.
* @param joint
* - the current joint which the pose should be applied to.
* @param parentTransform
* - the desired model-space transform of the parent joint for
* the pose.
*/
private void applyPoseToJoints(Map<String, Matrix4f> currentPose, Joint joint, Matrix4f parentTransform) {
Matrix4f currentLocalTransform = currentPose.get(joint.name);
Matrix4f currentTransform = Matrix4f.mul(parentTransform, currentLocalTransform, null);
for (Joint childJoint : joint.children) {
applyPoseToJoints(currentPose, childJoint, currentTransform);
}
Matrix4f.mul(currentTransform, joint.getInverseBindTransform(), currentTransform);
joint.setAnimationTransform(currentTransform);
}
示例15: getLocalTransform
import org.lwjgl.util.vector.Matrix4f; //導入方法依賴的package包/類
/**
* In this method the bone-space transform matrix is constructed by
* translating an identity matrix using the position variable and then
* applying the rotation. The rotation is applied by first converting the
* quaternion into a rotation matrix, which is then multiplied with the
* transform matrix.
*
* @return This bone-space joint transform as a matrix. The exact same
* transform as represented by the position and rotation in this
* instance, just in matrix form.
*/
protected Matrix4f getLocalTransform() {
Matrix4f matrix = new Matrix4f();
matrix.translate(position);
Matrix4f.mul(matrix, rotation.toRotationMatrix(), matrix);
return matrix;
}