Esempio n. 1
0
  public static void displayRealm(Realm r) {
    if (Logic.getPlayer() != null) {
      LAYER = BACKGROUND_LAYER;
      setCameraBackground();
      camera.setCameraBound(r.getCameraBound());
      Model background = r.getBackground();
      if (background != null) {
        background.draw(null, null, null);
      }
      camera.setPos(Logic.getPlayer().getPos());
      setCameraLevel();

      LAYER = STATIC_LAYER;
      for (Entity i : r.getEntities()) i.draw();
      for (Entity i : r.getWayPoints()) {
        i.draw();
      }

      LAYER = UNIT_LAYER;
      for (EntityUnit i : r.getUnits()) i.draw();
      LAYER = DYNAMIC_LAYER;
      for (EntityMissile i : r.getMissiles()) i.draw();

      GUI gui = Main.getGameState(STATE_SETTING_MENU).getGUI("GUI_CB_PARTICLES");
      if (gui != null && ((GUICheckBox) gui).getValue()) {
        LAYER = PARTICLE_LAYER;
        for (EntityParticle i : r.getParticles()) i.draw();
      }
    }
  }
Esempio n. 2
0
  public AbstractEntity(Model m) {

    super(m.getBounds());
    this.m = m;
    Vector3f myMin = b.getMin();
    this.origin = new Vector3f(-myMin.getX(), -myMin.getY(), -myMin.getZ());
    this.angle = 0;
  }
Esempio n. 3
0
  @Override
  public void draw() {

    if (m != null) {
      Vector3f min = b.getMin();
      Vector3f max = b.getMax();
      glPushMatrix();
      glTranslatef(origin.getX() + min.x, origin.getY() + min.y, origin.getZ() + min.z);
      glRotatef(angle, 0, 1, 0);
      m.draw();
      glPopMatrix();
      glDisable(GL_CULL_FACE);
      glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
      glBegin(GL_QUADS);

      glVertex3f(min.getX(), min.getY(), min.getZ());
      glVertex3f(max.getX(), min.getY(), min.getZ());
      glVertex3f(max.getX(), max.getY(), min.getZ());
      glVertex3f(min.getX(), max.getY(), min.getZ());

      glVertex3f(min.getX(), min.getY(), max.getZ());
      glVertex3f(max.getX(), min.getY(), max.getZ());
      glVertex3f(max.getX(), max.getY(), max.getZ());
      glVertex3f(min.getX(), max.getY(), max.getZ());

      glVertex3f(min.getX(), min.getY(), min.getZ());
      glVertex3f(min.getX(), min.getY(), max.getZ());
      glVertex3f(min.getX(), max.getY(), max.getZ());
      glVertex3f(min.getX(), max.getY(), min.getZ());

      glVertex3f(max.getX(), min.getY(), min.getZ());
      glVertex3f(max.getX(), min.getY(), max.getZ());
      glVertex3f(max.getX(), max.getY(), max.getZ());
      glVertex3f(max.getX(), max.getY(), min.getZ());

      glVertex3f(max.getX(), min.getY(), min.getZ());
      glVertex3f(min.getX(), min.getY(), min.getZ());
      glVertex3f(min.getX(), min.getY(), max.getZ());
      glVertex3f(max.getX(), min.getY(), max.getZ());

      glVertex3f(max.getX(), max.getY(), min.getZ());
      glVertex3f(min.getX(), max.getY(), min.getZ());
      glVertex3f(min.getX(), max.getY(), max.getZ());
      glVertex3f(max.getX(), max.getY(), max.getZ());

      glEnd();
      glEnable(GL_CULL_FACE);
      glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    }
  }
Esempio n. 4
0
 public static void initDisplayLists() throws IOException {
   Main.dl_zombiebody = glGenLists(1);
   glNewList(Main.dl_zombiebody, GL_COMPILE);
   zombiebody();
   glEndList();
   Main.dl_zombiehead = glGenLists(1);
   glNewList(Main.dl_zombiehead, GL_COMPILE);
   zombiehead();
   glEndList();
   Main.dl_bullet = Model.getDL(System.getProperty("user.dir") + "/res/obj/bullet.obj");
   Main.dl_grenade = Model.getDL(System.getProperty("user.dir") + "/res/obj/grenade.obj");
   Main.dl_cexplosive = Model.getDL(System.getProperty("user.dir") + "/res/obj/item2.obj");
   Main.dl_gun = new int[3];
   Main.dl_gun[0] = Model.getDL(System.getProperty("user.dir") + "/res/obj/gun0.obj");
   Main.dl_gun[1] = Model.getDL(System.getProperty("user.dir") + "/res/obj/gun1.obj");
   Main.dl_gun[2] = Model.getDL(System.getProperty("user.dir") + "/res/obj/gun2.obj");
   Main.dl_floorandmap = glGenLists(1);
   glNewList(Main.dl_floorandmap, GL_COMPILE);
   floor();
   new Model(System.getProperty("user.dir") + "/res/map/map.obj").render();
   glEndList();
 }
Esempio n. 5
0
  private static void createGraphicData(List<String> lines) {
    Model m = null;
    ModelAnim a = null;
    Particle p = null;
    Texture t = null;
    TextureCliped c = null;
    Animation A = null;
    for (String l : lines) {
      if (l.charAt(0) == '+') continue;
      String[] data = l.split(" ");
      String action = data[0];
      if ("new".equals(action)) { // create new thing
        String object = data[1];
        String name = data[2];
        if ("Model".equals(object)) {
          a = null;
          m = new Model();
          models.put(name, m);
          System.out.println("new model " + name);
        } else if ("ModelRepeat".equals(object)) {
          a = null;
          m = new ModelRepeat();
          models.put(name, m);
          System.out.println("new modelRepeat " + name);
        } else if ("ModelAnim".equals(object)) {
          a = new ModelAnim();
          m = null;
          models.put(name, a);
          System.out.println("new modelAnim " + name);
        } else if ("Particle".equals(object)) {
          p = new Particle();
          a = null;
          m = null;
          models.put(name, p);
          System.out.println("new particle " + name);
        } else if ("Texture".equals(object)) {
          t = Texture.loadTexture(name);
          c = null;
          textures.put(name, t);
          System.out.println("new texture " + name);
        } else if ("TextureCliped".equals(object)) {
          c = TextureCliped.loadTextureCliped(name);
          textures.put(name, c);
          System.out.println("new textureCliped " + name);
        } else if ("Animation".equals(object)) {
          A = new Animation();
          if (a != null) a.setAnimation(name, A);
          System.out.println("new animation " + name);
        }
      } else if ("set".equals(action)) { // set stuff
        String attribute = data[1];

        if (m != null) {
          if ("Texture".equals(attribute)) {
            String path = data[2];
            m.setTexture(getTexture(path));
          }
        } else if (A != null) {
          if ("Texture".equals(attribute)) {
            String path = data[2];
            A.setTexture(getTexture(path));
          } else if ("Duration".equals(attribute)) {
            String duration = data[2];
            A.setDuration(Float.valueOf(duration));
          } else if ("FrameCount".equals(attribute)) {
            String count = data[2];
            A.setFrameCount(Integer.valueOf(count));
          } else if ("Frame".equals(attribute)) {
            String frame = data[2];
            String clipID = data[3];
            A.setFrame(Integer.valueOf(frame), Integer.valueOf(clipID));
          }
        } else if (c != null) {
          if ("FrameCount".equals(attribute)) {
            String x = data[2];
            String y = data[3];
            c.setFrameCount(Integer.valueOf(x), Integer.valueOf(y));
          }
        }
      }
    }
  }