Package javax.vecmath

Examples of javax.vecmath.Vector3f.normalize()


      }

      RigidBody body = this.localCreateRigidBody(mass, startTransform, shootBoxShape);

      Vector3f linVel = new Vector3f(destination.x - camPos.x, destination.y - camPos.y, destination.z - camPos.z);
      linVel.normalize();
      linVel.scale(ShootBoxInitialSpeed);

      Transform worldTrans = body.getWorldTransform(new Transform());
      worldTrans.origin.set(camPos);
      worldTrans.setRotation(new Quat4f(0f, 0f, 0f, 1f));
View Full Code Here


    float fov = 2f * (float) Math.atan(tanFov);

    Vector3f rayFrom = new Vector3f(getCameraPosition());
    Vector3f rayForward = new Vector3f();
    rayForward.sub(getCameraTargetPosition(), getCameraPosition());
    rayForward.normalize();
    float farPlane = 10000f;
    rayForward.scale(farPlane);

    Vector3f rightOffset = new Vector3f();
    Vector3f vertical = new Vector3f(cameraUp);
View Full Code Here

    Vector3f vertical = new Vector3f(cameraUp);

    Vector3f hor = new Vector3f();
    // TODO: check: hor = rayForward.cross(vertical);
    hor.cross(rayForward, vertical);
    hor.normalize();
    // TODO: check: vertical = hor.cross(rayForward);
    vertical.cross(hor, rayForward);
    vertical.normalize();

    float tanfov = (float) Math.tan(0.5f * fov);
 
View Full Code Here

            if (rayCallback.hasHit()) {
              RigidBody body = RigidBody.upcast(rayCallback.collisionObject);
              if (body != null) {
                body.setActivationState(CollisionObject.ACTIVE_TAG);
                Vector3f impulse = new Vector3f(rayTo);
                impulse.normalize();
                float impulseStrength = 10f;
                impulse.scale(impulseStrength);
                Vector3f relPos = new Vector3f();
                relPos.sub(rayCallback.hitPointWorld, body.getCenterOfMassPosition(new Vector3f()));
                body.applyImpulse(impulse, relPos);
View Full Code Here

        Vector3f newRayTo = new Vector3f(getRayTo(x, y));
        Vector3f eyePos = new Vector3f(cameraPosition);
        Vector3f dir = new Vector3f();
        dir.sub(newRayTo, eyePos);
        dir.normalize();
        dir.scale(BulletStats.gOldPickingDist);

        Vector3f newPos = new Vector3f();
        newPos.add(eyePos, dir);
        p2p.setPivotB(newPos);
View Full Code Here

    // enable custom material callback
    //staticBody.setCollisionFlags(staticBody.getCollisionFlags() | CollisionFlags.CUSTOM_MATERIAL_CALLBACK);

    // static plane
    Vector3f normal = new Vector3f(0.4f, 1.5f, -0.4f);
    normal.normalize();
    CollisionShape staticplaneShape6 = new StaticPlaneShape(normal, 0f); // A plane

    startTransform.origin.set(0f, 0f, 0f);

    RigidBody staticBody2 = localCreateRigidBody(mass, startTransform, staticplaneShape6);
View Full Code Here

      startTransform.origin.set(camPos);

      RigidBody body = localCreateRigidBody(mass, startTransform, trimeshShape);

      Vector3f linVel = new Vector3f(destination.x - camPos.x, destination.y - camPos.y, destination.z - camPos.z);
      linVel.normalize();
      linVel.scale(ShootBoxInitialSpeed * 0.25f);

      Transform tr = new Transform();
      tr.origin.set(camPos);
      tr.setRotation(new Quat4f(0f, 0f, 0f, 1f));
View Full Code Here

      transform.origin.set(boneOrigin);

      // thigh
      Vector3f toBone = new Vector3f(boneOrigin);
      toBone.sub(root);
      toBone.normalize();
      Vector3f axis = new Vector3f();
      axis.cross(toBone,up);
      Quat4f q = new Quat4f();
      QuaternionUtil.setRotation(q, axis, BulletGlobals.SIMD_HALF_PI);
      transform.setRotation(q);
View Full Code Here

    // solve orthogonal angular velocity correction
    float len = velrelOrthog.length();
    if (len > 0.00001f) {
      Vector3f normal = Stack.alloc(Vector3f.class);
      normal.normalize(velrelOrthog);
      float denom = rbA.computeAngularImpulseDenominator(normal) + rbB.computeAngularImpulseDenominator(normal);
      velrelOrthog.scale((1f / denom) * dampingOrthoAng * softnessOrthoAng);
    }

    // solve angular positional correction
View Full Code Here

    angularError.cross(axisA, axisB);
    angularError.scale(1f / timeStep);
    float len2 = angularError.length();
    if (len2 > 0.00001f) {
      Vector3f normal2 = Stack.alloc(Vector3f.class);
      normal2.normalize(angularError);
      float denom2 = rbA.computeAngularImpulseDenominator(normal2) + rbB.computeAngularImpulseDenominator(normal2);
      angularError.scale((1f / denom2) * restitutionOrthoAng * softnessOrthoAng);
    }

    // apply impulse
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.