当前位置: 首页>>代码示例>>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;未经允许,请勿转载。