Package com.bulletphysics.collision.shapes

Examples of com.bulletphysics.collision.shapes.SphereShape


            float kantenLaenge = 1 + ((float) (i)) / 50 + (float) rand.nextGaussian();
            CollisionShape box1;
            if (rand.nextDouble() < 0.9) {
                box1 = new BoxShape(new Vector3f(kantenLaenge, kantenLaenge, kantenLaenge));
            } else {
                box1 = new SphereShape(kantenLaenge);
            }
            env.getCollisionShapes().add(box1);
            env.addAgent(new Agent3D(
                    i,
                    env,
View Full Code Here


            vectorsPool.release(halfExtent);
            useWireframeFallback = false;
            break;
          }
          case SPHERE_SHAPE_PROXYTYPE: {
            SphereShape sphereShape = (SphereShape) shape;
            float radius = sphereShape.getMargin(); // radius doesn't include the margin, so draw with margin
            // TODO: glutSolidSphere(radius,10,10);
            //sphere.draw(radius, 8, 8);
            gl.drawSphere(radius, 10, 10);
            /*
            glPointSize(10f);
 
View Full Code Here

                if (body.getCollisionShape().isConvex()) {
                  BulletStats.gNumClampedCcdMotions++;

                  ClosestNotMeConvexResultCallback sweepResults = new ClosestNotMeConvexResultCallback(body, body.getWorldTransform(tmpTrans).origin, predictedTrans.origin, getBroadphase().getOverlappingPairCache(), getDispatcher());
                  //ConvexShape convexShape = (ConvexShape)body.getCollisionShape();
                  SphereShape tmpSphere = new SphereShape(body.getCcdSweptSphereRadius()); //btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());

                  sweepResults.collisionFilterGroup = body.getBroadphaseProxy().collisionFilterGroup;
                  sweepResults.collisionFilterMask = body.getBroadphaseProxy().collisionFilterMask;

                  convexSweepTest(tmpSphere, body.getWorldTransform(tmpTrans), predictedTrans, sweepResults);
View Full Code Here

  public static void rayTestSingle(Transform rayFromTrans, Transform rayToTrans,
      CollisionObject collisionObject,
      CollisionShape collisionShape,
      Transform colObjWorldTransform,
      RayResultCallback resultCallback) {
    SphereShape pointShape = new SphereShape(0f);
    pointShape.setMargin(0f);
    ConvexShape castShape = pointShape;

    if (collisionShape.isConvex()) {
      CastResult castResult = new CastResult();
      castResult.fraction = resultCallback.closestHitFraction;
View Full Code Here

    Transform tmpTrans1 = Stack.alloc(Transform.class);
    Transform tmpTrans2 = Stack.alloc(Transform.class);

    resultOut.setPersistentManifold(manifoldPtr);

    SphereShape sphere0 = (SphereShape) col0.getCollisionShape();
    SphereShape sphere1 = (SphereShape) col1.getCollisionShape();

    Vector3f diff = Stack.alloc(Vector3f.class);
    diff.sub(col0.getWorldTransform(tmpTrans1).origin, col1.getWorldTransform(tmpTrans2).origin);

    float len = diff.length();
    float radius0 = sphere0.getRadius();
    float radius1 = sphere1.getRadius();

    //#ifdef CLEAR_MANIFOLD
    //manifoldPtr.clearManifold(); // don't do this, it disables warmstarting
    //#endif
View Full Code Here

    // Convex0 against sphere for Convex1
    {
      ConvexShape convex0 = (ConvexShape) col0.getCollisionShape();

      SphereShape sphere1 = new SphereShape(col1.getCcdSweptSphereRadius()); // todo: allow non-zero sphere sizes, for better approximation
      ConvexCast.CastResult result = new ConvexCast.CastResult();
      VoronoiSimplexSolver voronoiSimplex = new VoronoiSimplexSolver();
      //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex);
      ///Simplification, one object is simplified as a sphere
      GjkConvexCast ccd1 = new GjkConvexCast(convex0, sphere1, voronoiSimplex);
      //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0);
      if (ccd1.calcTimeOfImpact(col0.getWorldTransform(tmpTrans1), col0.getInterpolationWorldTransform(tmpTrans2),
          col1.getWorldTransform(tmpTrans3), col1.getInterpolationWorldTransform(tmpTrans4), result)) {
        // store result.m_fraction in both bodies

        if (col0.getHitFraction() > result.fraction) {
          col0.setHitFraction(result.fraction);
        }

        if (col1.getHitFraction() > result.fraction) {
          col1.setHitFraction(result.fraction);
        }

        if (resultFraction > result.fraction) {
          resultFraction = result.fraction;
        }
      }
    }

    // Sphere (for convex0) against Convex1
    {
      ConvexShape convex1 = (ConvexShape) col1.getCollisionShape();

      SphereShape sphere0 = new SphereShape(col0.getCcdSweptSphereRadius()); // todo: allow non-zero sphere sizes, for better approximation
      ConvexCast.CastResult result = new ConvexCast.CastResult();
      VoronoiSimplexSolver voronoiSimplex = new VoronoiSimplexSolver();
      //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex);
      ///Simplification, one object is simplified as a sphere
      GjkConvexCast ccd1 = new GjkConvexCast(sphere0, convex1, voronoiSimplex);
View Full Code Here

      //btTransform ident;
      //ident.setIdentity();
     
      CastResult castResult = new CastResult();
      castResult.fraction = hitFraction;
      SphereShape pointShape = new SphereShape(ccdSphereRadius);
      TriangleShape triShape = new TriangleShape(triangle[0], triangle[1], triangle[2]);
      VoronoiSimplexSolver simplexSolver = new VoronoiSimplexSolver();
      SubsimplexConvexCast convexCaster = new SubsimplexConvexCast(pointShape, triShape, simplexSolver);
      //GjkConvexCast  convexCaster(&pointShape,convexShape,&simplexSolver);
      //ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0);
View Full Code Here

    {
      // create a dynamic rigidbody

      // btCollisionShape* colShape = new
      // btBoxShape(btVector3(1,1,1));
      CollisionShape colShape = new SphereShape(1.f);
      collisionShapes.add(colShape);

      // Create Dynamic Objects
      Transform startTransform = new Transform();
      startTransform.setIdentity();

      float mass = 1f;

      // 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) {
        colShape.calculateLocalInertia(mass, localInertia);
      }

      startTransform.origin.set(new Vector3f(2, 10, 0));

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

            halfExtents.scale(0.5f);
            return new BoxShape(halfExtents);
        }
        SphereShapeComponent sphere = entity.getComponent(SphereShapeComponent.class);
        if (sphere != null) {
            return new SphereShape(sphere.radius);
        }
        CapsuleShapeComponent capsule = entity.getComponent(CapsuleShapeComponent.class);
        if (capsule != null) {
            return new CapsuleShape(capsule.radius, capsule.height);
        }
View Full Code Here

            float radius = colliderDef.get(RADIUS).getAsFloat();
            if (offset == null) {
                throw new JsonParseException("Sphere Collider missing position");
            }

            return new ColliderInfo(offset, new SphereShape(radius));
        }
View Full Code Here

TOP

Related Classes of com.bulletphysics.collision.shapes.SphereShape

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.