Package aspect.util

Examples of aspect.util.Vector3


           
            int nv = pipeVertices(branchWidth, branchLength, LOD, vertices, vpos);
            int nt = pipeTexCoords(1, 1, LOD, texCoords, tpos);
            int nn = pipeNormals(LOD, normals, npos);
           
            Vector3 pos = new Vector3(Trig.sin(branchYaw), -Trig.cos(branchPitch), Trig.cos(branchYaw));
            pos = pos.times(branchLength / 2.0f);
            pos.y += branchHeight - height / 2;
           
            Angles ang = Angles.zero();
            ang.pitch = 75;
            ang.yaw = branchYaw;
View Full Code Here


        p = new Player(Vector3.zero());
        p.setWalkSpeed(50);
        Light l = new Light(Color.WHITE);
        l.directional = true;
        l.pos = new Vector3(0, 1, 0);

        l.setAttenuation(1.0f, 0.0f, 0.0f);

        crosshair = sprite(new Material(loadTexture(new File("materials/crosshair.png"))), 1, 1);

        int pow = 8;

        int w = (1 << pow);

        t = new float[w][w];

        ///diamondSquare(t, w);
        //NoiseTest.generateTerrain(t, w);
        FFTTest.generateTerrain(t, w);

        try {
            fbo = new FrameBuffer(1024, 1024, p);
            fbo.setRepeat(false);
            fbo.setFilter(GL11.GL_NEAREST, GL11.GL_NEAREST);
            Shader vert = Shader.loadPrebuilt("texture.vert", Shader.Type.VERTEX);
            Shader frag = loadShader(new File("shaders/test.frag"), Shader.Type.FRAGMENT);
            post = new ShaderProgram(vert, frag);
            fbo.postProcess(post);
        } catch (LWJGLException ex) {
            Logger.getLogger(AspectTest.class.getName()).log(Level.SEVERE, null, ex);
        }

        terrain = new Entity(genMesh(t, new Material(loadTexture(new File("materials/rock.jpg"))), 32.0f, 0.25f));
        //Material wat = new Material(new Color(0.0f, 0.1f, 0.6f, 0.7f));
        Material wat = new Material(loadTexture(new File("materials/water.jpg")));
        //wat.specular = Color.WHITE;
        wat.shininess = 0.05f;
        wat.shader = ShaderProgram.loadPrebuilt("water");
        water = new Entity(rect(wat, 8.0f, 8.0f, w, w));

        water.ang.pitch = -90;
        water.pos = new Vector3(w / 2.0f, 0, w / 2.0f);
        Material sky = new Material(loadTexture(new File("materials/stars.jpg")));
        sky.shader = ShaderProgram.TEXTURE;
        skybox = box(sky, 1.0f, 1.0f, 1.0f);

        //makeFog(0.01f, Color.WHITE, 1);
        world = new ListWorld();

        for (int i = 0; i < 50; i++) {
            int x;
            int z;

            do {
                x = r.nextInt(w);
                z = r.nextInt(w);
            } while (t[x][z] < 0.0f);

            Tree tree = new Tree();
            tree.pos = new Vector3(x, t[x][z] + tree.height / 2, z);

            world.add(tree);
        }
    }
View Full Code Here

        }
       
        float dx = x - i;
        float dz = z - j;
       
        Vector3 point1 = new Vector3(i, t[i][j], j);
        Vector3 point2 = new Vector3(i + 1, t[i + 1][j + 1], j + 1);
        Vector3 point3;
       
        if (dx > dz) {
            point3 = new Vector3(i + 1, t[i + 1][j], j);
        } else {
            point3 = new Vector3(i, t[i][j + 1], j + 1);
        }
       
        Vector3 normal = normal(point1, point2, point3);
       
        float a = normal.x;
        float b = normal.y;
        float c = normal.z;
        float d = -(a * point1.x + b * point1.y + c * point1.z);
 
