Package javax.vecmath

Examples of javax.vecmath.Vector3f


    return element;

  }

  void translate(float x, float y, float z) {
    Vector3f offset3f = new Vector3f(x, y, z);
    offset3f.scale(GLOBAL.jBullet.scale);
    this.rigidBody.translate(offset3f);
    GLOBAL.jBullet.update();
    this.startWorldTransform.origin.set(offset3f);
  }
View Full Code Here


    //this.buildCoverMesh(indexVertexArrays, centreOfMass);

    if (indexVertexArrays != null) {
      trimesh = new GImpactMeshShape(indexVertexArrays);
      trimesh.setLocalScaling(new Vector3f(1f, 1f, 1f));
      trimesh.updateBound();
      // rigidBody.setMotionState(myMotionState);
      if (trimesh != null && this.rigidBody != null)
        this.rigidBody.setCollisionShape(trimesh);

      if (this.rigidBody == null || trimesh == null)
        return;

      Transform transform = new Transform();
      MotionState motionstate = rigidBody.getMotionState();
      motionstate.getWorldTransform(transform);
      Matrix4f chairMatrix = new Matrix4f();
      transform.getMatrix(chairMatrix);
      //  LOGGER.debug("current origin"+transform.origin.toString());

      //this is overwritten when settign the chair matrix
      //transform.origin.set(this.centreOfMass.x, this.centreOfMass.y,
      //    this.centreOfMass.z);

      LOGGER.debug("delta x" + deltaCentreOfmass.x);
      LOGGER.debug("delta y" + deltaCentreOfmass.y);
      LOGGER.debug("delta z" + deltaCentreOfmass.z);

      float newX = ((chairMatrix.m00) * deltaCentreOfmass.x)
          + ((chairMatrix.m01) * deltaCentreOfmass.y)
          + ((chairMatrix.m02) * deltaCentreOfmass.z);
      float newY = (((chairMatrix.m10) * deltaCentreOfmass.x)
          + ((chairMatrix.m11) * deltaCentreOfmass.y) + ((chairMatrix.m12) * deltaCentreOfmass.z));
      float newZ = ((chairMatrix.m20) * deltaCentreOfmass.x)
          + ((chairMatrix.m21) * deltaCentreOfmass.y)
          + ((chairMatrix.m22) * deltaCentreOfmass.z);

      //these are the origin
      chairMatrix.m03 -= deltaCentreOfmass.x;//10;//deltaCentreOfmass.x;
      chairMatrix.m13 -= deltaCentreOfmass.y;//deltaCentreOfmass.y;
      chairMatrix.m23 += deltaCentreOfmass.z;//deltaCentreOfmass.z;

      //chairMatrix.m03 = this.centreOfMass.x;
      //chairMatrix.m13 = this.centreOfMass.y;
      //chairMatrix.m23 = this.centreOfMass.z;

      LOGGER.debug("delta x t " + newX);
      LOGGER.debug("delta y t " + newY);
      LOGGER.debug("delta z t " + newZ);

      transform.set(chairMatrix);
      motionstate.setWorldTransform(transform);
      rigidBody.setMotionState(motionstate);

      Vector3f center = new Vector3f();
      rigidBody.getCenterOfMassPosition(center);
      LOGGER.debug("getCenterOfMassPosition set " + center);

      // System.out.println("weight" + this.getArea());
      Vector3f AngularVelocity = new Vector3f(0, 0, 0);
      rigidBody.getAngularVelocity(AngularVelocity);

      Vector3f LinearVelocity = new Vector3f(0, 0, 0);
      rigidBody.getLinearVelocity(LinearVelocity);

      GLOBAL.jBullet.update();

      motionstate.getWorldTransform(transform);
View Full Code Here

            GLOBAL.shapePack.zoomView(notches / 10f,GLOBAL.uiTools.mouseX,GLOBAL.uiTools.mouseY);

      }}
    });

    GLOBAL.person = new ergoDoll(GLOBAL.jBullet.myWorld, new Vector3f(-80,
        -10, 0), 1f);
   
   
    //GLOBAL.person.translate(-90, -10, 0);
    //GLOBAL.person.scale(60f);
