Examples of Vector3f


Examples of javax.vecmath.Vector3f

        BroadphaseInterface broadphase = new DbvtBroadphase();
        CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
        CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
        ConstraintSolver solver = new SequentialImpulseConstraintSolver();
        dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
        dynamicsWorld.setGravity(new Vector3f(0, -10 /* m/s2 */, 0));
        CollisionShape groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 0.25f /* m */);
        CollisionShape ballShape = new SphereShape(3.0f);
        MotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(
                new Quat4f(0, 0, 0, 1),
                new Vector3f(0, 0, 0), 1.0f)));
        RigidBodyConstructionInfo groundBodyConstructionInfo = new RigidBodyConstructionInfo(0, groundMotionState, groundShape, new Vector3f(0, 0, 0));
        groundBodyConstructionInfo.restitution = 0.25f;
        RigidBody groundRigidBody = new RigidBody(groundBodyConstructionInfo);
        dynamicsWorld.addRigidBody(groundRigidBody);
        MotionState ballMotionState = new DefaultMotionState(DEFAULT_BALL_TRANSFORM);
        Vector3f ballInertia = new Vector3f(0, 0, 0);
        ballShape.calculateLocalInertia(2.5f, ballInertia);
        RigidBodyConstructionInfo ballConstructionInfo = new RigidBodyConstructionInfo(2.5f, ballMotionState, ballShape, ballInertia);
        ballConstructionInfo.restitution = 0.5f;
        ballConstructionInfo.angularDamping = 0.95f;
        controlBall = new RigidBody(ballConstructionInfo);
View Full Code Here

Examples of javax.vecmath.Vector3f

    private static void render() {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        for (RigidBody body : balls) {
            glPushMatrix();
            Vector3f ballPosition = body.getWorldTransform(new Transform()).origin;
            glTranslatef(ballPosition.x, ballPosition.y, ballPosition.z);
            sphere.setDrawStyle(GLU.GLU_SILHOUETTE);
            if (body.equals(controlBall)) {
                glColor4f(0, 1, 0, 1);
            } else {
View Full Code Here

Examples of javax.vecmath.Vector3f

        glLoadIdentity();
        camera.applyTranslations();
        dynamicsWorld.stepSimulation(1.0f / 60.0f);
        Set<RigidBody> ballsToBeRemoved = new HashSet<RigidBody>();
        for (RigidBody body : balls) {
            Vector3f position = body.getMotionState().getWorldTransform(new Transform()).origin;
            if (!body.equals(controlBall) && (position.x < -50 || position.x > 50 || position.z < -50 || position.z > 50)) {
                ballsToBeRemoved.add(body);
            }
        }
        for (RigidBody body : ballsToBeRemoved) {
            balls.remove(body);
            dynamicsWorld.removeRigidBody(body);
        }
        if (applyForce) {
            Transform controlBallTransform = new Transform();
            controlBall.getMotionState().getWorldTransform(controlBallTransform);
            Vector3f controlBallLocation = controlBallTransform.origin;
            Vector3f cameraPosition = new Vector3f(camera.x(), camera.y(), camera.z());
            Vector3f force = new Vector3f();
            force.sub(cameraPosition, controlBallLocation);
            controlBall.activate(true);
            controlBall.applyCentralForce(force);
        }
        if (createNewShape) {
            CollisionShape shape = new SphereShape(3.0f);
            DefaultMotionState motionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(camera.x(), 35, camera.z()), 1)));
            Vector3f inertia = new Vector3f();
            shape.calculateLocalInertia(1.0f, inertia);
            RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo(1.0f, motionState, shape, inertia);
            constructionInfo.restitution = 0.75f;
            RigidBody body = new RigidBody(constructionInfo);
            dynamicsWorld.addRigidBody(body);
            balls.add(body);
            createNewShape = false;
        }
        if (resetControlBall) {
            controlBall.setCenterOfMassTransform(DEFAULT_BALL_TRANSFORM);
            controlBall.setAngularVelocity(new Vector3f(0, 0, 0));
            controlBall.setLinearVelocity(new Vector3f(0, 0, 0));
            resetControlBall = false;
        }
    }
