Exemplo n.º 1
0
  private void renderPlanet(
      GL10 gl,
      String texture,
      boolean uvtype,
      float radius,
      float x,
      float y,
      float z,
      Application app) {
    radius = radius * worldscale;

    if (texture.equals("earth")) {
      // render earth/jupiter  texture
      planetTexture.bind();
    } else if (texture.equals("sun")) {
      // render mars/sun  texture
      planetTexture.bind();
    }

    gl.glPushMatrix();
    // move away from origin
    gl.glTranslatef(x, y, z);
    // scale to 10% size of earth
    gl.glScalef(radius, radius, radius);
    gl.glRotatef((Splash.planetmove / 10) - 180, 0, 1, 0);
    if (uvtype == true) {
      // render lower planet texture
      planetMesh.render(GL10.GL_TRIANGLES);
    } else {
      // render upper planet texture
      planetMesh02.render(GL10.GL_TRIANGLES);
    }
    gl.glPopMatrix();
  }
Exemplo n.º 2
0
  private void renderStaticShip(GL10 gl, Application app) {

    shipTexture.bind();
    gl.glPushMatrix();
    gl.glTranslatef(0, 0, 0);
    shipMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    float noise = (float) Math.random() / 2;
    renderJet(gl, 2.3f, 1f + noise, 1.1f, -.5f, 1.8f, app);
    noise = (float) Math.random() / 2;
    renderJet(gl, 2.3f, 1f + noise, -1.1f, -.5f, 1.8f, app);
  }
Exemplo n.º 3
0
  private void renderSky(GL10 gl) {

    gl.glDisable(GL10.GL_LIGHTING);
    skyTexture.bind();
    gl.glColor4f(1, 1, 1, 1);

    gl.glPushMatrix();
    gl.glTranslatef(0, 0, 0);
    gl.glScalef(100f, 100f, 100f);
    skyMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
  }
Exemplo n.º 4
0
    public void update() {
      dynamicsWorld.stepSimulation(Gdx.graphics.getDeltaTime(), 5);

      GL10 gl = Gdx.gl10;

      for (int i = 0; i < entities.size; i++) {
        final Entity entity = entities.get(i);
        gl.glPushMatrix();
        gl.glMultMatrixf(entity.worldTransform.transform.val, 0);
        gl.glColor4f(entity.color.r, entity.color.g, entity.color.b, entity.color.a);
        entity.mesh.render(GL10.GL_TRIANGLES);
        gl.glPopMatrix();
      }
    }
Exemplo n.º 5
0
 /**
  * render ship jets
  *
  * @param basescale :- scale factor for jet size before applying thrust
  * @param length :- scale factor for jet length, typically thrust value + random noise
  * @param x The jet's x-coordinate.
  * @param y The jet's y-coordinate.
  * @param z The jet's z-coordinate.
  * @return The product, in a vector <#, #, #, 1>, representing the rotated point.
  */
 private void renderJet(
     GL10 gl, float baseScale, float length, float x, float y, float z, Application app) {
   jetTexture.bind();
   gl.glPushMatrix();
   // move away from origin
   gl.glTranslatef(x, y, z);
   // scale to size of earth
   gl.glScalef(baseScale, baseScale, baseScale * length);
   gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
   gl.glDisable(GL10.GL_LIGHTING);
   // gl.glRotatef((Splash.planetmove/10), .25f, .75f, .5f);
   jetMesh.render(GL10.GL_TRIANGLES);
   gl.glPopMatrix();
   gl.glEnable(GL10.GL_LIGHTING);
   // gl.glEnable(GL10.GL_DEPTH_TEST);
 }
Exemplo n.º 6
0
  private void renderSun(GL10 gl, float radius, float x, float y, float z, Application app) {

    gl.glDisable(GL10.GL_LIGHTING);
    radius = radius * worldscale;
    sunTexture.bind();
    gl.glPushMatrix();
    // move away from origin
    gl.glTranslatef(x, y, z);
    // scale to size of earth
    gl.glScalef(radius, radius, radius);
    gl.glDisable(GL10.GL_CULL_FACE);

    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    gl.glPushMatrix();
    gl.glDisable(GL10.GL_LIGHTING);
    // gl.glRotatef((Splash.planetmove/10), .25f, .75f, .5f);
    sunMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  }
Exemplo n.º 7
0
 public void render(GL10 gl) {
   gl.glPushMatrix();
   gl.glTranslatef(position.x, position.y, -50);
   mesh.render(GL10.GL_TRIANGLE_STRIP);
   gl.glPopMatrix();
 }
