Java Code Examples for javax.vecmath.Vector3f#sub()
The following examples show how to use
javax.vecmath.Vector3f#sub() .
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 | 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]); v1.sub(t); t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]); v2.sub(t, v1); v1.cross(v2, v1); v1.normalize(); int x = ((byte) (v1.x * 127)) & 0xFF; int y = ((byte) (v1.y * 127)) & 0xFF; int z = ((byte) (v1.z * 127)) & 0xFF; for (int i = 0; i < 4; i++) { faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10); } }
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: LineUtils.java From ar-drawing-java with Apache License 2.0 | 5 votes |
/** * @param newPoint * @param lastPoint * @return */ public static boolean distanceCheck(Vector3f newPoint, Vector3f lastPoint) { Vector3f temp = new Vector3f(); temp.sub(newPoint, lastPoint); if (temp.length() > AppSettings.getMinDistance()) { return true; } return false; }
Example 5
Source File: Stroke.java From justaline-android with Apache License 2.0 | 5 votes |
public void calculateTotalLength() { totalLength = 0; for (int i = 1; i < points.size(); i++) { Vector3f dist = new Vector3f(points.get(i)); dist.sub(points.get(i - 1)); totalLength += dist.length(); } }
Example 6
Source File: Stroke.java From justaline-android with Apache License 2.0 | 5 votes |
private float calculateAngle(int index) { Vector3f p1 = points.get(index - 1); Vector3f p2 = points.get(index); Vector3f p3 = points.get(index + 1); Vector3f n1 = new Vector3f(); n1.sub(p2, p1); Vector3f n2 = new Vector3f(); n2.sub(p3, p2); return n1.angle(n2); }
Example 7
Source File: Stroke.java From justaline-android with Apache License 2.0 | 5 votes |
private float calculateDistance(int index1, int index2) { Vector3f p1 = points.get(index1); Vector3f p2 = points.get(index2); Vector3f n1 = new Vector3f(); n1.sub(p2, p1); return n1.length(); }
Example 8
Source File: Stroke.java From justaline-android with Apache License 2.0 | 5 votes |
public void finishStroke() { finished = true; // Calculate total distance traveled float dist = 0; Vector3f d = new Vector3f(); for (int i = 0; i < points.size() - 1; i++) { d.sub(points.get(i), points.get(i + 1)); dist += d.length(); } // If line is very short, overwrite it if (dist < 0.01) { if (points.size() > 2) { Vector3f p1 = points.get(0); Vector3f p2 = points.get(points.size() - 1); points.clear(); points.add(p1); points.add(p2); } else if (points.size() == 1) { Vector3f v = new Vector3f(points.get(0)); v.y += 0.0005; points.add(v); } } }
Example 9
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
public static ej 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(); var4.sub(var1, var2); var5.sub(var3, var2); var6.cross(var5, var4); 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; ej var8 = null; float var9 = 0.0F; ej[] var10 = ej.values(); int var11 = var10.length; for (int var12 = 0; var12 < var11; ++var12) { ej var13 = var10[var12]; fd var14 = var13.m(); Vector3f var15 = new Vector3f((float) var14.n(), (float) var14.o(), (float) var14.p()); float var16 = var6.dot(var15); if (var16 >= 0.0F && var16 > var9) { var9 = var16; var8 = var13; } } if (var8 == null) { return ej.b; } else { return var8; } }
Example 10
Source File: FaceBakery.java From The-5zig-Mod with MIT License | 5 votes |
private void a(Vector3f var, Vector3f var1, Matrix4d var2, Vector3f var3) { var.sub(var1); var2.transform(var); var.x *= var3.x; var.y *= var3.y; var.z *= var3.z; var.add(var1); }
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++; }
Example 12
Source File: LineUtils.java From justaline-android with Apache License 2.0 | 4 votes |
public static boolean distanceCheck(Vector3f newPoint, Vector3f lastPoint) { Vector3f temp = new Vector3f(); temp.sub(newPoint, lastPoint); return temp.lengthSquared() > AppSettings.getMinDistance(); }
Example 13
Source File: LineShaderRenderer.java From justaline-android with Apache License 2.0 | 4 votes |
/** * AddLine takes in the 3D positions adds to the buffers to create the stroke and the degenerate * faces needed so the lines render properly. */ private int addLine(Stroke line, int offset) { if (line == null || line.size() < 2) return offset; int lineSize = line.size(); float mLineWidthMax = mLineWidth = line.getLineWidth(); float length = 0; float totalLength; int ii = offset; if (line.localLine) { totalLength = line.totalLength; } else { totalLength = line.animatedLength; } for (int i = 0; i < lineSize; i++) { int iGood = i; if (iGood >= lineSize) iGood = lineSize - 1; int i_m_1 = (iGood - 1) < 0 ? iGood : iGood - 1; int i_p_1 = (iGood + 1) > (lineSize - 1) ? iGood : iGood + 1; Vector3f current = line.get(iGood); Vector3f previous = line.get(i_m_1); Vector3f next = line.get(i_p_1); Vector3f dist = new Vector3f(current); dist.sub(previous); length += dist.length(); // if (i < line.mTapperPoints) { // mLineWidth = mLineWidthMax * line.mTaperLookup[i]; // } else if (i > lineSize - line.mTapperPoints) { // mLineWidth = mLineWidthMax * line.mTaperLookup[lineSize - i]; // } else { mLineWidth = line.getLineWidth(); // } mLineWidth = Math.max(0, Math.min(mLineWidthMax, mLineWidth)); if (i == 0) { setMemory(ii++, current, previous, next, mLineWidth, 1f, length, totalLength); } setMemory(ii++, current, previous, next, mLineWidth, 1f, length, totalLength); setMemory(ii++, current, previous, next, mLineWidth, -1f, length, totalLength); if (i == lineSize - 1) { setMemory(ii++, current, previous, next, mLineWidth, -1f, length, totalLength); } } return ii; }
Example 14
Source File: DrawAR.java From ar-drawing-java with Apache License 2.0 | 4 votes |
/** * update() is executed on the GL Thread. * The method handles all operations that need to take place before drawing to the screen. * The method : * extracts the current projection matrix and view matrix from the AR Pose * handles adding stroke and points to the data collections * updates the ZeroMatrix and performs the matrix multiplication needed to re-center the drawing * updates the Line Renderer with the current strokes, color, distance scale, line width etc */ private void update() { if (mSession == null) { return; } mDisplayRotationHelper.updateSessionIfNeeded(mSession); try { mSession.setCameraTextureName(mBackgroundRenderer.getTextureId()); mFrame = mSession.update(); Camera camera = mFrame.getCamera(); mState = camera.getTrackingState(); // Update tracking states if (mState == TrackingState.TRACKING && !bIsTracking.get()) { bIsTracking.set(true); } else if (mState== TrackingState.STOPPED && bIsTracking.get()) { bIsTracking.set(false); bTouchDown.set(false); } // Get projection matrix. camera.getProjectionMatrix(projmtx, 0, AppSettings.getNearClip(), AppSettings.getFarClip()); camera.getViewMatrix(viewmtx, 0); float[] position = new float[3]; camera.getPose().getTranslation(position, 0); // Check if camera has moved much, if thats the case, stop touchDown events // (stop drawing lines abruptly through the air) if (mLastFramePosition != null) { Vector3f distance = new Vector3f(position[0], position[1], position[2]); distance.sub(new Vector3f(mLastFramePosition[0], mLastFramePosition[1], mLastFramePosition[2])); if (distance.length() > 0.15) { bTouchDown.set(false); } } mLastFramePosition = position; // Multiply the zero matrix Matrix.multiplyMM(viewmtx, 0, viewmtx, 0, mZeroMatrix, 0); if (bNewStroke.get()) { bNewStroke.set(false); addStroke(lastTouch.get()); mLineShaderRenderer.bNeedsUpdate.set(true); } else if (bTouchDown.get()) { addPoint(lastTouch.get()); mLineShaderRenderer.bNeedsUpdate.set(true); } if (bReCenterView.get()) { bReCenterView.set(false); mZeroMatrix = getCalibrationMatrix(); } if (bClearDrawing.get()) { bClearDrawing.set(false); clearDrawing(); mLineShaderRenderer.bNeedsUpdate.set(true); } if (bUndo.get()) { bUndo.set(false); if (mStrokes.size() > 0) { mStrokes.remove(mStrokes.size() - 1); mLineShaderRenderer.bNeedsUpdate.set(true); } } mLineShaderRenderer.setDrawDebug(bLineParameters.get()); if (mLineShaderRenderer.bNeedsUpdate.get()) { mLineShaderRenderer.setColor(AppSettings.getColor()); mLineShaderRenderer.mDrawDistance = AppSettings.getStrokeDrawDistance(); mLineShaderRenderer.setDistanceScale(mDistanceScale); mLineShaderRenderer.setLineWidth(mLineWidthMax); mLineShaderRenderer.clear(); mLineShaderRenderer.updateStrokes(mStrokes); mLineShaderRenderer.upload(); } } catch (Exception e) { e.printStackTrace(); } }
Example 15
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 16
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 17
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 18
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 19
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 20
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++; }