本文整理匯總了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);
}