public Vector3f normalize(float length, Vector3f dest) { float invLength = 1.0f / length() * length; dest.x = x * invLength; dest.y = y * invLength; dest.z = z * invLength; return dest; }
public Vector3f normalize(float length, Vector3f dest) { float invLength = 1.0f / length() * length; dest.x = x * invLength; dest.y = y * invLength; dest.z = z * invLength; return dest; }
public Vector3f normalize(Vector3f dest) { float invLength = 1.0f / length(); dest.x = x * invLength; dest.y = y * invLength; dest.z = z * invLength; return dest; }
public Vector3f normalize(Vector3f dest) { float invLength = 1.0f / length(); dest.x = x * invLength; dest.y = y * invLength; dest.z = z * invLength; return dest; }
public void move(float time) { GVRSceneObject owner = getOwnerObject(); if (owner == null) { return; } getPosition(); mCurPos.x += Direction.x * Velocity * time; mCurPos.y += Direction.y * Velocity * time; mCurPos.z += Direction.z * Velocity * time; owner.getTransform().setPosition(mCurPos.x, mCurPos.y, mCurPos.z);; Distance = mCurPos.sub(mStartPos, mCurPos).length(); } }
public void move(float time) { GVRSceneObject owner = getOwnerObject(); if (owner == null) { return; } getPosition(); mCurPos.x += Direction.x * Velocity * time; mCurPos.y += Direction.y * Velocity * time; mCurPos.z += Direction.z * Velocity * time; owner.getTransform().setPosition(mCurPos.x, mCurPos.y, mCurPos.z);; Distance = mCurPos.sub(mStartPos, mCurPos).length(); } }
public void move(float time) { GVRSceneObject owner = getOwnerObject(); if (owner == null) { return; } getPosition(); mCurPos.x += Direction.x * Velocity * time; mCurPos.y += Direction.y * Velocity * time; mCurPos.z += Direction.z * Velocity * time; owner.getTransform().setPosition(mCurPos.x, mCurPos.y, mCurPos.z);; Distance = mCurPos.sub(mStartPos, mCurPos).length(); } }
/** * Look for a 3D object in the scene near the given position. * Used ro prevent objects from being placed too close together. */ private GVRAnchor findAnchorNear(float x, float y, float z, float maxdist) { Matrix4f anchorMtx = new Matrix4f(); Vector3f v = new Vector3f(); for (GVRAnchor anchor : mVirtualObjects) { float[] anchorPose = anchor.getPose(); anchorMtx.set(anchorPose); anchorMtx.getTranslation(v); v.x -= x; v.y -= y; v.z -= z; float d = v.length(); if (d < maxdist) { return anchor; } } return null; } };
if (perp.length() > EPSILON) {
if (new Vector3f(toCenter).sub(center).length() < 1e-3) { center.set(toCenter); fromCenter = null;
private void displayMesh(Mesh m) { this.mesh = m; Vector3f lower = new Vector3f(m.xmin(), m.ymin(), m.zmin()); Vector3f upper = new Vector3f(m.xmax(), m.ymax(), m.zmax()); center = new Vector3f(lower).add(upper).mul(0.5f); scale = 2.f / (new Vector3f(upper).sub(lower).length()); // reset other camera/transform/rotate parameters zoom = 1f; arcBall.reset(); // rescale glMesh vertices and center them at (0,0,0) for (int i = 0; i < m.vertices.length; i++) { m.vertices[i] = (m.vertices[i] - center.get(i % 3)) * scale; } // since we rescaled and centered them, scale will be 1.0 and center is the origin (0,0,0) center = new Vector3f(); scale = 1.0f; // create the gl glMesh for rendering glMesh = new GLMesh(gl, m); }