private Vertex findSimilar(Vertex v) { for (Vertex vertex : vertexList) { if (vertex.position.equals(v.position)) { return vertex; } } return null; }
/** * WARNING - CompoundCollisionShape scaling has no effect. */ @Override public void setScale(Vector3f scale) { if (!scale.equals(Vector3f.UNIT_XYZ)) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "CylinderCollisionShape cannot be scaled"); } }
/** * Alter the scaling factors of this shape. Scaling is disabled * for sphere shapes. * * @param scale the desired scaling factor for each local axis (not null, no * negative component, unaffected, default=1,1,1) */ @Override public void setScale(Vector3f scale) { if (!scale.equals(Vector3f.UNIT_XYZ)) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "SphereCollisionShape cannot be scaled"); } }
/** * Alter the scaling factors of this shape. Scaling is disabled * for capsule shapes. * * @param scale the desired scaling factor for each local axis (not null, no * negative component, unaffected, default=1,1,1) */ @Override public void setScale(Vector3f scale) { if (!scale.equals(Vector3f.UNIT_XYZ)) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "CapsuleCollisionShape cannot be scaled"); } }
/** * Alter the scaling factors of this shape. Scaling is disabled * for cylinder shapes. * * @param scale the desired scaling factor for each local axis (not null, no * negative component, unaffected, default=1,1,1) */ @Override public void setScale(Vector3f scale) { if (!scale.equals(Vector3f.UNIT_XYZ)) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "CylinderCollisionShape cannot be scaled"); } }
private List<BezierLine> getScaledBeziers() { if (scale.equals(Vector3f.UNIT_XYZ)) { return beziers; } List<BezierLine> result = new ArrayList<BezierLine>(); for (BezierLine bezierLine : beziers) { result.add(bezierLine.scale(scale)); } return result; }
/** * Render all the debug geometries to the specified view port. * * @param rm the render manager (not null) * @param vp the view port (not null) */ public void show(RenderManager rm, ViewPort vp) { if (!Vector3f.UNIT_X.equals(UNIT_X_CHECK) || !Vector3f.UNIT_Y.equals(UNIT_Y_CHECK) || !Vector3f.UNIT_Z.equals(UNIT_Z_CHECK) || !Vector3f.UNIT_XYZ.equals(UNIT_XYZ_CHECK) || !Vector3f.ZERO.equals(ZERO_CHECK)) { throw new IllegalStateException("Unit vectors compromised!" + "\nX: " + Vector3f.UNIT_X + "\nY: " + Vector3f.UNIT_Y + "\nZ: " + Vector3f.UNIT_Z + "\nXYZ: " + Vector3f.UNIT_XYZ + "\nZERO: " + Vector3f.ZERO); } debugNode.updateLogicalState(0); debugNode.updateGeometricState(); rm.renderScene(debugNode, vp); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Vertex other = (Vertex) obj; if (this.v != other.v && (this.v == null || !this.v.equals(other.v))) { return false; } if (this.vt != other.vt && (this.vt == null || !this.vt.equals(other.vt))) { return false; } if (this.vn != other.vn && (this.vn == null || !this.vn.equals(other.vn))) { return false; } return true; }
/** * Render all the debug geometries to the specified view port. * * @param rm the render manager (not null) * @param vp the view port (not null) */ public void show(RenderManager rm, ViewPort vp) { if (!Vector3f.UNIT_X.equals(UNIT_X_CHECK) || !Vector3f.UNIT_Y.equals(UNIT_Y_CHECK) || !Vector3f.UNIT_Z.equals(UNIT_Z_CHECK) || !Vector3f.UNIT_XYZ.equals(UNIT_XYZ_CHECK) || !Vector3f.ZERO.equals(ZERO_CHECK)) { throw new IllegalStateException("Unit vectors compromised!" + "\nX: " + Vector3f.UNIT_X + "\nY: " + Vector3f.UNIT_Y + "\nZ: " + Vector3f.UNIT_Z + "\nXYZ: " + Vector3f.UNIT_XYZ + "\nZERO: " + Vector3f.ZERO); } debugNode.updateLogicalState(0); debugNode.updateGeometricState(); rm.renderScene(debugNode, vp); }
protected boolean needToRecalculateNormals() { if (affectedAreaBBox != null) return true; if (!lastScale.equals(getWorldScale())) { affectedAreaBBox = new BoundingBox(getWorldTranslation(), Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE); lastScale = getWorldScale(); return true; } return false; }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is added to a scene. Do not invoke directly * from user code. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override public void update(float tpf) { if (!enabled) { return; } if(mode == Mode.IK){ ikUpdate(tpf); } else if (mode == mode.Ragdoll && targetModel.getLocalTranslation().equals(modelPosition)) { //if the ragdoll has the control of the skeleton, we update each bone with its position in physics world space. ragDollUpdate(tpf); } else { kinematicUpdate(tpf); } }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is added to a scene. Do not invoke directly * from user code. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override public void update(float tpf) { if (!enabled) { return; } if(mode == Mode.IK){ ikUpdate(tpf); } else if (mode == mode.Ragdoll && targetModel.getLocalTranslation().equals(modelPosition)) { //if the ragdoll has the control of the skeleton, we update each bone with its position in physics world space. ragDollUpdate(tpf); } else { kinematicUpdate(tpf); } }
static TSpace avgTSpace(final TSpace tS0, final TSpace tS1) { TSpace tsRes = new TSpace(); // this if is important. Due to floating point precision // averaging when s0 == s1 will cause a slight difference // which results in tangent space splits later on if (tS0.magS == tS1.magS && tS0.magT == tS1.magT && tS0.os.equals(tS1.os) && tS0.ot.equals(tS1.ot)) { tsRes.magS = tS0.magS; tsRes.magT = tS0.magT; tsRes.os.set(tS0.os); tsRes.ot.set(tS0.ot); } else { tsRes.magS = 0.5f * (tS0.magS + tS1.magS); tsRes.magT = 0.5f * (tS0.magT + tS1.magT); tsRes.os.set(tS0.os).addLocal(tS1.os).normalizeLocal(); tsRes.ot.set(tS0.ot).addLocal(tS1.ot).normalizeLocal(); } return tsRes; }
private Triangle makeTriangle() { Triangle triangle = new Triangle(v0, v1, v2); /* * Check center and normal before modification. */ Vector3f center = triangle.getCenter(); Vector3f normal = triangle.getNormal(); assert center.equals(new Vector3f(1f, 1f, 0f)); assert normal.equals(new Vector3f(0f, 0f, 1f)); return triangle; }
protected void updateLOD(final LodCalculator lodCalculator) { if (getSpatial() == null || camera == null) { return; } // update any existing ones that need updating updateQuadLODs(); if (updateLodOffCount(lodCalculator)) { return; } final Vector3f currentLocation = camera.getLocation(); if (!forceUpdate && previousCameraLocation.equals(currentLocation) && !lodCalculator.isLodOff()) { return; // don't update if in same spot } else { previousCameraLocation.set(currentLocation); } forceUpdate = false; if (!lodCalcRunning.compareAndSet(false, true)) { return; } prepareTerrain(); final TerrainExecutorService executorService = TerrainExecutorService.getInstance(); indexer = executorService.submit(createLodUpdateTask(singletonList(currentLocation), lodCalculator)); }
@Override public void updateGeometricState() { super.updateGeometricState(); if (channel < 0 || this.getParent() == null) return; Vector3f currentWorldTranslation = worldTransform.getTranslation(); if (!previousWorldTranslation.equals(currentWorldTranslation)) { getRenderer().updateSourceParam(this, AudioParam.Position); if (velocityFromTranslation && !Float.isNaN(previousWorldTranslation.x)) { velocity.set(currentWorldTranslation).subtractLocal(previousWorldTranslation).multLocal(1f / lastTpf); getRenderer().updateSourceParam(this, AudioParam.Velocity); } previousWorldTranslation.set(currentWorldTranslation); } }
@Override public void render(RenderManager rm) { if (!isEnabled() || listener == null) { return; } Vector3f lastLocation = listener.getLocation(); Vector3f currentLocation = camera.getLocation(); Vector3f velocity = listener.getVelocity(); if (!lastLocation.equals(currentLocation)) { velocity.set(currentLocation).subtractLocal(lastLocation); velocity.multLocal(1f / lastTpf); listener.setLocation(currentLocation); listener.setVelocity(velocity); } else if (!velocity.equals(Vector3f.ZERO)) { listener.setVelocity(Vector3f.ZERO); } Quaternion lastRotation = listener.getRotation(); Quaternion currentRotation = camera.getRotation(); if (!lastRotation.equals(currentRotation)) { listener.setRotation(currentRotation); } }
/** * Update this control. Invoked once per frame during the logical-state * update, provided the control is enabled and added to a scene. Should be * invoked only by a subclass or by AbstractControl. * * @param tpf the time interval between frames (in seconds, ≥0) */ @Override protected void controlUpdate(float tpf) { CollisionShape newShape = body.getCollisionShape(); Vector3f newScale = newShape.getScale(); if (myShape != newShape || !oldScale.equals(newScale)) { myShape = newShape; oldScale.set(newScale); Node node = (Node) spatial; node.detachChild(geom); geom = DebugShapeFactory.getDebugShape(myShape); geom.setName(body.toString()); node.attachChild(geom); } geom.setMaterial(debugAppState.DEBUG_PINK); body.getPhysicsLocation(location); applyPhysicsTransform(location, Quaternion.IDENTITY); }