本文整理汇总了Java中org.lwjgl.util.vector.Matrix4f.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4f.transform方法的具体用法?Java Matrix4f.transform怎么用?Java Matrix4f.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.util.vector.Matrix4f
的用法示例。
在下文中一共展示了Matrix4f.transform方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.lwjgl.util.vector.Matrix4f; //导入方法依赖的package包/类
public void update(){
viewDistance.update();
prevPos.set(pos);
MOVE.set(0, 0, 0);
if(Keyboard.isKeyDown(Keyboard.KEY_D)) MOVE.addX(1);
if(Keyboard.isKeyDown(Keyboard.KEY_A)) MOVE.addX(-1);
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)) MOVE.addY(1);
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) MOVE.addY(-1);
if(Keyboard.isKeyDown(Keyboard.KEY_S)) MOVE.addZ(1);
if(Keyboard.isKeyDown(Keyboard.KEY_W)) MOVE.addZ(-1);
Vector4f vec4=new Vector4f(MOVE.x, MOVE.y, MOVE.z, 1);
Matrix4f mat=new Matrix4f();
EFF_POS.set(rot).mul(-1);
EFF_POS.x=0;
MatrixUtil.rotate(mat, EFF_POS);
Matrix4f.transform(mat, vec4, vec4);
MOVE.x=vec4.x;
MOVE.y=vec4.y;
MOVE.z=vec4.z;
// MOVE.mul(100);
// if(EntityCrazyCube.CAM!=null&&false){
// pos.set(EntityCrazyCube.CAM.pos);
// }else
pos.add(MOVE);
viewDistance.setValue((viewDistance.getValue()+viewDistanceWanted)/2);
}
示例2: rotateScale
import org.lwjgl.util.vector.Matrix4f; //导入方法依赖的package包/类
private void rotateScale(Vector3f position, Vector3f rotationOrigin, Matrix4f rotationMatrix, Vector3f scale)
{
Vector4f vector4f = new Vector4f(position.x - rotationOrigin.x, position.y - rotationOrigin.y, position.z - rotationOrigin.z, 1.0F);
Matrix4f.transform(rotationMatrix, vector4f, vector4f);
vector4f.x *= scale.x;
vector4f.y *= scale.y;
vector4f.z *= scale.z;
position.set(vector4f.x + rotationOrigin.x, vector4f.y + rotationOrigin.y, vector4f.z + rotationOrigin.z);
}
示例3: 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;
}
示例4: readPositions
import org.lwjgl.util.vector.Matrix4f; //导入方法依赖的package包/类
private void readPositions() {
String positionsId = meshData.getChild("vertices").getChild("input").getAttribute("source").substring(1);
XmlNode positionsData = meshData.getChildWithAttribute("source", "id", positionsId).getChild("float_array");
int count = Integer.parseInt(positionsData.getAttribute("count"));
String[] posData = positionsData.getData().split(" ");
for (int i = 0; i < count/3; i++) {
float x = Float.parseFloat(posData[i * 3]);
float y = Float.parseFloat(posData[i * 3 + 1]);
float z = Float.parseFloat(posData[i * 3 + 2]);
Vector4f position = new Vector4f(x, y, z, 1);
Matrix4f.transform(CORRECTION, position, position);
vertices.add(new Vertex(vertices.size(), new Vector3f(position.x, position.y, position.z), vertexWeights.get(vertices.size())));
}
}
示例5: readNormals
import org.lwjgl.util.vector.Matrix4f; //导入方法依赖的package包/类
private void readNormals() {
String normalsId = meshData.getChild("polylist").getChildWithAttribute("input", "semantic", "NORMAL")
.getAttribute("source").substring(1);
XmlNode normalsData = meshData.getChildWithAttribute("source", "id", normalsId).getChild("float_array");
int count = Integer.parseInt(normalsData.getAttribute("count"));
String[] normData = normalsData.getData().split(" ");
for (int i = 0; i < count/3; i++) {
float x = Float.parseFloat(normData[i * 3]);
float y = Float.parseFloat(normData[i * 3 + 1]);
float z = Float.parseFloat(normData[i * 3 + 2]);
Vector4f norm = new Vector4f(x, y, z, 0f);
Matrix4f.transform(CORRECTION, norm, norm);
normals.add(new Vector3f(norm.x, norm.y, norm.z));
}
}
示例6: convertToScreenSpace
import org.lwjgl.util.vector.Matrix4f; //导入方法依赖的package包/类
private Vector2f convertToScreenSpace(Vector3f worldPos, Matrix4f viewMat, Matrix4f projectionMat) {
Vector4f coords = new Vector4f(worldPos.x, worldPos.y, worldPos.z, 1f);
Matrix4f.transform(viewMat, coords, coords);
Matrix4f.transform(projectionMat, coords, coords);
if (coords.w <= 0) {
return null;
}
//no need for conversion below
return new Vector2f(coords.x / coords.w, coords.y / coords.w);
}
示例7: 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);
}