當前位置: 首頁>>代碼示例>>Java>>正文


Java Mat4.transform方法代碼示例

本文整理匯總了Java中ch.fhnw.util.math.Mat4.transform方法的典型用法代碼示例。如果您正苦於以下問題:Java Mat4.transform方法的具體用法?Java Mat4.transform怎麽用?Java Mat4.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.fhnw.util.math.Mat4的用法示例。


在下文中一共展示了Mat4.transform方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: projectToScreen

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
public static Vec3 projectToScreen(Mat4 viewProjMatrix, Viewport viewport, Vec4 v) {
	Vec4 proj = viewProjMatrix.transform(v);

	if (proj.w == 0)
		return null;

	// map x, y and z to range [0, 1]
	float x = 0.5f * (proj.x / proj.w + 1);
	float y = 0.5f * (proj.y / proj.w + 1);
	float z = 0.5f * (proj.z / proj.w + 1);

	// map x and y to viewport
	x = x * viewport.w + viewport.x;
	y = y * viewport.h + viewport.y;
	return new Vec3(x, y, z);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:17,代碼來源:ProjectionUtilities.java

示例2: unprojectFromScreen

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
public static Vec3 unprojectFromScreen(Mat4 viewProjInvMatrix, Viewport viewport, Vec3 v) {
	// map x and y from window coordinates
	float x = (v.x - viewport.x) / viewport.w;
	float y = (v.y - viewport.y) / viewport.h;
	float z = v.z;

	// map to range -1 to 1
	x = x * 2 - 1;
	y = y * 2 - 1;
	z = z * 2 - 1;

	Vec4 result = viewProjInvMatrix.transform(new Vec4(x, y, z, 1));

	if (result.w == 0) {
		return null;
	}

	return new Vec3(result.x / result.w, result.y / result.w, result.z / result.w);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:20,代碼來源:ProjectionUtilities.java

示例3: getTransformedGeometryData

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
@Override
public float[][] getTransformedGeometryData() {
	float[][] src = geometry.getData();
	float[][] dst = new float[src.length][];
	IGeometryAttribute[] attrs = geometry.getAttributes();
	Mat4 tp = Mat4.multiply(Mat4.translate(position), transform);
	dst[0] = tp.transform(src[0]);
	for (int i = 1; i < src.length; ++i) {
		if (attrs[i].equals(IGeometry.NORMAL_ARRAY)) {
			Mat3 tn = new Mat3(tp).inverse().transpose();
			dst[i] = tn.transform(src[i]);
		} else {
			dst[i] = Arrays.copyOf(src[i], src[i].length);
		}
	}
	return dst;
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:18,代碼來源:DefaultMesh.java

示例4: projectToDevice

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
public static Vec3 projectToDevice(Mat4 viewProjMatrix, Vec4 v) {
	Vec4 proj = viewProjMatrix.transform(v);

	if (proj.w == 0)
		return null;

	// map x, y and z to range [-1, 1]
	float x = proj.x / proj.w;
	float y = proj.y / proj.w;
	float z = proj.z / proj.w;

	return new Vec3(x, y, z);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:14,代碼來源:ProjectionUtilities.java

示例5: addToAzimuth

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
/**
 * Orbit around target with camera orbit axis. Positive value orbits
 * counter-clock-wise around axis.
 * 
 * @param delta
 *            relative angle in degrees
 */
public void addToAzimuth(float delta) {
	Mat4 m = Mat4.multiply(Mat4.translate(camera.getTarget()), Mat4.rotate(delta, camera.getCameraOrbitAxis()),
			Mat4.translate(camera.getTarget().negate()));

	Vec3 p = m.transform(camera.getPosition());
	Vec3 u = m.transform(camera.getPosition().add(camera.getUp())).subtract(p);

	camera.setPosition(p);
	camera.setUp(u);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:18,代碼來源:DefaultCameraControl.java

示例6: addToElevation

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
/**
 * Orbit around target on camera-x axis. Positive value orbits clock-wise
 * around camera-x axis, i.e. moves camera "up"
 * 
 * @param delta
 *            relative angle in degrees
 */
public void addToElevation(float delta) {
	Mat4 m = Mat4.multiply(Mat4.translate(camera.getTarget()), Mat4.rotate(-delta, camera.getCameraXAxis()),
			Mat4.translate(camera.getTarget().negate()));

	Vec3 p = m.transform(camera.getPosition());
	Vec3 u = m.transform(camera.getPosition().add(camera.getUp())).subtract(p);

	if (KEEP_ROT_X_POSITIVE && Vec3.Z.dot(u) < 0)
		return;

	camera.setPosition(p);
	camera.setUp(u);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:21,代碼來源:DefaultCameraControl.java

示例7: transform

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
/**
 * Returns a new polygon, with all vertices transformed by matrix m.
 */
public Polygon transform(Mat4 m) {
	Vec3[] v = new Vec3[vertices.length];
	for (int i = 0; i < vertices.length; ++i)
		v[i] = m.transform(vertices[i]);
	Vec3 n = calculateNormal(v);
	float[] t = triangles != null ? m.transform(triangles) : null;
	return new Polygon(v, n, t);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:12,代碼來源:Polygon.java

示例8: animate

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
private void animate(double time, double interval) {
	if (!animationRunning || currentPath == null)
		return;

	float t = (float)(time - animationStart) * SPEED / currentPath.getNumNodes();
	
	if (t >= 1) {
		t = 0;
		animationStart = time;
		currentPath = loopPath;
	}
	
	DefaultCameraControl dcc = new DefaultCameraControl(controller.getCamera(controller.getViews().get(0)));
	Vec3 p = currentPath.position(t);
	Vec3 v = currentPath.velocity(t);
	
	Vec3 newD = lastCameraDirection.scale(1 - CAMERA_DAMP).add(v.normalize().scale(CAMERA_DAMP));
	
	Vec3 c = lastCameraDirection.cross(newD);
	
	float newR = (1 - CAMERA_DAMP) * lastCameraRotation + CAMERA_DAMP * (-c.z * CAMREA_ROT_SCALE);
	
	Mat4 rot = Mat4.rotate(newR, newD);
	Vec3 up = rot.transform(Vec3.Z);
	
	dcc.setPosition(p);
	dcc.setTarget(p.add(newD));
	dcc.setUp(up);
	
	lastCameraDirection = newD;
	lastCameraRotation = newR;
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:33,代碼來源:CameraPath.java

示例9: getTransformedPositionData

import ch.fhnw.util.math.Mat4; //導入方法依賴的package包/類
@Override
public float[] getTransformedPositionData() {
	Mat4 tp = Mat4.multiply(Mat4.translate(position), transform);
	return tp.transform(geometry.getData()[0]);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:6,代碼來源:DefaultMesh.java


注:本文中的ch.fhnw.util.math.Mat4.transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。