View Full Code Here

            for (int j = 0; j < heightmap[0].length - 1; j++) {
                int index = (i * (heightmap.length - 1) + j) * 18;

                int tindex = (i * (heightmap.length - 1) + j) * 12;

                Vector3 v1 = new Vector3(i * scale, heightmap[i][j], j * scale);
                Vector3 v2 = new Vector3(i * scale, heightmap[i][j + 1], (j + 1) * scale);
                Vector3 v3 = new Vector3((i + 1) * scale, heightmap[i + 1][j + 1], (j + 1) * scale);
                Vector3 v4 = new Vector3((i + 1) * scale, heightmap[i + 1][j], j * scale);

                vertices[index + 0] = v1.x;
                vertices[index + 1] = v1.y;
                vertices[index + 2] = v1.z;

View Full Code Here

       
        printGlVersion();
        player = new Player(Vector3.zero());
        Material material = new Material(Texture.create(UNLOADED_IMAGE));
        cube = new Entity(box(material, 0.9f, 0.7f, 0.6f));
        cube.pos = new Vector3(-1, 0, -4);
        cube.ang.pitch = -20;
        pipe = new Entity(pipe(material, 0.5f, 2, 60));
        pipe.pos = new Vector3(1, 0, -4);
       
        Shader vertex = new Shader(new File("shaders/example.vert"), Type.VERTEX);
        Shader fragment1 = new Shader(new File("shaders/example1.frag"), Type.FRAGMENT);
        Shader fragment2 = new Shader(new File("shaders/example2.frag"), Type.FRAGMENT);
       
View Full Code Here

    public float health = 100.0f;
   
    private Behavior flight;

    public Fighter(Fighter leader) {
        super(loadObjModel("fighter", new File("models/fighter.obj"), new Vector3(0.25f)));

        final Motion m = new Motion();
        m.velocity = new Vector3(0, 0, -5);
        addBehavior(m);

        if (leader == null) {
            flight = new Behavior() {
                @Override
                public void update() {
                    m.acceleration = transform.right().times(m.velocity.mag2() / radius);
                   
                    Vector3 vn = m.velocity.normalize();
                    transform.setForward(vn);
                   
                    if (m.velocity.mag() > 5) {
                        m.velocity = vn.times(5);
                    }
                }
            };
        } else {
            flight = new FollowEntity(leader);
View Full Code Here

        addBehavior(rigidBody);
        rigidBody.velocity = motion.velocity;
       
        World.main.add(new Explosion(transform.position));
       
        rigidBody.impel(new Vector3(2.0f, 0, 0), new Vector3(0, 1.0f, 0));
    }
View Full Code Here

    public void onAdd() {
        Material earthImage = new Material(loadTexture(new File("textures/earth.png")));
        float earthWidth = 6378.1e3f * 2;
        ViewModel earthSprite = ellipse(earthImage, earthWidth, earthWidth, 100);
        earth = new Entity(earthSprite);
        earth.pos = new Vector3(getCanvasWidth() / 4, getCanvasHeight() / 4, 0);
        earth.addBehavior(new RigidBody());
        earth.rigidBody().mass = 5.97219e24f;

        Material moonImage = new Material(loadTexture(new File("textures/moon.png")));
        float moonWidth = 1737.4e3f * 2;
        ViewModel moonSprite = ellipse(moonImage, moonWidth, moonWidth, 100);
        moon = new Entity(moonSprite);
        moon.pos = new Vector3(earth.pos.x - 384400e3f, earth.pos.y);
        moon.addBehavior(new RigidBody());
        moon.rigidBody().mass = 7.34767309e22f;

        yesThrust = new Material(loadTexture("nothrust", new File("textures/ship.png")));
        yesThrust.setTextureFilter(Material.Filter.MIPMAP, Material.Filter.NEAREST);
        noThrust = new Material(loadTexture("thrust", new File("textures/ship_thrust.png")));
        noThrust.setTextureFilter(Material.Filter.MIPMAP, Material.Filter.NEAREST);
        ViewModel model = rect2D(noThrust, 37.5f, 50f);
        ship = new Entity(model);
        ship.pos = new Vector3(earth.pos.x, earth.pos.y + earthWidth / 2 + 300e3f);
        ship.addBehavior(new RigidBody());
        ship.rigidBody().mass = 78e3f;
        ship.rigidBody().velocity.x = 7700f;

        earthGravity = new PointGravity(earth);
View Full Code Here

    public void render() {

        AspectRenderer.setRenderMode(RenderMode.ORTHOGONAL);
        loadIdentity();
        pushMatrix();
        translate(new Vector3(getCanvasWidth() / 2, getCanvasHeight() / 2));
        background.render();
        popMatrix();
        setupCamera2D(viewpoint);

        earth.render();
        moon.render();
        ship.render();

        if (hud) {
            RigidBody rb = ship.rigidBody();
            Vector2 v = Vector2.fromAngle(-ship.ang.roll, 50 / viewpoint.scale);
            Vector2 a1 = Vector2.fromAngle(-ship.ang.roll + 140, 10 / viewpoint.scale);
            Vector2 a2 = Vector2.fromAngle(-ship.ang.roll - 140, 10 / viewpoint.scale);
            glColor3f(1, 0, 0);
            glBegin(GL_LINES);
            glVertex2f(ship.pos.x, ship.pos.y);
            glVertex2f(ship.pos.x + v.x, ship.pos.y + v.y);
            glVertex2f(ship.pos.x + v.x, ship.pos.y + v.y);
            glVertex2f(ship.pos.x + v.x + a1.x, ship.pos.y + v.y + a1.y);
            glVertex2f(ship.pos.x + v.x, ship.pos.y + v.y);
            glVertex2f(ship.pos.x + v.x + a2.x, ship.pos.y + v.y + a2.y);
            glEnd();

            Vector3 forceVector = rb.netForce();
            glColor3f(0, 0, 1);
            glBegin(GL_LINES);
            glVertex2f(ship.pos.x, ship.pos.y);
            glVertex2f(ship.pos.x + forceVector.x, ship.pos.y + forceVector.y);
            glEnd();

            glColor3f(0, 1, 0);
            glBegin(GL_LINE_STRIP);

            Vector3 curVel = rb.velocity.copy();
            Vector3 curPos = ship.pos.copy();

            glVertex2f(curPos.x, curPos.y);
            float tick = 5f;
            boolean readyToStop = false;
            for (float t = 0; t < 8000; t += tick) {
                Entity e = new Entity();
                e.addBehavior(new RigidBody(curVel, Vector3.zero()));
                e.rigidBody().addForce(moonGravity);
                e.rigidBody().addForce(earthGravity);
                e.pos = curPos;
                Vector3 realAcc = rb.acceleration.plus(Vector3.divide(e.rigidBody().netForce(), e.rigidBody().mass));
                Vector3 velOld = curVel;
                curVel = curVel.plus(realAcc.times(tick));
                curPos = curPos.plus(Vector3.multiply(Vector3.add(Vector3.multiply(velOld, tick), Vector3.multiply(curVel, tick)), 0.5f));
                glVertex2f(curPos.x, curPos.y);

                if (Vector2.toAngle(earth.pos.xy(), ship.pos.xy()) < Vector2.toAngle(earth.pos.xy(), curPos.xy())) {
View Full Code Here

   
    private final Behavior[] controls;
    private int control = 0;

    public Frigate() {
        super(loadObjModel("frigate", new File("models/frigate_body.obj"), new Vector3(10.0f)));

        rigidBody = new RigidBody();
        rigidBody.mass = 10.0f;
        rigidBody.setUniformMOI(100);
        addBehavior(rigidBody);

        ViewModel engineRight = loadObjModel("rengine", new File("models/thruster_medium.obj"), new Vector3(10.0f));
        ViewModel engineLeft = loadObjModel("lengine", new File("models/thruster_medium.obj"), new Vector3(-10.0f, 10.0f, 10.0f));

        engineRF = new Entity(engineRight);
        engineRR = new Entity(engineRight);
        engineLF = new Entity(engineLeft);
        engineLR = new Entity(engineLeft);

        engineLF.transform.scale.x = -1.0f;
        engineLR.transform.scale.x = -1.0f;
        engineRR.transform.position = new Vector3(8.1f, 0.5f, 6.7f);
        engineRF.transform.position = new Vector3(10.1f, -0.5f, -6.7f);
        engineLR.transform.position = new Vector3(-8.1f, 0.5f, 6.7f);
        engineLF.transform.position = new Vector3(-10.1f, -0.5f, -6.7f);

        addChild(engineLR);
        addChild(engineLF);
        addChild(engineRF);
        addChild(engineRR);

        ViewModel turret = loadObjModel("turret", new File("models/turret.obj"), new Vector3(10.0f));

        Entity turret1 = new Entity(turret);
        Entity turret2 = new Entity(turret);
        Entity turret3 = new Entity(turret);
        Entity turret4 = new Entity(turret);
        Entity turret5 = new Entity(turret);
        Entity turret6 = new Entity(turret);

        turret1.transform.position = new Vector3(1.25f, 1.2f, 9.0f);
        turret2.transform.position = new Vector3(-1.25f, 1.2f, 9.0f);
        turret3.transform.position = new Vector3(1.25f, 1.2f, -2.5f);
        turret4.transform.position = new Vector3(-1.25f, 1.2f, -2.5f);
        turret5.transform.position = new Vector3(3.25f, 0.2f, -5.5f);
        turret6.transform.position = new Vector3(-3.25f, 0.2f, -5.5f);

        addChild(turret1);
        addChild(turret2);
        addChild(turret3);
        addChild(turret4);
View Full Code Here

TOP

Related Classes of aspect.util.Vector3

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.