org.lwjgl.util.vector.Vector4f Java Examples
The following examples show how to use
org.lwjgl.util.vector.Vector4f.
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: ParametricEmitter.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
public ParametricEmitter(World world, ParametricFunction function, Vector3f position, float area_xy, float area_z, float velocity_u, float velocity_v, float velocity_random_margin, int num_particles, float particles_per_second, Vector4f color, Vector4f delta_color, Vector3f particle_radius, Vector3f growth_rate, float energy, int src_blend_func, int dst_blend_func, TextureKey[] textures, AnimationManager manager) { super(world, position, src_blend_func, dst_blend_func, textures, null, textures.length, manager); this.function = function; this.area_xy = area_xy; this.area_z = area_z; this.velocity_u = velocity_u; this.velocity_v = velocity_v; this.velocity_random_margin = velocity_random_margin; this.num_particles = num_particles; this.particles_per_second = particles_per_second; this.color = color; this.delta_color = delta_color; this.particle_radius = particle_radius; this.growth_rate = growth_rate; this.energy = energy; random = world.getRandom(); register(); }
Example #2
Source File: BalancedParametricEmitter.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
protected int initParticle(ParametricFunction function, float velocity_u, float velocity_v, Vector4f color, Vector4f delta_color, Vector3f particle_radius, Vector3f growth_rate, float energy) { for (int i = 0; i < num_particles; i++) { float u = dist_u*i/(float)num_particles; float v = dist_v*i/(float)num_particles; ParametricParticle particle = new ParametricParticle(function, u, v, 0f, 0f, 0f); Vector3f offset = randomOffset(margin_u, margin_v, 0f); particle.setVelocity(velocity_u + offset.getX(), velocity_v + offset.getY()); particle.setColor(color.getX(), color.getY(), color.getZ(), color.getW()); particle.setDeltaColor(delta_color.getX(), delta_color.getY(), delta_color.getZ(), delta_color.getW()); particle.setRadius(particle_radius.getX(), particle_radius.getY(), particle_radius.getZ()); particle.setGrowthRate(growth_rate.getX(), growth_rate.getY(), growth_rate.getZ()); particle.setEnergy(energy); particle.setType(getWorld().getRandom().nextInt(getTypes())); particle.update(0); add(particle); } return num_particles; }
Example #3
Source File: BlockUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void addNorth(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry) { // final int northId = world.getBlockId(rawChunk.getChunkCoord(), x-1, y, z); // BlockType north = registry.find(northId); BlockType north = world.getBlockType(rawChunk.getChunkCoord(), x-1, y, z); if (!north.isSolid()) { final float lightness = world.getLight(rawChunk.getChunkCoord(), x-1, y, z, LightFace.NorthSouth); MeshUtil.addQuad(mesh, new Vector3f(x, y+1, z), new Vector3f(x, y+1, z+1), new Vector3f(x, y, z+1), new Vector3f(x, y, z), new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a), texture); } }
Example #4
Source File: Fire.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void addEdgeGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry) { int newFrame; if(numTiles > 1 && frame == 0) { Random rand = new Random(); newFrame = rand.nextInt(numTiles)+1; } else { newFrame = frame; } SubTexture randomTexture = new SubTexture(texture.texture, texture.u0, texture.v0+(float)((newFrame-1)*texWidth)/texHeight, texture.u1, texture.v0+(float)(newFrame*texWidth)/texHeight); Mesh mesh = geometry.getMesh(randomTexture.texture, Geometry.MeshType.AlphaTest); Vector4f colour = new Vector4f(1, 1, 1, 1); addFireGeometry(x, y, z, mesh, colour, randomTexture); }
Example #5
Source File: BlockUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void addWest(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry) { // final int westId = world.getBlockId(rawChunk.getChunkCoord(), x, y, z+1); // BlockType west = registry.find(westId); BlockType west = world.getBlockType(rawChunk.getChunkCoord(), x, y, z+1); if (!west.isSolid()) { final float lightness = world.getLight(rawChunk.getChunkCoord(), x, y, z+1, LightFace.EastWest); MeshUtil.addQuad(mesh, new Vector3f(x, y+1, z+1), new Vector3f(x+1, y+1, z+1), new Vector3f(x+1, y, z+1), new Vector3f(x, y, z+1), new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a), texture); } }
Example #6
Source File: DaylightSensor.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void addEdgeGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry) { final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.Top, rawChunk, x, y, z); Vector4f colour = new Vector4f(lightness, lightness, lightness, 1); final float offSet = 1.0f / 16.0f; SubMesh topMesh = new SubMesh(); SubMesh bottomMesh = new SubMesh(); SubMesh.addBlockSimple(bottomMesh, 0, 0, 0, 1, offSet*6, 1, colour, side, null, bottom); // Top topMesh.addQuad(new Vector3f(1, offSet*6, 0), new Vector3f(1, offSet*6, 1), new Vector3f(0, offSet*6, 1), new Vector3f(0, offSet*6, 0), colour, top); topMesh.pushTo(geometry.getMesh(top.texture, Geometry.MeshType.Solid), x, y, z, Rotation.None, 0); bottomMesh.pushTo(geometry.getMesh(bottom.texture, Geometry.MeshType.Solid), x, y, z, Rotation.None, 0); }
Example #7
Source File: BlockUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void addInteriorWest(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry) { final int westId = rawChunk.getBlockId(x, y, z+1); final int westData = rawChunk.getBlockData(x, y, z+1); BlockType west = registry.find(westId, westData); if (!west.isSolid()) { final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.EastWest, rawChunk, x, y, z+1); MeshUtil.addQuad(mesh, new Vector3f(x, y+1, z+1), new Vector3f(x+1, y+1, z+1), new Vector3f(x+1, y, z+1), new Vector3f(x, y, z+1), new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a), texture); } }
Example #8
Source File: CompositePrimitive.java From ldparteditor with MIT License | 6 votes |
private void adjustTranslate(float old, float zoom2) { float dx = 0; float dy = 0; dx = 0f / viewport_pixel_per_ldu; dy = 0f / viewport_pixel_per_ldu; Vector4f xAxis4f_translation = new Vector4f(dx, 0, 0, 1.0f); Vector4f yAxis4f_translation = new Vector4f(0, dy, 0, 1.0f); Vector3f xAxis3 = new Vector3f(xAxis4f_translation.x, xAxis4f_translation.y, xAxis4f_translation.z); Vector3f yAxis3 = new Vector3f(yAxis4f_translation.x, yAxis4f_translation.y, yAxis4f_translation.z); Matrix4f.load(old_viewport_translation, viewport_translation); Matrix4f.translate(xAxis3, old_viewport_translation, viewport_translation); Matrix4f.translate(yAxis3, viewport_translation, viewport_translation); viewport_translation.m30 = 0f; if (viewport_translation.m13 > 0f) viewport_translation.m13 = 0f; if (-viewport_translation.m31 > maxY) viewport_translation.m31 = -maxY; }
Example #9
Source File: Manipulator.java From ldparteditor with MIT License | 6 votes |
public void copyState(Manipulator origin) { this.accuratePosition = origin.accuratePosition.clone(); this.position = new Vector4f(origin.position); this.xAxis = new Vector4f(origin.xAxis); this.yAxis = new Vector4f(origin.yAxis); this.zAxis = new Vector4f(origin.zAxis); this.accurateXaxis = origin.accurateXaxis.clone(); this.accurateYaxis = origin.accurateYaxis.clone(); this.accurateZaxis = origin.accurateZaxis.clone(); this.result.load(origin.result); this.scale.load(origin.scale); this.accurateResult = new Matrix(origin.accurateResult); this.accurateScale = new Matrix(origin.accurateScale); this.accurateRotationX = origin.accurateRotationX; this.accurateRotationY = origin.accurateRotationY; this.accurateRotationZ = origin.accurateRotationZ; this.modified = origin.modified; }
Example #10
Source File: ChorusFlower.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void addEdgeGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry) { final float lightVal = world.getLight(rawChunk.getChunkCoord(), x, y, z, LightFace.Top); Vector4f colour = new Vector4f(lightVal, lightVal, lightVal, 1.0f); final int data = rawChunk.getBlockData(x, y, z); SubTexture tex = null; if(data == 5) tex = dead; else tex = alive; final float offSet = 1.0f / 16.0f; SubMesh flowerMesh = new SubMesh(); SubMesh.addBlock(flowerMesh, offSet*2, offSet*2, 0, offSet*12, offSet*12, offSet*16, colour, tex, tex, tex); // north-south SubMesh.addBlock(flowerMesh, 0, offSet*2, offSet*2, offSet*16, offSet*12, offSet*12, colour, tex, tex, tex); // east-west SubMesh.addBlock(flowerMesh, offSet*2, 0, offSet*2, offSet*12, offSet*16, offSet*12, colour, tex, tex, tex); // up-down flowerMesh.pushTo(geometry.getMesh(tex.texture, Geometry.MeshType.Solid), x, y, z, Rotation.None, 0); }
Example #11
Source File: ProcessingMesh.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void addVertex(Vector3f position, Vector4f colour, float u, float v) { if (numVerts+1 == xPositions.length) ensureCapacity(numVerts + 1024); xPositions[numVerts] = position.x; yPositions[numVerts] = position.y; zPositions[numVerts] = position.z; reds[numVerts] = colour.x; greens[numVerts] = colour.y; blues[numVerts] = colour.z; alphas[numVerts] = colour.w; uCoords[numVerts] = u; vCoords[numVerts] = v; numVerts++; }
Example #12
Source File: Particle.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public Particle(float angle) { Matrix4f rot_matrix = new Matrix4f(); Vector3f axis = new Vector3f(); Vector4f uv_vector = new Vector4f(); Vector4f transform_uv_vector = new Vector4f(); rot_matrix.setIdentity(); axis.set(0f, 0f, 1f); rot_matrix.rotate(angle, axis); uv_vector.set(-.5f, -.5f, 0f, 0f); Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector); u1 = transform_uv_vector.getX() + .5f; v1 = transform_uv_vector.getY() + .5f; uv_vector.set(.5f, -.5f, 0f, 0f); Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector); u2 = transform_uv_vector.getX() + .5f; v2 = transform_uv_vector.getY() + .5f; uv_vector.set(.5f, .5f, 0f, 0f); Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector); u3 = transform_uv_vector.getX() + .5f; v3 = transform_uv_vector.getY() + .5f; uv_vector.set(-.5f, .5f, 0f, 0f); Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector); u4 = transform_uv_vector.getX() + .5f; v4 = transform_uv_vector.getY() + .5f; }
Example #13
Source File: SubMesh.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void pushTo(Mesh mesh, final float xOffset, final float yOffset, final float zOffset, Rotation horizRotation, final float horizAngleDeg, Rotation vertRotation, final float vertAngleDeg) { Matrix4f transform = createTransform(horizRotation, horizAngleDeg, vertRotation, vertAngleDeg); for (int i=0; i<positions.size(); i++) { Vector3f pos = new Vector3f( positions.get(i) ); Vector2f tex = texCoords.get(i); Vector4f col = colours.get(i); if (transform != null) { Vector4f dest = new Vector4f(); Matrix4f.transform(transform, new Vector4f(pos.x, pos.y, pos.z, 1.0f), dest); pos.x = dest.x / dest.w; pos.y = dest.y / dest.w; pos.z = dest.z / dest.w; } pos.x += xOffset; pos.y += yOffset; pos.z += zOffset; mesh.addVertex(pos, col, tex.x, tex.y); } }
Example #14
Source File: Stairs.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void createNorthStair(Mesh mesh, final int x, final int y, final int z, final int offSetY, BlockContext world, RawChunk chunk, Vector4f colour, final float topLight, final float northLight, final float southLight, final float eastLight, final float westLight) { final float ownLight = Math.max(topLight, Math.max(northLight, Math.max(southLight, Math.max(eastLight, westLight)))); final BlockType north = world.getBlockType(chunk.getChunkCoord(), x, y, z-1); final BlockType south = world.getBlockType(chunk.getChunkCoord(), x, y, z+1); final boolean stairsToNorth = north instanceof Stairs; final boolean stairsToSouth = south instanceof Stairs; if(stairsToNorth || (stairsToNorth && stairsToSouth)) { final int northData = chunk.getBlockData(x, y, z-1); if(northData == 0x0 || northData == 0x4) BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 0, 8, 8, 8, colour, texture, topLight, northLight, southLight, eastLight, ownLight); else if(northData == 0x1 || northData == 0x5) BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 0, 8, 8, 8, colour, texture, topLight, northLight, southLight, eastLight, ownLight); else BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 0, 16, 8, 8, colour, texture, topLight, northLight, southLight, eastLight, ownLight); } else if(stairsToSouth) { final int southData = chunk.getBlockData(x, y, z+1); BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 0, 16, 8, 8, colour, texture, topLight, northLight, southLight, eastLight, ownLight); if(southData == 0x0 || southData == 0x4) BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 8, 8, 8, 8, colour, texture, topLight, ownLight, southLight, eastLight, westLight); else if(southData == 0x1 || southData == 0x5) BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 8, 8, 8, 8, colour, texture, topLight, northLight, ownLight, eastLight, westLight); } else { BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 0, 16, 8, 8, colour, texture, topLight, northLight, southLight, eastLight, ownLight); } }
Example #15
Source File: PerspectiveCalculator.java From ldparteditor with MIT License | 5 votes |
/** * Calculates the grid data for the actual viewport perspective */ private void calculateGrid(Matrix4f realViewport) { float grid_size = c3d.getZoom() * View.PIXEL_PER_LDU; while (grid_size > 10f) { grid_size = grid_size / 10f; } while (grid_size < 10f) { grid_size = grid_size * 10f; } if (grid_size > 10f) { grid_size = grid_size / 2f; } grid_size = grid_size * 10f * c3d.getGrid_scale(); int mx = (int) (c3d.getBounds().width / grid_size + 4) / 2; int my = (int) (c3d.getBounds().height / grid_size + 4) / 2; grid_size = grid_size / 1000f; float rest_x = offset.x % grid_size; float rest_y = offset.y % grid_size; Vector4f[] grid = c3d.getGrid(); grid[0].set(rest_x, rest_y, z_eff + 0.1f); grid[1].set(-grid_size, 0f); grid[2].set(0f, -grid_size); // Multiplicants grid[3].set(mx, my); grid_size = grid_size * 10f; int mx10 = (int) (c3d.getBounds().width / grid_size + 4) / 2; int my10 = (int) (c3d.getBounds().height / grid_size + 4) / 2; float rest_x10 = offset.x % grid_size; float rest_y10 = offset.y % grid_size; grid[4].set(rest_x10, rest_y10, z_eff); grid[5].set(-grid_size, 0f); grid[6].set(0f, -grid_size); // Multiplicants grid[7].set(mx10, my10); }
Example #16
Source File: PerspectiveCalculator.java From ldparteditor with MIT License | 5 votes |
/** * Transforms screen coordinates to 3D space coordinates * * @param x * x-screen coordinate * @param y * y-screen coordinate * @return vector position in 3D space */ public Vector4f get3DCoordinatesFromScreen(int x, int y) { Point cSize = c3d.getSize(); Vector4f relPos = new Vector4f(); relPos.x = (0.5f * cSize.x - x) / View.PIXEL_PER_LDU; relPos.y = (y - 0.5f * cSize.y) / View.PIXEL_PER_LDU; relPos.w = 1.0f; Matrix4f v_inverse = c3d.getViewport_Inverse(); Matrix4f.transform(v_inverse, relPos, relPos); return relPos; }
Example #17
Source File: PowerRay.java From ldparteditor with MIT License | 5 votes |
public boolean TRIANGLE_INTERSECT(Vector4f orig, Vector4f dir, Vertex vert0, Vertex vert1, Vertex vert2, Vector4f intersection_point, double[] dist) { double[] orig_arr = new double[] { orig.x, orig.y, orig.z }; double[] dir_arr = new double[] { dir.x, dir.y, dir.z }; double[] vert0_arr = new double[] { vert0.x, vert0.y, vert0.z }; double[] vert1_arr = new double[] { vert1.x, vert1.y, vert1.z }; double[] vert2_arr = new double[] { vert2.x, vert2.y, vert2.z }; if (TRIANGLE_INTERSECT2(orig_arr, dir_arr, vert0_arr, vert1_arr, vert2_arr)) { intersection_point.set((float) (orig_arr[0] + dir_arr[0] * t), (float) (orig_arr[1] + dir_arr[1] * t), (float) (orig_arr[2] + dir_arr[2] * t), 1f); dist[0] = t; return true; } return false; }
Example #18
Source File: RandomAccelerationEmitter.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public RandomAccelerationEmitter(World world, Vector3f position, float offset_z, float emitter_radius, float emitter_height, float angle_bound, float angle_max_jump, int num_particles, float particles_per_second, Vector3f velocity, Vector3f acceleration, float acceleration_factor, Vector4f color, Vector4f delta_color, Vector3f particle_radius, Vector3f growth_rate, float energy, float friction, int src_blend_func, int dst_blend_func, TextureKey[] textures, AnimationManager manager) { this(world, position, offset_z, emitter_radius, emitter_height, angle_bound, angle_max_jump, num_particles, particles_per_second, velocity, acceleration, acceleration_factor, color, delta_color, particle_radius, growth_rate, energy, friction, src_blend_func, dst_blend_func, textures, null, textures.length, manager); }
Example #19
Source File: SkyboxUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Geometry generateNightSkybox(Rasteriser rasteriser) { Vector4f topColour = new Vector4f(0.0f, 0.0f, 0.0f, 1); Vector4f bottomColour = new Vector4f(0, 0, 0.4f, 1); return generateSkybox(rasteriser, topColour, bottomColour); }
Example #20
Source File: PerspectiveCalculator.java From ldparteditor with MIT License | 5 votes |
/** * Transforms screen coordinates to 3D space coordinates * * @param x * x-screen coordinate * @param y * y-screen coordinate * @param z * z-screen coordinate * @return vector position in 3D space */ public Vector4f get3DCoordinatesFromScreen(int x, int y, int z) { Point cSize = c3d.getSize(); Vector4f relPos = new Vector4f(); relPos.x = (0.5f * cSize.x - x) / View.PIXEL_PER_LDU; relPos.y = (y - 0.5f * cSize.y) / View.PIXEL_PER_LDU; relPos.z = z; relPos.w = 1.0f; Matrix4f v_inverse = c3d.getViewport_Inverse(); Matrix4f.transform(v_inverse, relPos, relPos); return relPos; }
Example #21
Source File: Stairs.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void createEastStair(Mesh mesh, final int x, final int y, final int z, final int offSetY, BlockContext world, RawChunk chunk, Vector4f colour, final float topLight, final float northLight, final float southLight, final float eastLight, final float westLight) { final float ownLight = Math.max(topLight, Math.max(northLight, Math.max(southLight, Math.max(eastLight, westLight)))); final BlockType west = world.getBlockType(chunk.getChunkCoord(), x-1, y, z); final BlockType east = world.getBlockType(chunk.getChunkCoord(), x+1, y, z); final boolean stairsToWest = west instanceof Stairs; final boolean stairsToEast = east instanceof Stairs; if(stairsToEast || (stairsToEast && stairsToWest)) { final int eastData = chunk.getBlockData(x+1, y, z); if(eastData == 0x2 || eastData == 0x6) BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 8, 8, 8, 8, colour, texture, topLight, northLight, southLight, eastLight, ownLight); else if(eastData == 0x3 || eastData == 0x7) BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 0, 8, 8, 8, colour, texture, topLight, northLight, southLight, eastLight, ownLight); else BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 0, 8, 8, 16, colour, texture, topLight, ownLight, southLight, eastLight, westLight); } else if(stairsToWest) { final int westData = chunk.getBlockData(x-1, y, z); BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 0, 8, 8, 16, colour, texture, topLight, ownLight, southLight, eastLight, westLight); if(westData == 0x2 || westData == 0x6) BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 8, 8, 8, 8, colour, texture, topLight, northLight, southLight, ownLight, westLight); else if(westData == 0x3 || westData == 0x7) BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 0, 8, 8, 8, colour, texture, topLight, northLight, ownLight, eastLight, westLight); } else { BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 0, 8, 8, 16, colour, texture, topLight, ownLight, southLight, eastLight, westLight); } }
Example #22
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example #23
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example #24
Source File: KeyStateManager.java From ldparteditor with MIT License | 5 votes |
private static void translateView(Composite3D c3d, float dx, float dy) { PerspectiveCalculator perspective = c3d.getPerspectiveCalculator(); Matrix4f viewport_rotation = c3d.getRotation(); Matrix4f viewport_translation = c3d.getTranslation(); Matrix4f old_viewport_translation = new Matrix4f(); Matrix4f.load(c3d.getTranslation(), old_viewport_translation); Vector4f xAxis4f_translation = new Vector4f(dx, 0, 0, 1.0f); Vector4f yAxis4f_translation = new Vector4f(0, dy, 0, 1.0f); Matrix4f ovr_inverse2 = Matrix4f.invert(viewport_rotation, null); Matrix4f.transform(ovr_inverse2, xAxis4f_translation, xAxis4f_translation); Matrix4f.transform(ovr_inverse2, yAxis4f_translation, yAxis4f_translation); Vector3f xAxis3 = new Vector3f(xAxis4f_translation.x, xAxis4f_translation.y, xAxis4f_translation.z); Vector3f yAxis3 = new Vector3f(yAxis4f_translation.x, yAxis4f_translation.y, yAxis4f_translation.z); Matrix4f.load(old_viewport_translation, viewport_translation); Matrix4f.translate(xAxis3, old_viewport_translation, viewport_translation); Matrix4f.translate(yAxis3, viewport_translation, viewport_translation); perspective.calculateOriginData(); c3d.getVertexManager().getResetTimer().set(true); if (c3d.isSyncTranslation()) { float tx = c3d.getTranslation().m30; float ty = c3d.getTranslation().m31; float tz = c3d.getTranslation().m32; for (OpenGLRenderer renderer : Editor3DWindow.getRenders()) { Composite3D c3d2 = renderer.getC3D(); if (!c3d2.isDisposed() && c3d != c3d2 && c3d.getLockableDatFileReference().equals(c3d2.getLockableDatFileReference())) { c3d2.getTranslation().m30 = tx; c3d2.getTranslation().m31 = ty; c3d2.getTranslation().m32 = tz; ((ScalableComposite) c3d2.getParent()).redrawScales(); c3d2.getPerspectiveCalculator().initializeViewportPerspective(); } } } }
Example #25
Source File: LightningCloud.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
private final void strike(Target target) { if (lightning_timer <= 0f) { cloud.forceColorChange(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 0f); lightning_timer = LIGHTNING_TIME; lighted = true; } float x = target.getPositionX(); float y = target.getPositionY(); float z = owner.getWorld().getHeightMap().getNearestHeight(x, y); new Lightning(owner.getWorld(), position, new Vector3f(x, y, z), .5f, 15, new Vector4f(1f, 1f, 1f, 1f), new Vector4f(0f, 0f, 0f, -1f/LIGHTNING_TIME), owner.getWorld().getRacesResources().getLightningTexture(), LIGHTNING_TIME, owner.getWorld().getAnimationManagerGameTime()); }
Example #26
Source File: RandomVelocityEmitter.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public RandomVelocityEmitter(World world, Vector3f position, float offset_z, float emitter_radius, float emitter_height, float angle_bound, float angle_max_jump, int num_particles, float particles_per_second, Vector3f velocity, Vector3f acceleration, Vector4f color, Vector4f delta_color, Vector3f particle_radius, Vector3f growth_rate, float energy, float friction, SpriteKey[] sprite_renderers, AnimationManager manager) { this(world, position, offset_z, 0f, emitter_radius, emitter_height, angle_bound, angle_max_jump, num_particles, particles_per_second, velocity, acceleration, color, delta_color, particle_radius, growth_rate, energy, friction, 0, 0, null, sprite_renderers, sprite_renderers.length, manager); }
Example #27
Source File: MeshUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void addQuad(Mesh mesh, Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3, Vector4f colour, SubTexture texture) { mesh.addVertex(p0, colour, texture.u0, texture.v0); mesh.addVertex(p1, colour, texture.u1, texture.v0); mesh.addVertex(p2, colour, texture.u1, texture.v1); mesh.addVertex(p3, colour, texture.u0, texture.v1); }
Example #28
Source File: SubMesh.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void addQuad(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3, Vector4f colour, Vector2f uv0, Vector2f uv1, Vector2f uv2, Vector2f uv3) { addVertex(p0, colour, uv0.x, uv0.y); addVertex(p1, colour, uv1.x, uv1.y); addVertex(p2, colour, uv2.x, uv2.y); addVertex(p3, colour, uv3.x, uv3.y); }
Example #29
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4f var2, Vector3f var3) { Vector4f var4 = new Vector4f(var.x - var1.x, var.y - var1.y, var.z - var1.z, 1.0F); Matrix4f.transform(var2, var4, var4); var4.x *= var3.x; var4.y *= var3.y; var4.z *= var3.z; var.set(var4.x + var1.x, var4.y + var1.y, var4.z + var1.z); }
Example #30
Source File: Stairs.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void createSouthStair(Mesh mesh, final int x, final int y, final int z, final int offSetY, BlockContext world, RawChunk chunk, Vector4f colour, final float topLight, final float northLight, final float southLight, final float eastLight, final float westLight) { final float ownLight = Math.max(topLight, Math.max(northLight, Math.max(southLight, Math.max(eastLight, westLight)))); final BlockType north = world.getBlockType(chunk.getChunkCoord(), x, y, z-1); final BlockType south = world.getBlockType(chunk.getChunkCoord(), x, y, z+1); final boolean stairsToNorth = north instanceof Stairs; final boolean stairsToSouth = south instanceof Stairs; if(stairsToSouth || (stairsToSouth && stairsToNorth)) { final int southData = chunk.getBlockData(x, y, z+1); if(southData == 0x0 || southData == 0x4) BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 8, 8, 8, 8, colour, texture, topLight, ownLight, southLight, eastLight, westLight); else if(southData == 0x1 || southData == 0x5) BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 8, 8, 8, 8, colour, texture, topLight, northLight, southLight, ownLight, westLight); else BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 8, 16, 8, 8, colour, texture, topLight, northLight, southLight, ownLight, westLight); } else if(stairsToNorth) { final int northData = chunk.getBlockData(x, y, z-1); BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 8, 16, 8, 8, colour, texture, topLight, northLight, southLight, ownLight, westLight); if(northData == 0x0 || northData == 0x4) BlockUtil.addBlock(mesh, x, y, z, 8, offSetY, 0, 8, 8, 8, colour, texture, topLight, ownLight, southLight, eastLight, westLight); else if(northData == 0x1 || northData == 0x5) BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 0, 8, 8, 8, colour, texture, topLight, northLight, ownLight, eastLight, westLight); } else { BlockUtil.addBlock(mesh, x, y, z, 0, offSetY, 8, 16, 8, 8, colour, texture, topLight, northLight, southLight, ownLight, westLight); } }