Search in sources :

Example 36 with Vector3f

use of javax.vecmath.Vector3f in project bdx by GoranM.

the class BoxShape method getVertex.

@Override
public void getVertex(int i, Vector3f vtx) {
    Stack stack = Stack.enter();
    Vector3f halfExtents = getHalfExtentsWithoutMargin(stack.allocVector3f());
    vtx.set(halfExtents.x * (1 - (i & 1)) - halfExtents.x * (i & 1), halfExtents.y * (1 - ((i & 2) >> 1)) - halfExtents.y * ((i & 2) >> 1), halfExtents.z * (1 - ((i & 4) >> 2)) - halfExtents.z * ((i & 4) >> 2));
    stack.leave();
}
Also used : Vector3f(javax.vecmath.Vector3f) Stack(com.bulletphysics.util.Stack)

Example 37 with Vector3f

use of javax.vecmath.Vector3f in project bdx by GoranM.

the class BoxShape method setMargin.

@Override
public void setMargin(float margin) {
    Stack stack = Stack.enter();
    // correct the implicitShapeDimensions for the margin
    Vector3f oldMargin = stack.allocVector3f();
    oldMargin.set(getMargin(), getMargin(), getMargin());
    Vector3f implicitShapeDimensionsWithMargin = stack.allocVector3f();
    implicitShapeDimensionsWithMargin.add(implicitShapeDimensions, oldMargin);
    super.setMargin(margin);
    Vector3f newMargin = stack.allocVector3f();
    newMargin.set(getMargin(), getMargin(), getMargin());
    implicitShapeDimensions.sub(implicitShapeDimensionsWithMargin, newMargin);
    stack.leave();
}
Also used : Vector3f(javax.vecmath.Vector3f) Stack(com.bulletphysics.util.Stack)

Example 38 with Vector3f

use of javax.vecmath.Vector3f in project bdx by GoranM.

the class BoxShape method setLocalScaling.

@Override
public void setLocalScaling(Vector3f scaling) {
    Stack stack = Stack.enter();
    Vector3f oldMargin = stack.allocVector3f();
    oldMargin.set(getMargin(), getMargin(), getMargin());
    Vector3f implicitShapeDimensionsWithMargin = stack.allocVector3f();
    implicitShapeDimensionsWithMargin.add(implicitShapeDimensions, oldMargin);
    Vector3f unScaledImplicitShapeDimensionsWithMargin = stack.allocVector3f();
    VectorUtil.div(unScaledImplicitShapeDimensionsWithMargin, implicitShapeDimensionsWithMargin, localScaling);
    super.setLocalScaling(scaling);
    VectorUtil.mul(implicitShapeDimensions, unScaledImplicitShapeDimensionsWithMargin, localScaling);
    implicitShapeDimensions.sub(oldMargin);
    stack.leave();
}
Also used : Vector3f(javax.vecmath.Vector3f) Stack(com.bulletphysics.util.Stack)

Example 39 with Vector3f

use of javax.vecmath.Vector3f in project bdx by GoranM.

the class BoxShape method getHalfExtentsWithMargin.

public Vector3f getHalfExtentsWithMargin(Vector3f out) {
    Stack stack = Stack.enter();
    Vector3f halfExtents = getHalfExtentsWithoutMargin(out);
    Vector3f margin = stack.allocVector3f();
    margin.set(getMargin(), getMargin(), getMargin());
    halfExtents.add(margin);
    stack.leave();
    return out;
}
Also used : Vector3f(javax.vecmath.Vector3f) Stack(com.bulletphysics.util.Stack)

Example 40 with Vector3f

use of javax.vecmath.Vector3f in project bdx by GoranM.

the class BoxShape method getPlaneEquation.

public void getPlaneEquation(Vector4f plane, int i) {
    Stack stack = Stack.enter();
    Vector3f halfExtents = getHalfExtentsWithoutMargin(stack.allocVector3f());
    switch(i) {
        case 0:
            plane.set(1f, 0f, 0f, -halfExtents.x);
            break;
        case 1:
            plane.set(-1f, 0f, 0f, -halfExtents.x);
            break;
        case 2:
            plane.set(0f, 1f, 0f, -halfExtents.y);
            break;
        case 3:
            plane.set(0f, -1f, 0f, -halfExtents.y);
            break;
        case 4:
            plane.set(0f, 0f, 1f, -halfExtents.z);
            break;
        case 5:
            plane.set(0f, 0f, -1f, -halfExtents.z);
            break;
        default:
            assert (false);
    }
    stack.leave();
}
Also used : Vector3f(javax.vecmath.Vector3f) Stack(com.bulletphysics.util.Stack)

Aggregations

Vector3f (javax.vecmath.Vector3f)266 Stack (com.bulletphysics.util.Stack)197 Transform (com.bulletphysics.linearmath.Transform)53 Matrix3f (javax.vecmath.Matrix3f)25 ManifoldPoint (com.bulletphysics.collision.narrowphase.ManifoldPoint)14 StaticAlloc (com.bulletphysics.util.StaticAlloc)12 Matrix4f (javax.vecmath.Matrix4f)10 Vector4f (javax.vecmath.Vector4f)8 CollisionShape (com.bulletphysics.collision.shapes.CollisionShape)7 TypedConstraint (com.bulletphysics.dynamics.constraintsolver.TypedConstraint)7 CollisionObject (com.bulletphysics.collision.dispatch.CollisionObject)6 ObjectArrayList (com.bulletphysics.util.ObjectArrayList)5 Quat4f (javax.vecmath.Quat4f)5 ConvexShape (com.bulletphysics.collision.shapes.ConvexShape)4 SphereShape (com.bulletphysics.collision.shapes.SphereShape)4 RigidBody (com.bulletphysics.dynamics.RigidBody)4 HashMap (java.util.HashMap)4 VoronoiSimplexSolver (com.bulletphysics.collision.narrowphase.VoronoiSimplexSolver)3 CompoundShape (com.bulletphysics.collision.shapes.CompoundShape)3 ConcaveShape (com.bulletphysics.collision.shapes.ConcaveShape)3