Package org.xjge.core

Class Entity

java.lang.Object
org.xjge.core.Entity

public abstract class Entity
extends java.lang.Object
Abstract class which can be used to represent dynamic game objects within the game world.
Since:
2.0.0
  • Field Summary

    Fields
    Modifier and Type Field Description
    org.joml.Vector3f position  
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected Entity​(org.joml.Vector3f position)
    Creates a new instance of an entity object.
  • Method Summary

    Modifier and Type Method Description
    protected abstract void destroy()
    Used to free the resources used by the entity once it is no longer needed.
    boolean removalRequested()
    Finds if the entity has made a request for removal from the game world.
    void remove()
    Requests the removal and destruction of this entity.
    abstract void render​(java.util.Map<java.lang.String,​GLProgram> glPrograms, Camera camera, Light[] lights, int depthTexHandle)
    Used to organize calls to the OpenGL API and other code pertaining to rendering.
    abstract void render​(GLProgram glProgram, Camera camera, Light[] lights, int depthTexHandle)
    Used to organize calls to the OpenGL API and other code pertaining to rendering.
    abstract void renderShadow​(GLProgram depthProgram)
    Used to cast a shadow using this entities model matrix (and texture if necessary) by passing them as uniforms to the depth program.
    abstract void update​(double targetDelta, double trueDelta)
    Used to organize entity game logic.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • position

      public final org.joml.Vector3f position
  • Constructor Details

    • Entity

      protected Entity​(org.joml.Vector3f position)
      Creates a new instance of an entity object. Most subclasses will likely overload this with their own arguments.
      Parameters:
      position - the initial position of this entity in the game world
  • Method Details

    • update

      public abstract void update​(double targetDelta, double trueDelta)
      Used to organize entity game logic.
      Parameters:
      targetDelta - a constant value denoting the desired time (in seconds) it should take for one game tick to complete
      trueDelta - the actual time (in seconds) it took the current game tick to complete.
    • render

      public abstract void render​(GLProgram glProgram, Camera camera, Light[] lights, int depthTexHandle)
      Used to organize calls to the OpenGL API and other code pertaining to rendering.
      Parameters:
      glProgram - the shader program that will be used to render this entity
      camera - the camera object of the current viewport whos turn it is to complete a render pass
      lights - an array of light source objects provided by the current scene
      depthTexHandle - the handle of the texture generated by the current shadow map or -1 if one has not been set
      See Also:
      render(java.util.Map<java.lang.String,org.xjge.graphics.GLProgram>,org.xjge.core.Camera,org.xjge.core.Light[],int)
    • render

      public abstract void render​(java.util.Map<java.lang.String,​GLProgram> glPrograms, Camera camera, Light[] lights, int depthTexHandle)
      Used to organize calls to the OpenGL API and other code pertaining to rendering.

      This variant of the render method allows entities to utilize multiple shader programs.

      Parameters:
      glPrograms - an immutable collection containing the shader programs compiled during startup
      camera - the camera object of the current viewport whos turn it is to complete a render pass
      lights - an array of light source objects provided by the current scene
      depthTexHandle - the handle of the texture generated by the current shadow map or -1 if one has not been set
      See Also:
      render(org.xjge.graphics.GLProgram,org.xjge.core.Camera,org.xjge.core.Light[],int)
    • renderShadow

      public abstract void renderShadow​(GLProgram depthProgram)
      Used to cast a shadow using this entities model matrix (and texture if necessary) by passing them as uniforms to the depth program.
      Parameters:
      depthProgram - the shader program provided by the engine that will be used to generate the shadow map texture
    • destroy

      protected abstract void destroy()
      Used to free the resources used by the entity once it is no longer needed.

      NOTE: This method should only be used to deallocate memory. Death animations and other effects should be included in the entities game logic via the update() method.

      See Also:
      Graphics.freeBuffers(), Texture.freeTexture()
    • remove

      public void remove()
      Requests the removal and destruction of this entity.
    • removalRequested

      public final boolean removalRequested()
      Finds if the entity has made a request for removal from the game world.

      If a removal request has been made, the entity will be destroyed and subsequently removed from the current scenes entity collection.

      Returns:
      true if the entity has requested removal