Java Code Examples for javax.vecmath.Vector3f#scale()
The following examples show how to use
javax.vecmath.Vector3f#scale() .
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: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f vector, clz var1) { if (var1 != null) { Matrix4d var2 = this.a(); Vector3f var3 = new Vector3f(0.0F, 0.0F, 0.0F); switch (var1.b) { case a: var2.mul(a(new AxisAngle4d(1.0D, 0.0D, 0.0D, var1.c * 0.017453292519943295D))); var3.set(0.0F, 1.0F, 1.0F); break; case b: var2.mul(a(new AxisAngle4d(0.0D, 1.0D, 0.0D, var1.c * 0.017453292519943295D))); var3.set(1.0F, 0.0F, 1.0F); break; case c: var2.mul(a(new AxisAngle4d(0.0D, 0.0D, 1.0D, var1.c * 0.017453292519943295D))); var3.set(1.0F, 1.0F, 0.0F); } if (var1.d) { if (Math.abs(var1.c) == 22.5F) { var3.scale(fieldA); } else { var3.scale(fieldB); } var3.add(new Vector3f(1.0F, 1.0F, 1.0F)); } else { var3.set(1.0F, 1.0F, 1.0F); } this.a(vector, new Vector3f(var1.a), var2, var3); } }
Example 2
Source File: Stroke.java From justaline-android with Apache License 2.0 | 5 votes |
private void subdivideSection(int s, float maxAngle, int iteration) { if (iteration == 6) { return; } Vector3f p1 = points.get(s); Vector3f p2 = points.get(s + 1); Vector3f p3 = points.get(s + 2); Vector3f n1 = new Vector3f(); n1.sub(p2, p1); Vector3f n2 = new Vector3f(); n2.sub(p3, p2); float angle = n1.angle(n2); // If angle is too big, add points if (angle > maxAngle) { n1.scale(0.5f); n2.scale(0.5f); n1.add(p1); n2.add(p2); points.add(s + 1, n1); points.add(s + 3, n2); subdivideSection(s + 2, maxAngle, iteration + 1); subdivideSection(s, maxAngle, iteration + 1); } }
Example 3
Source File: Bezier3.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
/** * interpolate between two Vector3f * @param a * @param b * @param i * @return */ protected Vector3f interpolate(Vector3f a,Vector3f b,float i) { Vector3f c = new Vector3f(b); c.sub(a); c.scale(i); c.add(a); return c; }
Example 4
Source File: Skylight_BulletPhysics_Cubes.java From PixelFlow with MIT License | 4 votes |
public void addShootingBody(){ float vel = 2000; float mass = 120000; float dimr = 30; PGraphics3D pg = (PGraphics3D) skylight.renderer.pg_render; mat_mvp.set(pg.modelview); mat_mvp.apply(mat_scene_view); mat_mvp_inv.set(mat_mvp); mat_mvp_inv.invert(); float[] cam_start = {0, 0, -0, 1}; float[] cam_aim = {0, 0, -400, 1}; float[] world_start = new float[4]; float[] world_aim = new float[4]; mat_mvp_inv.mult(cam_start, world_start); mat_mvp_inv.mult(cam_aim, world_aim); Vector3f pos = new Vector3f(world_start[0], world_start[1], world_start[2]); Vector3f aim = new Vector3f(world_aim[0], world_aim[1], world_aim[2]); Vector3f dir = new Vector3f(aim); dir.sub(pos); dir.normalize(); dir.scale(vel); BObject obj; // if((shooter_count % 2) == 0){ obj = new BSphere(this, mass, 0, 0, 0, dimr*0.5f); // } else { // obj = new BBox(this, mass, dimr, dimr, dimr); // } BObject body = new BObject(this, mass, obj, pos, true); body.setPosition(pos); body.setVelocity(dir); body.setRotation(new Vector3f(random(-1, 1),random(-1, 1),random(-1, 1)), random(PI)); body.rigidBody.setRestitution(0.1f); body.rigidBody.setFriction(0.91f); // body.rigidBody.setHitFraction(1); // body.rigidBody.setDamping(0.1f, 0.1f); body.displayShape.setStroke(false); body.displayShape.setFill(true); body.displayShape.setFill(color(255,200,0)); body.displayShape.setStrokeWeight(1); body.displayShape.setStroke(color(0)); if(obj instanceof BBox){ fixBoxNormals(body.displayShape); } physics.addBody(body); group_bulletbodies.addChild(body.displayShape); body.displayShape.setName("[shooter_"+shooter_count+"] [wire]"); shooter_count++; }
Example 5
Source File: Skylight_BulletPhysics_CellFracture.java From PixelFlow with MIT License | 4 votes |
public void addShootingBody(){ float vel = 2000; float mass = 100000; float dimr = 40; PGraphics3D pg = (PGraphics3D) skylight.renderer.pg_render; mat_mvp.set(pg.modelview); mat_mvp.apply(mat_scene_view); mat_mvp_inv.set(mat_mvp); mat_mvp_inv.invert(); float[] cam_start = {0, 0, -0, 1}; float[] cam_aim = {0, 0, -400, 1}; float[] world_start = new float[4]; float[] world_aim = new float[4]; mat_mvp_inv.mult(cam_start, world_start); mat_mvp_inv.mult(cam_aim, world_aim); Vector3f pos = new Vector3f(world_start[0], world_start[1], world_start[2]); Vector3f aim = new Vector3f(world_aim[0], world_aim[1], world_aim[2]); Vector3f dir = new Vector3f(aim); dir.sub(pos); dir.normalize(); dir.scale(vel); BObject obj; // if((shooter_count % 2) == 0){ obj = new BSphere(this, mass, 0, 0, 0, dimr*0.5f); // } else { // obj = new BBox(this, mass, dimr, dimr, dimr); // } BObject body = new BObject(this, mass, obj, pos, true); body.setPosition(pos); body.setVelocity(dir); body.setRotation(new Vector3f(random(-1, 1),random(-1, 1),random(-1, 1)), random(PI)); body.rigidBody.setRestitution(0.9f); body.rigidBody.setFriction(1); // body.rigidBody.setHitFraction(1); body.rigidBody.setDamping(0.1f, 0.1f); body.displayShape.setStroke(false); body.displayShape.setFill(true); body.displayShape.setFill(color(255,200,0)); body.displayShape.setStrokeWeight(1); body.displayShape.setStroke(color(0)); if(obj instanceof BBox){ fixBoxNormals(body.displayShape); } physics.addBody(body); group_bulletbodies.addChild(body.displayShape); body.displayShape.setName("[shooter_"+shooter_count+"] [wire]"); shooter_count++; }
Example 6
Source File: Skylight_BulletPhysics_MengerSponge.java From PixelFlow with MIT License | 4 votes |
public void addShootingBody(){ float vel = 1200; float mass = 300000; float dimr = 30; PGraphics3D pg = (PGraphics3D) skylight.renderer.pg_render; mat_mvp.set(pg.modelview); mat_mvp.apply(mat_scene_view); mat_mvp_inv.set(mat_mvp); mat_mvp_inv.invert(); float[] cam_start = {0, 0, -0, 1}; float[] cam_aim = {0, 0, -400, 1}; float[] world_start = new float[4]; float[] world_aim = new float[4]; mat_mvp_inv.mult(cam_start, world_start); mat_mvp_inv.mult(cam_aim, world_aim); Vector3f pos = new Vector3f(world_start[0], world_start[1], world_start[2]); Vector3f aim = new Vector3f(world_aim[0], world_aim[1], world_aim[2]); Vector3f dir = new Vector3f(aim); dir.sub(pos); dir.normalize(); dir.scale(vel); BObject obj; // if((shooter_count % 2) == 0){ obj = new BSphere(this, mass, 0, 0, 0, dimr*0.5f); // } else { // obj = new BBox(this, mass, dimr, dimr, dimr); // } BObject body = new BObject(this, mass, obj, pos, true); body.setPosition(pos); body.setVelocity(dir); body.setRotation(new Vector3f(random(-1, 1),random(-1, 1),random(-1, 1)), random(PI)); body.rigidBody.setRestitution(0.1f); body.rigidBody.setFriction(0.91f); // body.rigidBody.setHitFraction(1); // body.rigidBody.setDamping(0.1f, 0.1f); body.displayShape.setStroke(false); body.displayShape.setFill(true); body.displayShape.setFill(color(255,16,0)); body.displayShape.setStrokeWeight(1); body.displayShape.setStroke(color(0)); if(obj instanceof BBox){ fixBoxNormals(body.displayShape); } physics.addBody(body); group_bulletbodies.addChild(body.displayShape); body.displayShape.setName("[shooter_"+shooter_count+"] [wire]"); shooter_count++; }
Example 7
Source File: Skylight_BulletPhysics_Breakable.java From PixelFlow with MIT License | 4 votes |
public void addShootingBody(){ float vel = 1000; float mass = 300000; float dimr = 40; PGraphics3D pg = (PGraphics3D) skylight.renderer.pg_render; mat_mvp.set(pg.modelview); mat_mvp.apply(mat_scene_view); mat_mvp_inv.set(mat_mvp); mat_mvp_inv.invert(); float[] cam_start = {0, 0, -0, 1}; float[] cam_aim = {0, 0, -400, 1}; float[] world_start = new float[4]; float[] world_aim = new float[4]; mat_mvp_inv.mult(cam_start, world_start); mat_mvp_inv.mult(cam_aim, world_aim); Vector3f pos = new Vector3f(world_start[0], world_start[1], world_start[2]); Vector3f aim = new Vector3f(world_aim[0], world_aim[1], world_aim[2]); Vector3f dir = new Vector3f(aim); dir.sub(pos); dir.normalize(); dir.scale(vel); BObject body = new BSphere(this, mass, 0, 0, 0, dimr*0.5f); body.setPosition(pos); body.setVelocity(dir); body.setRotation(new Vector3f(random(-1, 1),random(-1, 1),random(-1, 1)), random(PI)); // body.rigidBody.setRestitution(0.9f); // body.rigidBody.setFriction(1); // body.rigidBody.setHitFraction(1); // body.rigidBody.setDamping(0.1f, 0.1f); body.rigidBody.setUserPointer(body); body.displayShape.setStroke(false); body.displayShape.setFill(true); body.displayShape.setFill(color(255,200,0)); body.displayShape.setStrokeWeight(1); body.displayShape.setStroke(color(0)); body.displayShape.setName("[bullet] [wire]"); physics.addBody(body); group_bulletbodies.addChild(body.displayShape); }
Example 8
Source File: Skylight_BulletPhysics_Breakable_VideoExport.java From PixelFlow with MIT License | 4 votes |
public void addShootingBody(){ float vel = 1000; float mass = 300000; float dimr = 40; PGraphics3D pg = (PGraphics3D) skylight.renderer.pg_render; mat_mvp.set(pg.modelview); mat_mvp.apply(mat_scene_view); mat_mvp_inv.set(mat_mvp); mat_mvp_inv.invert(); float[] cam_start = {0, 0, -0, 1}; float[] cam_aim = {0, 0, -400, 1}; float[] world_start = new float[4]; float[] world_aim = new float[4]; mat_mvp_inv.mult(cam_start, world_start); mat_mvp_inv.mult(cam_aim, world_aim); Vector3f pos = new Vector3f(world_start[0], world_start[1], world_start[2]); Vector3f aim = new Vector3f(world_aim[0], world_aim[1], world_aim[2]); Vector3f dir = new Vector3f(aim); dir.sub(pos); dir.normalize(); dir.scale(vel); BObject body = new BSphere(this, mass, 0, 0, 0, dimr*0.5f); body.setPosition(pos); body.setVelocity(dir); body.setRotation(new Vector3f(random(-1, 1),random(-1, 1),random(-1, 1)), random(PI)); // body.rigidBody.setRestitution(0.9f); // body.rigidBody.setFriction(1); // body.rigidBody.setHitFraction(1); // body.rigidBody.setDamping(0.1f, 0.1f); body.rigidBody.setUserPointer(body); body.displayShape.setStroke(false); body.displayShape.setFill(true); body.displayShape.setFill(color(255,200,0)); body.displayShape.setStrokeWeight(1); body.displayShape.setStroke(color(0)); body.displayShape.setName("[bullet] [wire]"); physics.addBody(body); group_bulletbodies.addChild(body.displayShape); }
Example 9
Source File: Skylight_BulletPhysics_Breakable3.java From PixelFlow with MIT License | 4 votes |
public void addShootingBody(){ float vel = 1000; float mass = 300000; float dimr = 40; PGraphics3D pg = (PGraphics3D) skylight.renderer.pg_render; mat_mvp.set(pg.modelview); mat_mvp.apply(mat_scene_view); mat_mvp_inv.set(mat_mvp); mat_mvp_inv.invert(); float[] cam_start = {0, 0, -0, 1}; float[] cam_aim = {0, 0, -400, 1}; float[] world_start = new float[4]; float[] world_aim = new float[4]; mat_mvp_inv.mult(cam_start, world_start); mat_mvp_inv.mult(cam_aim, world_aim); Vector3f pos = new Vector3f(world_start[0], world_start[1], world_start[2]); Vector3f aim = new Vector3f(world_aim[0], world_aim[1], world_aim[2]); Vector3f dir = new Vector3f(aim); dir.sub(pos); dir.normalize(); dir.scale(vel); BObject obj; // if((shooter_count % 2) == 0){ obj = new BSphere(this, mass, 0, 0, 0, dimr*0.5f); // } else { // obj = new BBox(this, mass, dimr, dimr, dimr); // } BObject body = new BObject(this, mass, obj, pos, true); body.setPosition(pos); body.setVelocity(dir); body.setRotation(new Vector3f(random(-1, 1),random(-1, 1),random(-1, 1)), random(PI)); body.rigidBody.setRestitution(0.9f); body.rigidBody.setFriction(1); // body.rigidBody.setHitFraction(1); body.rigidBody.setDamping(0.1f, 0.1f); body.rigidBody.setUserPointer(body); body.displayShape.setStroke(false); body.displayShape.setFill(true); body.displayShape.setFill(color(255,200,0)); body.displayShape.setStrokeWeight(1); body.displayShape.setStroke(color(0)); // body.displayShape.setName("bullet"); physics.addBody(body); group_bulletbodies.addChild(body.displayShape); body.displayShape.setName("[bullet_"+shooter_count+"] [wire]"); shooter_count++; }
Example 10
Source File: Skylight_BulletPhysics_TowerDemolition.java From PixelFlow with MIT License | 4 votes |
public void addShootingBody(){ PGraphics3D pg = (PGraphics3D) skylight.renderer.pg_render; mat_mvp.set(pg.modelview); mat_mvp.apply(mat_scene_view); mat_mvp_inv.set(mat_mvp); mat_mvp_inv.invert(); float[] cam_start = {0, 0, -0, 1}; float[] cam_aim = {0, 0, -400, 1}; float[] world_start = new float[4]; float[] world_aim = new float[4]; mat_mvp_inv.mult(cam_start, world_start); mat_mvp_inv.mult(cam_aim, world_aim); Vector3f pos = new Vector3f(world_start[0], world_start[1], world_start[2]); Vector3f aim = new Vector3f(world_aim[0], world_aim[1], world_aim[2]); Vector3f dir = new Vector3f(aim); dir.sub(pos); dir.normalize(); dir.scale(2000); float mass = 20000; float dimr = 80; BObject obj; // if((shooter_count % 2) == 0){ obj = new BSphere(this, mass, 0, 0, 0, dimr*0.5f); // } else { // obj = new BBox(this, mass, dimr, dimr, dimr); // } BObject body = new BObject(this, mass, obj, pos, true); body.setPosition(pos); body.setVelocity(dir); body.setRotation(new Vector3f(random(-1, 1),random(-1, 1),random(-1, 1)), random(PI)); body.rigidBody.setRestitution(0.9f); body.rigidBody.setFriction(1); // body.rigidBody.setHitFraction(1); body.rigidBody.setDamping(0.1f, 0.1f); body.displayShape.setStroke(false); body.displayShape.setFill(true); body.displayShape.setFill(color(255,8,0)); body.displayShape.setStrokeWeight(1); body.displayShape.setStroke(color(0)); if(obj instanceof BBox){ fixBoxNormals(body.displayShape); } physics.addBody(body); group_bulletbodies.addChild(body.displayShape); body.displayShape.setName("[shooter_"+shooter_count+"] [wire]"); shooter_count++; }
Example 11
Source File: Skylight_BulletPhysics_Basic.java From PixelFlow with MIT License | 4 votes |
public void addShootingBody(){ PGraphics3D pg = (PGraphics3D) skylight.renderer.pg_render; mat_mvp.set(pg.modelview); mat_mvp.apply(mat_scene_view); mat_mvp_inv.set(mat_mvp); mat_mvp_inv.invert(); float[] cam_start = {0, 0, -0, 1}; float[] cam_aim = {0, 0, -400, 1}; float[] world_start = new float[4]; float[] world_aim = new float[4]; mat_mvp_inv.mult(cam_start, world_start); mat_mvp_inv.mult(cam_aim, world_aim); Vector3f pos = new Vector3f(world_start[0], world_start[1], world_start[2]); Vector3f aim = new Vector3f(world_aim[0], world_aim[1], world_aim[2]); Vector3f dir = new Vector3f(aim); dir.sub(pos); dir.normalize(); dir.scale(1000); float mass = 600000; float dimr = 50; BObject obj; if((shooter_count % 2) == 0){ obj = new BSphere(this, mass, 0, 0, 0, dimr*0.5f); } else { obj = new BBox(this, mass, dimr, dimr, dimr); } BObject body = new BObject(this, mass, obj, pos, true); body.setPosition(pos); body.setVelocity(dir); body.setRotation(new Vector3f(random(-1, 1),random(-1, 1),random(-1, 1)), random(PI)); body.rigidBody.setRestitution(0.9f); body.rigidBody.setFriction(1); // body.rigidBody.setHitFraction(1); body.rigidBody.setDamping(0.1f, 0.1f); body.displayShape.setStroke(false); body.displayShape.setFill(true); body.displayShape.setFill(color(8,64,255)); body.displayShape.setStrokeWeight(1); body.displayShape.setStroke(color(0)); if(obj instanceof BBox){ fixBoxNormals(body.displayShape); } physics.addBody(body); group_bulletbodies.addChild(body.displayShape); body.displayShape.setName("[shooter_"+shooter_count+"] [wire]"); shooter_count++; }