Example #1
0
  /** A moving object that doesn't obey physics. */
  public static void SV_Physics_Noclip(edict_t ent) {
    //	   regular thinking
    if (!SV_RunThink(ent)) return;

    Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles);
    Math3D.VectorMA(ent.s.origin, Defines.FRAMETIME, ent.velocity, ent.s.origin);

    GameBase.gi.linkentity(ent);
  }
Example #2
0
  /** R_DrawSpriteModel */
  void R_DrawSpriteModel(entity_t e) {
    float alpha = 1.0F;

    qfiles.dsprframe_t frame;
    qfiles.dsprite_t psprite;

    // don't even bother culling, because it's just a single
    // polygon without a surface cache

    psprite = (qfiles.dsprite_t) currentmodel.extradata;

    e.frame %= psprite.numframes;

    frame = psprite.frames[e.frame];

    if ((e.flags & Defines.RF_TRANSLUCENT) != 0) alpha = e.alpha;

    if (alpha != 1.0F) GL11.glEnable(GL11.GL_BLEND);

    GL11.glColor4f(1, 1, 1, alpha);

    GL_Bind(currentmodel.skins[e.frame].texnum);

    GL_TexEnv(GL11.GL_MODULATE);

    if (alpha == 1.0) GL11.glEnable(GL11.GL_ALPHA_TEST);
    else GL11.glDisable(GL11.GL_ALPHA_TEST);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(0, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glEnd();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL_TexEnv(GL11.GL_REPLACE);

    if (alpha != 1.0F) GL11.glDisable(GL11.GL_BLEND);

    GL11.glColor4f(1, 1, 1, 1);
  }
Example #3
0
  // FIXME: hacked in for E3 demo
  public static void SV_AddRotationalFriction(edict_t ent) {
    int n;
    float adjustment;

    Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles);
    adjustment = Defines.FRAMETIME * Defines.sv_stopspeed * Defines.sv_friction;
    for (n = 0; n < 3; n++) {
      if (ent.avelocity[n] > 0) {
        ent.avelocity[n] -= adjustment;
        if (ent.avelocity[n] < 0) ent.avelocity[n] = 0;
      } else {
        ent.avelocity[n] += adjustment;
        if (ent.avelocity[n] > 0) ent.avelocity[n] = 0;
      }
    }
  }
Example #4
0
  /** Toss, bounce, and fly movement. When onground, do nothing. */
  public static void SV_Physics_Toss(edict_t ent) {

    trace_t trace;
    float[] move = {0, 0, 0};
    float backoff;
    edict_t slave;
    boolean wasinwater;
    boolean isinwater;
    float[] old_origin = {0, 0, 0};

    //	   regular thinking
    SV_RunThink(ent);

    // if not a team captain, so movement will be handled elsewhere
    if ((ent.flags & Defines.FL_TEAMSLAVE) != 0) return;

    if (ent.velocity[2] > 0) ent.groundentity = null;

    //	check for the groundentity going away
    if (ent.groundentity != null) if (!ent.groundentity.inuse) ent.groundentity = null;

    //	   if onground, return without moving
    if (ent.groundentity != null) return;

    Math3D.VectorCopy(ent.s.origin, old_origin);

    SV_CheckVelocity(ent);

    //	   add gravity
    if (ent.movetype != Defines.MOVETYPE_FLY && ent.movetype != Defines.MOVETYPE_FLYMISSILE)
      SV_AddGravity(ent);

    //	   move angles
    Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles);

    //	   move origin
    Math3D.VectorScale(ent.velocity, Defines.FRAMETIME, move);
    trace = SV_PushEntity(ent, move);
    if (!ent.inuse) return;

    if (trace.fraction < 1) {
      if (ent.movetype == Defines.MOVETYPE_BOUNCE) backoff = 1.5f;
      else backoff = 1;

      GameBase.ClipVelocity(ent.velocity, trace.plane.normal, ent.velocity, backoff);

      // stop if on ground
      if (trace.plane.normal[2] > 0.7) {
        if (ent.velocity[2] < 60 || ent.movetype != Defines.MOVETYPE_BOUNCE) {
          ent.groundentity = trace.ent;
          ent.groundentity_linkcount = trace.ent.linkcount;
          Math3D.VectorCopy(Globals.vec3_origin, ent.velocity);
          Math3D.VectorCopy(Globals.vec3_origin, ent.avelocity);
        }
      }

      // if (ent.touch)
      //	ent.touch (ent, trace.ent, &trace.plane, trace.surface);
    }

    //	   check for water transition
    wasinwater = (ent.watertype & Defines.MASK_WATER) != 0;
    ent.watertype = GameBase.gi.pointcontents.pointcontents(ent.s.origin);
    isinwater = (ent.watertype & Defines.MASK_WATER) != 0;

    if (isinwater) ent.waterlevel = 1;
    else ent.waterlevel = 0;

    if (!wasinwater && isinwater)
      GameBase.gi.positioned_sound(
          old_origin, ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/h2ohit1.wav"), 1, 1, 0);
    else if (wasinwater && !isinwater)
      GameBase.gi.positioned_sound(
          ent.s.origin,
          ent,
          Defines.CHAN_AUTO,
          GameBase.gi.soundindex("misc/h2ohit1.wav"),
          1,
          1,
          0);

    //	   move teamslaves
    for (slave = ent.teamchain; slave != null; slave = slave.teamchain) {
      Math3D.VectorCopy(ent.s.origin, slave.s.origin);
      GameBase.gi.linkentity(slave);
    }
  }