Exemplo n.º 8
0
  /**
   * This method is responsible for OpenGL rendering mechanism. Adds lighting to the world. Checks
   * rigidBody map for proper collisionshapes (like SphereShape or BoxShape).
   */
  public void render(float delta) {
    float[] light_ambient = new float[] {1.5f, 1.5f, 1.5f, 1.5f};
    float[] light_diffuse = new float[] {1.0f, 1.0f, 1.0f, 1.0f};
    float[] light_specular = new float[] {1.0f, 1.0f, 1.0f, 1.0f};
    float[] light_position0 = new float[] {1.0f, 10.0f, 1.0f, 0.0f};
    light_position0[0] = position.x + 10;
    light_position0[1] = position.y;
    light_position0[2] = position.z;
    float x = 0.0f, z = 0.0f;

    GL10 gl = Gdx.graphics.getGL10();
    deltaTime = Gdx.graphics.getDeltaTime();

    Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    Gdx.graphics.getGL11().glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, light_ambient, 0);
    Gdx.graphics.getGL11().glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, light_diffuse, 0);
    Gdx.graphics.getGL11().glLightfv(GL10.GL_LIGHT0, GL10.GL_SPECULAR, light_specular, 0);
    Gdx.graphics.getGL11().glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, light_position0, 0);

    Gdx.graphics.getGL11().glEnable(GL10.GL_LIGHTING);
    Gdx.graphics.getGL11().glEnable(GL10.GL_LIGHT0);

    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    Gdx.gl.glEnable(GL10.GL_CULL_FACE);
    Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);

    startTime = System.nanoTime();
    rigidBody = physics.doSimulation(deltaTime, 1);
    endTime = (System.nanoTime() - startTime) / 1000000000.0f;

    for (RigidBody body : rigidBody.values()) {

      if (body.geometry.shape.getType() == ShapeType.BOX_SHAPE_PROXYTYPE) {
        gl.glPushMatrix();

        body.motionState.resultSimulation.getOpenGLMatrix(glMat);
        gl.glMultMatrixf(glMat, 0);

        wallShapeZ = (BoxShape) body.geometry.shape;

        wood.bind();
        gl.glRotatef(270, 1, 0, 0);
        gl.glScalef(7, 7, 7);
        wall.render(GL10.GL_TRIANGLES);
        gl.glPopMatrix();
      }

      if (body.geometry.shape.getType() == ShapeType.STATIC_PLANE_PROXYTYPE) {
        gl.glPushMatrix();

        body.motionState.resultSimulation.getOpenGLMatrix(glMat);
        gl.glMultMatrixf(glMat, 0);

        groundShape = (StaticPlaneShape) body.geometry.shape;

        stone.bind();
        gl.glRotatef(270, 1, 0, 0);
        gl.glScalef(6f, 6f, 6f);
        plane.render(GL10.GL_TRIANGLES);
        gl.glPopMatrix();
      }

      if (body.geometry.shape.getType() == ShapeType.SPHERE_SHAPE_PROXYTYPE) {

        gl.glPushMatrix();

        sphereMovement(body);

        body.motionState.resultSimulation.getOpenGLMatrix(glMat);
        gl.glMultMatrixf(glMat, 0);

        x = body.motionState.resultSimulation.originPoint.x;
        z = body.motionState.resultSimulation.originPoint.z;

        if ((x >= 19.0 && x <= 26.5) && (z >= 8.4 && z <= 8.6)) {
          Gdx.app.log("Zwyciestwo", "lolol");
        }

        if (indexior == 0) black.bind();
        else if (indexior == 1) green.bind();
        else if (indexior == 2) pink.bind();
        else if (indexior == 3) steel.bind();
        else if (indexior == 4) maja.bind();

        sphere.render(GL10.GL_TRIANGLES);
        gl.glPopMatrix();
        cameraSetup(body);
      }
    }

    if (Gdx.input.justTouched()) {
      FileHandle fh = Gdx.files.local("ala.txt");
      fh.writeString(
          String.valueOf(x) + " " + String.valueOf(z) + " " + String.valueOf(indexior), false);
      game.setScreen(new MenuScreen(game));
    }

    gl.glPushMatrix();
    gl.glTranslatef(22.0f, -10.0f, 8.5f);
    gl.glScalef(1.0f, 1.0f, 1.0f);
    gl.glRotatef(270, 1, 0, 0);
    aim.bind();
    target.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();

    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_DEPTH_TEST);
  }