Java Code Examples for com.badlogic.gdx.math.Vector3#nor()
The following examples show how to use
com.badlogic.gdx.math.Vector3#nor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Terrain.java From Mundus with Apache License 2.0 | 6 votes |
/** * Get Normal at x,y point of terrain * * @param x * the x coord on terrain * @param y * the y coord on terrain( actual z) * @return the normal at the point of terrain */ public Vector3 getNormalAt(int x, int y) { Vector3 out = new Vector3(); // handle edges of terrain int xP1 = (x + 1 >= vertexResolution) ? vertexResolution - 1 : x + 1; int yP1 = (y + 1 >= vertexResolution) ? vertexResolution - 1 : y + 1; int xM1 = (x - 1 < 0) ? 0 : x - 1; int yM1 = (y - 1 < 0) ? 0 : y - 1; float hL = heightData[y * vertexResolution + xM1]; float hR = heightData[y * vertexResolution + xP1]; float hD = heightData[yM1 * vertexResolution + x]; float hU = heightData[yP1 * vertexResolution + x]; out.x = hL - hR; out.y = 2; out.z = hD - hU; out.nor(); return out; }
Example 2
Source File: GameScene.java From GdxDemo3D with Apache License 2.0 | 5 votes |
public void setToSceneCamera(GhostCamera camera) { Vector3 direction = new Vector3(V3_DOWN); direction.rotate(Vector3.X, sceneCamera.rotation.x); direction.rotate(Vector3.Z, sceneCamera.rotation.z); direction.rotate(Vector3.Y, sceneCamera.rotation.y); direction.nor(); camera.fieldOfView = sceneCamera.fov; camera.targetPosition.set(sceneCamera.position); camera.targetDirection.set(direction); camera.targetUp.set(Vector3.Y); camera.snapToTarget(); camera.update(); }
Example 3
Source File: BlockChest.java From Cubes with MIT License | 5 votes |
@Override public Integer place(World world, int x, int y, int z, int meta, Player player, BlockIntersection intersection) { Vector3 pos = player.position.cpy(); pos.sub(x, y, z); pos.nor(); BlockFace blockFace = VectorUtil.directionXZ(pos); if (blockFace == BlockFace.negX) { return 1; } else if (blockFace == BlockFace.posZ) { return 2; } else if (blockFace == BlockFace.negZ) { return 3; } return 0; }
Example 4
Source File: Tools.java From gdx-proto with Apache License 2.0 | 4 votes |
public static void calculateRectFaceNormal(Vector3 norm, Vector3 a, Vector3 b) { a.nor(); b.nor(); norm.set(b).crs(a).nor(); }