Package aspect.entity

Examples of aspect.entity.Entity


                            entity.render();
                        }
                        ShaderProgram.unlock();

                        Color c = getPixelColor(new Vector2(getCanvasWidth() / 2, getCanvasHeight() / 2));
                        Entity hit = key.get(c);

                        if (hit instanceof Fighter) {
                            Fighter f = (Fighter) hit;
                            if (f.health > 0) {
                                f.health -= 200 * Time.deltaTime();
 
View Full Code Here


            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;
View Full Code Here

    public void onAdd() {
       
        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

   
    @Override
    public void onAdd() {
        Material material = new Material(loadTexture(new File("textures/tex.jpg")));
        ViewModel model = box(material, 1, 1, 1);
        cube = new Entity(model);
        cube.pos.z = -4;
        cube.addBehavior(new Seizure());
        cube.addBehavior(new CmpntRotate());
       
        addKeyListener(this);
View Full Code Here

        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);
View Full Code Here

        fe[3] = new Vector3(1.0f, 1.0f, -1.0f).normalize();
        fe[4] = new Vector3(-1.0f, 1.0f, -1.0f).normalize();
        fe[5] = new Vector3(-1.0f, 1.0f, 1.0f).normalize();

        ViewModel floorModel = loadObjModel(new File("models/platform.obj"), Vector3.one());
        Entity floor = new Entity(floorModel);

        floor.transform.position = new Vector3(0, -7, 0);

        //floor.transform.set(new Vector3(0, -12, 0), Vector3.yAxis().negate(), Vector3.zAxis(), Vector3.one());
        floor.addBehavior(new Collider(fv, fn, fe));

        World.main.add(floor);

        Light light = new Light(Color.WHITE);
        light.transform.position = new Vector3(-5, 5, 2);
        light.setAttenuation(1, 0, 0);

        //player = new Player(new Vector3(0, 0, 4));
        //World.main.add(player);
        camera = new Transform(new Vector3(-10, 10, 10), new Vector3(1, -1, -1), Vector3.yAxis(), Vector3.one());

        gravity = new UniformGravity();
        World.main.addForce(gravity);
       
        counter = new Canvas(128, 32);
        updateCounter();

        spawner = new Entity();
        spawner.transform.position.y = 15.0f;

        spawner.addBehavior(new Behavior() {
            private float timeUntilSpawn = 2.0f;

            @Override
            public void update() {
                timeUntilSpawn -= Time.deltaTime();

                if (timeUntilSpawn <= 0) {
                    float width = random.nextFloat() * 2.0f + 1.0f;
                    float height = random.nextFloat() * 2.0f + 1.0f;
                    float depth = random.nextFloat() * 2.0f + 1.0f;
                    final Entity entity = RigidBody.box(new Material(Color.random()), width, height, depth, 1.0f);

                    entity.addBehavior(new Behavior() {
                        @Override
                        public void update() {
                            if (entity.transform.position.y < -20.0f || isKeyDown(KEY_LCONTROL)) {
                                entity.destroy();
                                numBlocks--;
                                updateCounter();
                            }
                        }
                    });
View Full Code Here

    @Override
    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;

View Full Code Here

            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);
View Full Code Here

            }
        }
    }

    public static Entity box(Material material, float width, float height, float depth, float density) {
        Entity entity = new Entity(Resources.box(material, width, height, depth));
        entity.addBehavior(Collider.box(width, height, depth));
        entity.addBehavior(new RigidBody());

        entity.rigidBody().mass = width * height * depth * density;

        float w2 = width * width;
        float h2 = height * height;
        float d2 = depth * depth;

        float f = entity.rigidBody().mass / 12.0f;

        entity.rigidBody().setMomentsOfInertia(new Vector3(f * (h2 + d2), f * (w2 + d2), f * (w2 + h2)));

        return entity;
    }
View Full Code Here

    }

    @Override
    public void keyEvent(KeyEvent evt) {
        if (evt.key == Keyboard.KEY_RETURN && evt.type && !builder.min.equals(builder.max)) {
            Entity ent = new EditorBlock(shader, m, builder.min, builder.max);
            world.add(ent);
            ent.name = "Cube " + world.size();

            updateList();
            builder.max = Vector3.zero();
            builder.min = Vector3.zero();
           
            items.setSelectedValue(ent, false);
        } else if (evt.key == Keyboard.KEY_DELETE && evt.type) {
            Entity value = (Entity) items.getSelectedValue();
            if (value != null) {
                world.remove(value);
                updateList();
            }
        }
View Full Code Here

TOP

Related Classes of aspect.entity.Entity

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.