org.lwjgl.util.vector.Vector3f Java Examples
The following examples show how to use
org.lwjgl.util.vector.Vector3f.
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: BlockUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void addSouth(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry) { // final int southId = world.getBlockId(rawChunk.getChunkCoord(), x+1, y, z); // BlockType south = registry.find(southId); BlockType south = world.getBlockType(rawChunk.getChunkCoord(), x+1, y, z); if (!south.isSolid()) { final float lightness = world.getLight(rawChunk.getChunkCoord(), x+1, y, z, LightFace.NorthSouth); MeshUtil.addQuad(mesh, new Vector3f(x+1, y+1, z+1), new Vector3f(x+1, y+1, z), new Vector3f(x+1, y, z), new Vector3f(x+1, y, z+1), new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a), texture); } }
Example #2
Source File: SubMesh.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void pushTo(SubMesh destMesh, 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) ); 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; } destMesh.positions.add( new Vector3f(positions.get(i) )); destMesh.colours.add( new Vector4f(colours.get(i) )); destMesh.texCoords.add( new Vector2f(texCoords.get(i) )); } }
Example #3
Source File: BlockUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void addTop(BlockContext world, RawChunk rawChunk, Mesh mesh, final int blockX, final int blockY, final int blockZ, Colour4f colour, SubTexture texture, BlockTypeRegistry registry) { // final int aboveId = world.getBlockId(rawChunk.getChunkCoord(), blockX, blockY+1, blockZ); // BlockType above = registry.find(aboveId); BlockType above = world.getBlockType(rawChunk.getChunkCoord(), blockX, blockY+1, blockZ); if (!above.isSolid()) { final float lightness = world.getLight(rawChunk.getChunkCoord(), blockX, blockY+1, blockZ, LightFace.Top); MeshUtil.addQuad(mesh, new Vector3f(blockX, blockY+1, blockZ), new Vector3f(blockX+1, blockY+1, blockZ), new Vector3f(blockX+1, blockY+1, blockZ+1), new Vector3f(blockX, blockY+1, blockZ+1), new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a), texture); } }
Example #4
Source File: GData2.java From ldparteditor with MIT License | 6 votes |
public GData2(GData1 parent, int colourNumber, float r, float g, float b, float a, BigDecimal x1, BigDecimal y1, BigDecimal z1, BigDecimal x2, BigDecimal y2, BigDecimal z2, float x12, float y12, float z12, float x22, float y22, float z22, DatFile datFile, boolean isLine) { super(parent); this.colourNumber = colourNumber; this.r = r; this.g = g; this.b = b; this.a = a; this.X1 = x1; this.Y1 = y1; this.Z1 = z1; this.X2 = x2; this.Y2 = y2; this.Z2 = z2; this.x1 = x12; this.y1 = y12; this.z1 = z12; this.x2 = x22; this.y2 = y22; this.z2 = z22; this.lGeom = MathHelper.getLineVertices1000(new Vector3f(this.x1, this.y1, this.z1), new Vector3f(this.x2, this.y2, this.z2), parent.productMatrix); this.isLine = isLine; datFile.getVertexManager().add(this); }
Example #5
Source File: JpctRasteriser.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void setCameraMatrix(Matrix4f matrix, Vector3f lookAt, Vector3f eye, Vector3f up) { // TODO: OrthoCamera sets the position *way* far out and we look everything // behind the far plane. // Figure out how to adjust jpct's near/far planes world.setClippingPlanes(1.0f, 2000); float fov = (float)Math.PI/180f; world.getCamera().setFOV(fov); world.getCamera().setFOVLimits(fov, fov); world.getCamera().setPosition(eye.x, eye.y, eye.z); world.getCamera().lookAt(new SimpleVector(lookAt.x, lookAt.y, lookAt.z)); /* eye = new Vector3f(50, -120, 100); Vector3f target = new Vector3f(50, 0, 50); world.getCamera().setPosition(eye.x, eye.y, eye.z); world.getCamera().lookAt(new SimpleVector(target.x, target.y, target.z)); */ }
Example #6
Source File: Arrow.java From ldparteditor with MIT License | 6 votes |
public Arrow(float r, float g, float b, float dir_x, float dir_y, float dir_z, float cone_height, float cone_width, float line_width) { dir_x = dir_x / 1000f; dir_y = dir_y / 1000f; dir_z = dir_z / 1000f; this.r = r; this.g = g; this.b = b; this.line_width = line_width; length = (float) Math.sqrt(dir_x * dir_x + dir_y * dir_y + dir_z * dir_z); cone_start = length - cone_height; line_end = length - cone_height / 3f; rotation = makeRotationDir(new Vector3f(dir_x, dir_y, dir_z)); matrix_buf = BufferUtils.createFloatBuffer(16); rotation.store(matrix_buf); matrix_buf.position(0); float cone_radius = cone_width; float step = (float) (Math.PI / 8d); float angle = 0f; for (int i = 0; i < 34; i += 2) { cone[i] = (float) (cone_radius * Math.cos(angle)); cone[i + 1] = (float) (cone_radius * Math.sin(angle)); angle = angle + step; } }
Example #7
Source File: Lightning.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
public Lightning(World world, Vector3f src, Vector3f dst, float width, int num_particles, Vector4f color, Vector4f delta_color, TextureKey texture, float energy, AnimationManager manager) { super(world.getElementRoot()); this.world = world; this.src = src; this.dst = dst; this.width = width; this.num_particles = num_particles; this.color = color; this.delta_color = delta_color; this.texture = texture; this.energy = energy; this.manager = manager; initParticles(); register(); }
Example #8
Source File: ItemRenderer.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void renderBlock(File outFile, BlockTypeRegistry registry, TexturePack texturePack, int blockId, int blockData) throws Exception { ItemContext context = new ItemContext(texturePack, registry); Geometry geometry = new Geometry(rasteriser, texturePack.getTexture()); RawChunk rawChunk = new RawChunk(); rawChunk.setBlockId(0, 0, 0, (byte)blockId); rawChunk.setBlockData(0, 0, 0, (byte)blockData); rawChunk.setBlockLight(0, 0, 0, (byte)16); rawChunk.setSkyLight(0, 0, 0, (byte) 16); BlockType type = registry.find(blockId, blockData); if (type != null) { type.addInteriorGeometry(0, 0, 0, context, registry, rawChunk, geometry); } BoundingBox bounds = new BoundingBox(new Vector3f(0, 0.1f, 0), 1, 1, 1); ItemGeometry item = new ItemGeometry(geometry, bounds); renderItem(item, outFile, 4, getAngleRad(45), getAngleRad(25)); }
Example #9
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 6 votes |
private void fillNormal(int[] faceData) { Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]); Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]); Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]); Vector3f result1 = new Vector3f(); Vector3f result2 = new Vector3f(); Vector3f result3 = new Vector3f(); Vector3f.sub(v1, t, result1); t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]); Vector3f.sub(v2, t, result2); Vector3f.cross(result2, result1, result3); result3.normalise(); int x = ((byte) (result3.x * 127)) & 0xFF; int y = ((byte) (result3.y * 127)) & 0xFF; int z = ((byte) (result3.z * 127)) & 0xFF; for (int i = 0; i < 4; i++) { faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10); } }
Example #10
Source File: BlockUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void addInteriorEast(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry) { final int eastId = rawChunk.getBlockId(x, y, z-1); final int eastData = rawChunk.getBlockData(x, y, z-1); BlockType east = registry.find(eastId, eastData); if (!east.isSolid()) { final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.EastWest, rawChunk, x, y, z-1); MeshUtil.addQuad(mesh, new Vector3f(x+1, y+1, z), new Vector3f(x, y+1, z), new Vector3f(x, y, z), new Vector3f(x+1, y, z), new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a), texture); } }
Example #11
Source File: GData2.java From ldparteditor with MIT License | 6 votes |
public GData2(final int colourNumber, float r, float g, float b, float a, Vertex v1, Vertex v2, GData1 parent, DatFile datFile, boolean isLine) { super(parent); this.colourNumber = colourNumber; this.r = r; this.g = g; this.b = b; this.a = a; this.x1 = v1.x; this.y1 = v1.y; this.z1 = v1.z; this.x2 = v2.x; this.y2 = v2.y; this.z2 = v2.z; this.X1 = v1.X; this.Y1 = v1.Y; this.Z1 = v1.Z; this.X2 = v2.X; this.Y2 = v2.Y; this.Z2 = v2.Z; this.isLine = isLine; datFile.getVertexManager().add(this); this.lGeom = MathHelper.getLineVertices1000(new Vector3f(x1, y1, z1), new Vector3f(x2, y2, z2), parent.productMatrix); }
Example #12
Source File: EnderPortal.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void addEdgeGeometry(final int x, final int y, final int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry) { Mesh mesh = geometry.getMesh(texture.texture, Geometry.MeshType.Solid); final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.Top, rawChunk, x, y, z); Vector4f colour = new Vector4f(lightness, lightness, lightness, 1.0f); final float height = 0.5f; MeshUtil.addQuad(mesh, new Vector3f(x, y+height, z), new Vector3f(x+1, y+height, z), new Vector3f(x+1, y+height, z+1), new Vector3f(x, y+height, z+1), colour, texture); }
Example #13
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 #14
Source File: OrthoCamera.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static Vector3f calcEyePosition(Vector3f lookAt, final float angleOffsetRads, final float elevationAngleRads) { final float distance = 1000; // arbitrary, since we're in ortho it doesn't actually matter how far away our camera is // Should be quite large so that our camera is 'above' our geometry though final float angle = angleOffsetRads; // Figure out horizontal distance based on vertical distance and elevation angle // Elevation angle of 0 is horizontal, so invert it so 0 is straight up final float deelevationAngleRads = ((float)Math.PI/2.0f) - elevationAngleRads; final float horizontalDistance = distance * (float)Math.tan(deelevationAngleRads); // Angle of 0 is looking North Vector3f rotatePoint = new Vector3f(lookAt.x, lookAt.y + distance, lookAt.z); float offsetX = (float)Math.cos(angle) * horizontalDistance; float offsetY = 0; float offsetZ = (float)Math.sin(angle) * horizontalDistance; return new Vector3f(rotatePoint.x + offsetX, rotatePoint.y + offsetY, rotatePoint.z + offsetZ); }
Example #15
Source File: ParametricEmitter.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) { Vector3f offset = randomOffset(area_xy, area_xy, area_z); ParametricParticle particle = new ParametricParticle(function, random.nextFloat()*(float)StrictMath.PI*2f, random.nextFloat()*(float)StrictMath.PI*2f, offset.getX(), offset.getY(), offset.getZ()); offset = randomOffset(velocity_random_margin, velocity_random_margin, 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(random.nextInt(getTypes())); particle.update(0); add(particle); return 1; }
Example #16
Source File: BlockUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void addInteriorSouth(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry) { final int southId = rawChunk.getBlockId(x+1, y, z); final int southData = rawChunk.getBlockData(x+1, y, z); BlockType south = registry.find(southId, southData); if (!south.isSolid()) { final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.NorthSouth, rawChunk, x+1, y, z); MeshUtil.addQuad(mesh, new Vector3f(x+1, y+1, z+1), new Vector3f(x+1, y+1, z), new Vector3f(x+1, y, z), new Vector3f(x+1, y, z+1), new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a), texture); } }
Example #17
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 #18
Source File: ItemRenderer.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void renderSign(File outFile, BlockTypeRegistry registry, TexturePack texturePack, int blockId, int blockData) throws Exception { System.out.println("Generating sign icon..."); ItemContext context = new ItemContext(texturePack, registry); Geometry geometry = new Geometry(rasteriser, texturePack.getTexture()); RawChunk rawChunk = new RawChunk(); rawChunk.setBlockId(0, 0, 0, (byte)blockId); rawChunk.setBlockData(0, 0, 0, (byte)blockData); rawChunk.setBlockLight(0, 0, 0, (byte)16); rawChunk.setSkyLight(0, 0, 0, (byte) 16); HashMap<String, SignEntity> signs = new HashMap<>(); signs.put("x0y0z0", new SignEntity(0, 0, 0, 0, 0, 0, "", "Tectonicus", "", "", blockData)); rawChunk.setSigns(signs); BlockType type = registry.find(blockId, blockData); if (type != null) { type.addInteriorGeometry(0, 0, 0, context, registry, rawChunk, geometry); } BoundingBox bounds = new BoundingBox(new Vector3f(0, 0.4f, 0), 1, 1, 0); ItemGeometry item = new ItemGeometry(geometry, bounds); renderItem(item, outFile, 4, getAngleRad(45), getAngleRad(25)); }
Example #19
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
public static cv a(int[] var) { Vector3f var1 = new Vector3f(Float.intBitsToFloat(var[0]), Float.intBitsToFloat(var[1]), Float.intBitsToFloat(var[2])); Vector3f var2 = new Vector3f(Float.intBitsToFloat(var[7]), Float.intBitsToFloat(var[8]), Float.intBitsToFloat(var[9])); Vector3f var3 = new Vector3f(Float.intBitsToFloat(var[14]), Float.intBitsToFloat(var[15]), Float.intBitsToFloat(var[16])); Vector3f var4 = new Vector3f(); Vector3f var5 = new Vector3f(); Vector3f var6 = new Vector3f(); Vector3f.sub(var1, var2, var4); Vector3f.sub(var3, var2, var5); Vector3f.cross(var5, var4, var6); float var7 = (float) Math.sqrt((double) (var6.x * var6.x + var6.y * var6.y + var6.z * var6.z)); var6.x /= var7; var6.y /= var7; var6.z /= var7; cv var8 = null; float var9 = 0.0F; cv[] var10 = cv.values(); int var11 = var10.length; for (int var12 = 0; var12 < var11; ++var12) { cv var13 = var10[var12]; dl var14 = var13.n(); Vector3f var15 = new Vector3f((float) var14.p(), (float) var14.q(), (float) var14.r()); float var16 = Vector3f.dot(var6, var15); if (var16 >= 0.0F && var16 > var9) { var9 = var16; var8 = var13; } } if (var8 == null) { return cv.b; } else { return var8; } }
Example #20
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(int[] dataIn, int count, ct enumFacing, bpa blockPartFace, float[] vec, bym modelRotation, bpb blockPartRotation, boolean b1, boolean b2) { ct var10 = modelRotation.a(enumFacing); int var11 = b2 ? this.a(var10) : -1; bny.b var12 = bny.a(enumFacing).a(count); Vector3f var13 = new Vector3f(vec[var12.a], vec[var12.b], vec[var12.c]); this.a(var13, blockPartRotation); int var14 = this.a(var13, enumFacing, count, modelRotation, b1); this.a(dataIn, var14, count, var13, var11, blockPartFace.e); }
Example #21
Source File: LightningCloud.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public LightningCloud(World world, float offset_x, float offset_y, float offset_z, float seconds_to_live, float seconds_per_hit, float seconds_to_init, float meters_per_second, float hit_chance, int damage, float height, Unit src) { this.seconds_to_live = seconds_to_live; this.seconds_per_hit = seconds_per_hit; this.meters_per_second = meters_per_second; this.hit_chance = hit_chance; this.damage = damage; this.height = height; owner = src.getOwner(); float start_x = src.getPositionX() + offset_x*src.getDirectionX() - offset_y*(-src.getDirectionY()); float start_y = src.getPositionY() + offset_x*src.getDirectionY() + offset_y*src.getDirectionX(); position.setX(start_x); position.setY(start_y); position.setZ(world.getHeightMap().getNearestHeight(position.getX(), position.getY()) + height); cloud = new ParametricEmitter(world, new CloudFunction(2.5f, .7f), position, 0f, 0f, .5f, .5f, .2f, 25, 100f, new Vector4f(.4f, .4f, .4f, .6f), new Vector4f(0f, 0f, 0f, 0f), new Vector3f(3f, 3f, 1f), new Vector3f(0f, 0f, 0f), seconds_to_live + seconds_to_init, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, world.getRacesResources().getSmokeTextures(), world.getAnimationManagerGameTime()); bubbling_sound = world.getAudio().newAudio(new AudioParameters(world.getRacesResources().getBubblingSound(), position.getX(), position.getY(), world.getHeightMap().getNearestHeight(position.getX(), position.getY()), AudioPlayer.AUDIO_RANK_MAGIC, AudioPlayer.AUDIO_DISTANCE_MAGIC, AudioPlayer.AUDIO_GAIN_BUBBLING, AudioPlayer.AUDIO_RADIUS_BUBBLING, 1f, true, false)); }
Example #22
Source File: InteractiveRenderer.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
public InteractiveRenderer(Configuration args, final int displayWidth, final int displayHeight) throws LWJGLException { rasteriser = RasteriserFactory.createRasteriser(args.getRasteriserType(), DisplayType.Window, displayWidth, displayHeight, 24, 8, 24, 4); System.out.println("Using rasteriser: "+rasteriser); rasteriser.printInfo(); viewMode = ViewMode.OrthoView; orthoCamPosition = new Vector3f(); orthoCamera = new OrthoCamera(rasteriser, displayWidth, displayHeight); perspectiveCamera = new PerspectiveCamera(rasteriser, displayWidth, displayHeight); views = new ArrayList<SignEntity>(); }
Example #23
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, boi blockPartRotation) { if (blockPartRotation != null) { Matrix4f var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (blockPartRotation.b) { case a: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(1.0F, 0.0F, 0.0F), var2, var2); var3.set(0.0F, 1.0F, 1.0F); break; case b: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 1.0F, 0.0F), var2, var2); var3.set(1.0F, 0.0F, 1.0F); break; case c: Matrix4f.rotate(blockPartRotation.c * 0.017453292F, new Vector3f(0.0F, 0.0F, 1.0F), var2, var2); var3.set(1.0F, 1.0F, 0.0F); } if (blockPartRotation.d) { if (Math.abs(blockPartRotation.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } Vector3f.add(var3, new Vector3f(1.0F, 1.0F, 1.0F), var3); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(blockPartRotation.a), var2, var3); } }
Example #24
Source File: CSGCube.java From ldparteditor with MIT License | 5 votes |
@Override public List<Polygon> toPolygons(DatFile df, GColour colour) { int[][][] a = { // position // normal { { 0, 4, 6, 2 }, { -1, 0, 0 } }, { { 1, 3, 7, 5 }, { +1, 0, 0 } }, { { 0, 1, 5, 4 }, { 0, -1, 0 } }, { { 2, 6, 7, 3 }, { 0, +1, 0 } }, { { 0, 2, 3, 1 }, { 0, 0, -1 } }, { { 4, 5, 7, 6 }, { 0, 0, +1 } } }; List<Polygon> polygons = new ArrayList<Polygon>(); for (int[][] info : a) { List<VectorCSGd> vertices = new ArrayList<VectorCSGd>(); for (int i : info[0]) { VectorCSGd pos = new VectorCSGd(center.x + dimensions.x * (1 * Math.min(1, i & 1) - 0.5), center.y + dimensions.y * (1 * Math.min(1, i & 2) - 0.5), center.z + dimensions.z * (1 * Math.min(1, i & 4) - 0.5)); vertices.add(pos); } polygons.add(new Polygon(df, vertices, new GColourIndex(colour, ID))); } if (!centered) { Transform centerTransform = Transform.unity().apply( Matrix4f.setIdentity(new Matrix4f()).translate(new Vector3f((float) dimensions.x / 2f, (float) dimensions.y / 2f, (float) dimensions.z / 2f))); for (Polygon p : polygons) { p.transform(centerTransform); } } return polygons; }
Example #25
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(int[] dataIn, int count, cv enumFacing, brd blockPartFace, float[] vec, cbf modelRotation, bre blockPartRotation, boolean b1, boolean b2) { cv var10 = modelRotation.a(enumFacing); int var11 = b2 ? this.a(var10) : -1; bqb.b var12 = bqb.a(enumFacing).a(count); Vector3f var13 = new Vector3f(vec[var12.a], vec[var12.b], vec[var12.c]); this.a(var13, blockPartRotation); int var14 = this.a(var13, enumFacing, count, modelRotation, b1); this.a(dataIn, var14, count, var13, var11, blockPartFace.e); }
Example #26
Source File: GTModelWire.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) private Map<EnumFacing, BakedQuad> generateCoreQuads(GTBlockBaseConnect wire, int min, int max) { Vector3f minF = new Vector3f((float) min, (float) min, (float) min); Vector3f maxF = new Vector3f((float) max, (float) max, (float) max); BlockPartFace face = new BlockPartFace((EnumFacing) null, 0, "", new BlockFaceUV(new float[] { (float) min, (float) min, (float) max, (float) max }, 0)); Map<EnumFacing, BakedQuad> quads = new EnumMap(EnumFacing.class); EnumFacing[] var8 = EnumFacing.VALUES; int var9 = var8.length; for (int var10 = 0; var10 < var9; ++var10) { EnumFacing side = var8[var10]; quads.put(side, this.getBakery().makeBakedQuad(minF, maxF, face, wire.getTextureFromState(this.state, side), side, ModelRotation.X0_Y0, (BlockPartRotation) null, true, true)); } return quads; }
Example #27
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 #28
Source File: Arc.java From ldparteditor with MIT License | 5 votes |
public Arc(float r, float g, float b, float dir_x, float dir_y, float dir_z, float radius, float arc_width) { dir_x = dir_x / 1000f; dir_y = dir_y / 1000f; dir_z = dir_z / 1000f; radius = radius / 1000f; this.r = r; this.g = g; this.b = b; this.arc_width = arc_width; this.arc_width_neg = -arc_width; rotation = makeRotationDir(new Vector3f(dir_x, dir_y, dir_z)); matrix = BufferUtils.createFloatBuffer(16); rotation.store(matrix); matrix.position(0); final float step = (float) (Math.PI / 16d); float angle = 0f; final float radius2 = radius - arc_width / 6f; for (int i = 0; i < 66; i += 2) { circle[i] = (float) (radius * Math.cos(angle)); circle[i + 1] = (float) (radius * Math.sin(angle)); circle2[i] = (float) (radius2 * Math.cos(angle)); circle2[i + 1] = (float) (radius2 * Math.sin(angle)); angle = angle + step; } }
Example #29
Source File: PressurePlate.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void addEdgeGeometry(final int x, final int y, final int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry) { final float height = 1.0f / 16.0f; final float border = 1.0f / 16.0f; //used to make pressure plate slightly smaller than the block it sits on Mesh mesh = geometry.getMesh(texture.texture, Geometry.MeshType.Solid); final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.Top, rawChunk, x, y, z); Vector4f white = new Vector4f(lightness, lightness, lightness, 1); // Top quad MeshUtil.addQuad(mesh, new Vector3f(x+border, y+height, z+border), new Vector3f(x+1-border, y+height, z+border), new Vector3f(x+1-border, y+height, z+1-border), new Vector3f(x+border, y+height, z+1-border), white, texture); // West edge MeshUtil.addQuad(mesh, new Vector3f(x+border, y+height, z+border), new Vector3f(x+border, y+height, z+1-border), new Vector3f(x+border, y, z+1-border), new Vector3f(x+border, y, z+border), white, edgeTexture); // East edge MeshUtil.addQuad(mesh, new Vector3f(x+1-border, y+height, z+1-border), new Vector3f(x+1-border, y+height, z+border), new Vector3f(x+1-border, y, z+border), new Vector3f(x+1-border, y, z+1-border), white, edgeTexture); // South edge MeshUtil.addQuad(mesh, new Vector3f(x+1-border, y+height, z+border), new Vector3f(x+border, y+height, z+border), new Vector3f(x+border, y, z+border), new Vector3f(x+1-border, y, z+border), white, edgeTexture); // North edge MeshUtil.addQuad(mesh, new Vector3f(x+border, y+height, z+1-border), new Vector3f(x+1-border, y+height, z+1-border), new Vector3f(x+1-border, y, z+1-border), new Vector3f(x+border, y, z+1-border), white, edgeTexture); }
Example #30
Source File: Colour.java From LowPolyWater with The Unlicense | 5 votes |
public static Colour add(Colour colour1, Colour colour2, Colour dest) { if (dest == null) { return new Colour(Vector3f.add(colour1.col, colour2.col, null)); } else { Vector3f.add(colour1.col, colour2.col, dest.col); return dest; } }