本文整理汇总了Java中org.lwjgl.util.vector.Matrix4f.invert方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4f.invert方法的具体用法?Java Matrix4f.invert怎么用?Java Matrix4f.invert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.util.vector.Matrix4f
的用法示例。
在下文中一共展示了Matrix4f.invert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toWorldCoords
import org.lwjgl.util.vector.Matrix4f; //导入方法依赖的package包/类
private Vector3f toWorldCoords(Vector4f eyeCoords) {
Matrix4f invertedView = Matrix4f.invert(viewMatrix, null);
Vector4f rayWorld = Matrix4f.transform(invertedView, eyeCoords, null);
Vector3f mouseRay = new Vector3f(rayWorld.x, rayWorld.y, rayWorld.z);
mouseRay.normalise();
return mouseRay;
}
示例2: toEyeCoords
import org.lwjgl.util.vector.Matrix4f; //导入方法依赖的package包/类
private Vector4f toEyeCoords(Vector4f clipCoords) {
Matrix4f invertedProjection = Matrix4f.invert(projectionMatrix, null);
Vector4f eyeCoords = Matrix4f.transform(invertedProjection, clipCoords, null);
return new Vector4f(eyeCoords.x, eyeCoords.y, -1f, 0f);
}
示例3: updateMatrices
import org.lwjgl.util.vector.Matrix4f; //导入方法依赖的package包/类
public void updateMatrices(IntBuffer viewport, FloatBuffer modelview, FloatBuffer projection, double widthScale, double heightScale) {
this.viewport = viewport;
this.modelview = modelview;
this.projection = projection;
this.widthScale = widthScale;
this.heightScale = heightScale;
//Get fov and display dimensions
float fov = (float) Math.toDegrees(Math.atan(1.0D / this.projection.get(5)) * 2.0D);
fovY = fov;
displayWidth = this.viewport.get(2);
displayHeight = this.viewport.get(3);
fovX = (float) Math.toDegrees(2.0D * Math.atan((displayWidth / displayHeight) * Math.tan(Math.toRadians(fovY) / 2.0D)));
//Getting modelview vectors
Vector3D ft = new Vector3D(this.modelview.get(12), this.modelview.get(13), this.modelview.get(14));
Vector3D lv = new Vector3D(this.modelview.get(0), this.modelview.get(1), this.modelview.get(2));
Vector3D uv = new Vector3D(this.modelview.get(4), this.modelview.get(5), this.modelview.get(6));
Vector3D fv = new Vector3D(this.modelview.get(8), this.modelview.get(9), this.modelview.get(10));
//Default axes
Vector3D nuv = new Vector3D(0, 1.0D, 0);
Vector3D nlv = new Vector3D(1.0D, 0, 0);
Vector3D nfv = new Vector3D(0, 0, 1.0D);
//Calculate yaw and pitch from modelview
double yaw = Math.toDegrees(Math.atan2(nlv.cross(lv).length(), nlv.dot(lv))) + 180.0D;
if (fv.x < 0.0D) {
yaw = 360.0D - yaw;
}
double pitch = 0.0D;
if ((-fv.y > 0.0D && yaw >= 90.0D && yaw < 270.0D) || (fv.y > 0.0D && !(yaw >= 90.0D && yaw < 270.0D))) {
pitch = Math.toDegrees(Math.atan2(nuv.cross(uv).length(), nuv.dot(uv)));
} else {
pitch = -Math.toDegrees(Math.atan2(nuv.cross(uv).length(), nuv.dot(uv)));
}
lookVec = getRotationVector(yaw, pitch);
//Get modelview matrix and invert it
Matrix4f modelviewMatrix = new Matrix4f();
modelviewMatrix.load(this.modelview.asReadOnlyBuffer());
modelviewMatrix.invert();
//Get frustum position
frustumPos = new Vector3D(modelviewMatrix.m30, modelviewMatrix.m31, modelviewMatrix.m32);
frustum = getFrustum(frustumPos.x, frustumPos.y, frustumPos.z, yaw, pitch, fov, 1.0F, displayWidth / displayHeight);
invFrustum = getFrustum(frustumPos.x, frustumPos.y, frustumPos.z, yaw - 180, -pitch, fov, 1.0F, displayWidth / displayHeight);
//Set view vec
viewVec = getRotationVector(yaw, pitch).normalized();
//Calculate screen border angles
bra = Math.toDegrees(Math.acos((displayHeight * heightScale) / Math.sqrt(displayWidth * widthScale * displayWidth * widthScale + displayHeight * heightScale * displayHeight * heightScale)));
bla = 360 - bra;
tra = bla - 180;
tla = bra + 180;
//Create screen border lines
rb = new Line(displayWidth * this.widthScale, 0, 0, 0, 1, 0);
tb = new Line(0, 0, 0, 1, 0, 0);
lb = new Line(0, 0, 0, 0, 1, 0);
bb = new Line(0, displayHeight * this.heightScale, 0, 1, 0, 0);
}
示例4: 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);
}
}
示例5: 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);
}
}