View Full Code Here

  public RigidBody getOver(float x, float y) {
    x = (int) this.scaleVal(x);
    y = (int) this.scaleVal(y);

    Vector3f rayTo = new Vector3f(getRayToCustom(x, y));

    // add a point to point constraint for picking
    if (myWorld != null) {
      CollisionWorld.ClosestRayResultCallback rayCallback = new CollisionWorld.ClosestRayResultCallback(
          cameraPosition, rayTo);
View Full Code Here

    float bottom = -1f;
    float nearPlane = 1f;
    float tanFov = (top - bottom) * 0.5f / nearPlane;
    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);

    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);

    float aspect = glutScreenHeight / glutScreenWidth;

    hor.scale(2f * farPlane * tanfov);
    vertical.scale(2f * farPlane * tanfov);

    if (aspect < 1f) {
      hor.scale(1f / aspect);
    } else {
      vertical.scale(aspect);
    }

    Vector3f rayToCenter = new Vector3f();
    rayToCenter.add(rayFrom, rayForward);
    Vector3f dHor = new Vector3f(hor);
    dHor.scale(1f / glutScreenWidth);
    Vector3f dVert = new Vector3f(vertical);
    dVert.scale(1.f / glutScreenHeight);

    Vector3f tmp1 = new Vector3f();
    Vector3f tmp2 = new Vector3f();
    tmp1.scale(0.5f, hor);
    tmp2.scale(0.5f, vertical);

    Vector3f rayTo = new Vector3f();
    rayTo.sub(rayToCenter, tmp1);
    rayTo.add(tmp2);

    tmp1.scale(x, dHor);
    tmp2.scale(y, dVert);

    rayTo.add(tmp1);
    rayTo.sub(tmp2);
    return rayTo;
  }