View Full Code Here

Examples of javax.vecmath.Vector3f

        RigidBody getPhysicsBody() {
            return physicsBody;
        }

        Vector3f getPosition() {
            return physicsBody.getCenterOfMassPosition(new Vector3f());
        }
View Full Code Here

Examples of net.jsoundsystem.utils.Vector3f

    soundFormat = format;
    soundData = data;
  }
 
  public void enableSpatializedSound(){
    source = new Vector3f();
    simulate3DEffect = true;
  }
View Full Code Here

Examples of net.rim.device.api.math.Vector3f

     * @param position
     *            The position vector for the character
     */
    SpriteGameCharacter(final String texture, final Animator animator,
            final Vector3f position) {
        super(TEXCOORDS, texture, new BoundingBox(new Vector3f(-1.0f, -1.0f,
                0.0f), new Vector3f(1.0f, 1.0f, 0.0f)), position);

        _transform.setScale(new Vector3f(DEFAULT_SCALE, DEFAULT_SCALE,
                DEFAULT_SCALE));

        _prevTransform = new Transform3D(_transform);
        _prevBounds = new BoundingBox();

View Full Code Here

Examples of org.lwjgl.util.vector.Vector3f

      e.printStackTrace();
    }


    int lastError;
    Vector3f sourcePosition = new Vector3f();
    Vector3f listenerPosition = new Vector3f();
   
    //initialize keyboard
    try {
      Keyboard.create();
    } catch (Exception e) {
View Full Code Here

Examples of org.lwjgl.util.vector.Vector3f

        lightProjection.flip();
        lightModelView.flip();

        Matrix4f tempMatrix = new Matrix4f();
        tempMatrix.setIdentity();
        tempMatrix.translate(new Vector3f(0.5F, 0.5F, 0.5F));
        tempMatrix.scale(new Vector3f(0.5F, 0.5F, 0.5F));
        Matrix4f.mul(tempMatrix, lightProjectionTemp, textureMatrix);
        Matrix4f.mul(textureMatrix, lightModelViewTemp, tempMatrix);
        Matrix4f.transpose(tempMatrix, textureMatrix);
    }
View Full Code Here

Examples of org.lwjgl.util.vector.Vector3f

            glMaterialf(GL_FRONT, GL_SHININESS, 120);
            glColor3f(0.4f, 0.27f, 0.17f);
            glBegin(GL_TRIANGLES);
            for (Model.Face face : m.getFaces()) {
                if (face.hasNormals()) {
                    Vector3f n1 = m.getNormals().get(face.getNormalIndices()[0] - 1);
                    glNormal3f(n1.x, n1.y, n1.z);
                }
                Vector3f v1 = m.getVertices().get(face.getVertexIndices()[0] - 1);
                glVertex3f(v1.x, v1.y, v1.z);
                if (face.hasNormals()) {
                    Vector3f n2 = m.getNormals().get(face.getNormalIndices()[1] - 1);
                    glNormal3f(n2.x, n2.y, n2.z);
                }
                Vector3f v2 = m.getVertices().get(face.getVertexIndices()[1] - 1);
                glVertex3f(v2.x, v2.y, v2.z);
                if (face.hasNormals()) {
                    Vector3f n3 = m.getNormals().get(face.getNormalIndices()[2] - 1);
                    glNormal3f(n3.x, n3.y, n3.z);
                }
                Vector3f v3 = m.getVertices().get(face.getVertexIndices()[2] - 1);
                glVertex3f(v3.x, v3.y, v3.z);
            }
            glEnd();
        }
        glEndList();
View Full Code Here

Examples of org.lwjgl.util.vector.Vector3f

    private static Vector3f parseVertex(String line) {
        String[] xyz = line.split(" ");
        float x = Float.valueOf(xyz[1]);
        float y = Float.valueOf(xyz[2]);
        float z = Float.valueOf(xyz[3]);
        return new Vector3f(x, y, z);
    }
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.