View Full Code Here

    rayTo.sub(tmp2);
    return rayTo;
  }

  public Vector3f getRayToCustom(float x, float y) {
    Vector3f rayTo = new Vector3f(x, y, -1000);
    //  cameraPosition = new Vector3f(x,y,10);
    cameraPosition.x = x;
    cameraPosition.y = y;
    cameraPosition.z = 1000;
    return rayTo;
View Full Code Here

    // the maximum size of the collision world. Make sure objects stay
    // within these boundaries
    // TODO: AxisSweep3
    // Don't make the world AABB size too large, it will harm simulation
    // quality and performance
    Vector3f worldAabbMin = new Vector3f(-100000, -100000, -100000);
    Vector3f worldAabbMax = new Vector3f(100000, 100000, 100000);
    overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax);

    //overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax,
    //    MAX_PROXIES);
    // overlappingPairCache = new SimpleBroadphase(MAX_PROXIES);

    // the default constraint solver. For parallel processing you can use a
    // different solver (see Extras/BulletMultiThreaded)
    SequentialImpulseConstraintSolver sol = new SequentialImpulseConstraintSolver();
    solver = sol;

    // TODO: needed for SimpleDynamicsWorld
    // sol.setSolverMode(sol.getSolverMode() &
    // ~SolverMode.SOLVER_CACHE_FRIENDLY.getMask());

    myWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache,
        solver, collisionConfiguration);
    // dynamicsWorld = new SimpleDynamicsWorld(dispatcher,
    // overlappingPairCache, solver, collisionConfiguration);

    myWorld.setGravity(new Vector3f(0f, 3, 0f));

    // create a few basic rigid bodies
    // CollisionShape groundShape = new BoxShape(new Vector3f(50f, 50f,
    // 50f));
    CollisionShape groundShape = new StaticPlaneShape(
        new Vector3f(0, -1, 0), 1);

    collisionShapes.add(groundShape);

    Transform groundTransform = new Transform();
    groundTransform.setIdentity();
    groundTransform.origin.set(this.scaleVal(600), this.scaleVal(1600),
        this.scaleVal(600));

    CollisionShape constrainPlane = new StaticPlaneShape(new Vector3f(0, 0,
        1), 1);

    Vector3f localInertia2 = new Vector3f(0, 0, 0);
    Transform planeTransform = new Transform();
    planeTransform.setIdentity();
    planeTransform.origin.set(this.scaleVal(600), this.scaleVal(600),
        this.scaleVal(0));

    // using motionstate is recommended, it provides interpolation
    // capabilities, and only synchronizes 'active' objects
    DefaultMotionState myMotionState2 = new DefaultMotionState(
        planeTransform);
    RigidBodyConstructionInfo rbInfo2 = new RigidBodyConstructionInfo(0,
        myMotionState2, constrainPlane, localInertia2);
    RigidBody body2 = new RigidBody(rbInfo2);
    this.constrainPlane2D = body2;

    // We can also use DemoApplication::localCreateRigidBody, but for
    // clarity it is provided here:
    {
      float mass = 0f;

      // rigidbody is dynamic if and only if mass is non zero, otherwise
      // static
      boolean isDynamic = (mass != 0f);

      Vector3f localInertia = new Vector3f(0, 0, 0);
      if (isDynamic) {
        groundShape.calculateLocalInertia(mass, localInertia);
      }

      // using motionstate is recommended, it provides interpolation
View Full Code Here

  void mouseDown(float x, float y) {

    x = (int) this.scaleVal(x);
    y = (int) this.scaleVal(y);

    Vector3f rayTo = new Vector3f(getRayToCustom(x, y));

    if (pickConstraint != null && myWorld != null) {
      myWorld.removeConstraint(pickConstraint);
      // delete m_pickConstraint;
      //printf("removed constraint %i",gPickingConstraintId);
      pickConstraint = null;
      pickedBody.forceActivationState(CollisionObject.ACTIVE_TAG);
      pickedBody.setDeactivationTime(0f);
      pickedBody = null;
    }

    // add a point to point constraint for picking
    if (myWorld != null) {
      CollisionWorld.ClosestRayResultCallback rayCallback = new CollisionWorld.ClosestRayResultCallback(
          cameraPosition, rayTo);
      myWorld.rayTest(cameraPosition, rayTo, rayCallback);
      if (rayCallback.hasHit()) {

        RigidBody body = RigidBody.upcast(rayCallback.collisionObject);
        if (body != null) {

          //if physics is off turn it on
          //if(  !SETTINGS.physics_on)
          //  SETTINGS.physics_on = true;

          // other exclusions?
          if (!(body.isStaticObject() || body.isKinematicObject())) {
            pickedBody = body;
            pickedBody
                .setActivationState(CollisionObject.DISABLE_DEACTIVATION);

            Vector3f pickPos = new Vector3f(
                rayCallback.hitPointWorld);

            Transform tmpTrans = body
                .getCenterOfMassTransform(new Transform());
            tmpTrans.inverse();
            Vector3f localPivot = new Vector3f(pickPos);
            tmpTrans.transform(localPivot);

            Point2PointConstraint p2p = new Point2PointConstraint(
                body, localPivot);
            myWorld.addConstraint(p2p);
            pickConstraint = p2p;
            // save mouse position for dragging
            BulletStats.gOldPickingPos.set(rayTo);
            Vector3f eyePos = new Vector3f(cameraPosition);
            Vector3f tmp = new Vector3f();
            //tmp.sub(pickPos, eyePos);
            //BulletStats.gOldPickingDist = tmp.length();
            this.pickDist = pickPos.z;
            // very weak constraint for picking
            p2p.setting.tau = 0.2f;
View Full Code Here

        //Vector3f dir = new Vector3f();
        //dir.sub(newRayTo, eyePos);
        //dir.normalize();
        //dir.scale(BulletStats.gOldPickingDist);

        Vector3f newPos = new Vector3f(x, y, this.pickDist);
        //newPos.add(eyePos, dir);
        p2p.setPivotB(newPos);
      }
    }
View Full Code Here

      // fill(fallRigidBody.c);
      // do the actual drawing of the object

      CollisionShape col = rBody.getCollisionShape();
      //if (col.isPolyhedral()) {
        Vector3f posP = new Vector3f();
        float[] sizeP = { 0 };
        col.getBoundingSphere(posP, sizeP);
        g.pushMatrix();
        g.translate(posP.x, posP.y, posP.z);
        g.sphere(sizeP[0]);
        g.popMatrix();

      //}

      if (col.getShapeType() == BroadphaseNativeType.GIMPACT_SHAPE_PROXYTYPE) {

        ConcaveShape polyshape = (ConcaveShape) col;
        /*
        int i;
        for (i=0;i<polyshape.getNumEdges();i++)
        {
          Vector3f a = Stack.alloc(Vector3f.class);
          Vector3f b = Stack.alloc(Vector3f.class);;
          polyshape.getEdge(i,a,b);
          Vector3f tmp2 = new Vector3f(0f, 0f, 1f);

          debugD.drawLine(a, b, tmp2);
        //          getDebugDrawer()->drawLine(wa,wb,color);
        //
        }
        */
        //
        //
      }

      if (col.getShapeType() == BroadphaseNativeType.CAPSULE_SHAPE_PROXYTYPE) {
        Vector3f pos = new Vector3f();
        // System.out.println("capsula");
        float[] size = { 0 };
        //col.getAabb(t, aabbMin, aabbMax)
        col.getBoundingSphere(pos, size);
        g.pushMatrix();
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector3f

Copyright © 2018 www.massapicom. 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.