public void render(List<Terrain> terrains, Matrix4f toShadowSpace) {
   shader.loadToShadowSpaceMatrix(toShadowSpace);
   for (Terrain t : terrains) {
     prepareTerrain(t);
     loadModelMatrix(t);
     GL11.glDrawElements(
         GL11.GL_TRIANGLES, t.getModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
     unbindShtuffs();
   }
 }
 private void bindTextures(Terrain terrain) {
   TerrainTexturePack pack = terrain.getTexturePack();
   GL13.glActiveTexture(GL13.GL_TEXTURE0);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getBackgroundTexture().getTextureID());
   GL13.glActiveTexture(GL13.GL_TEXTURE1);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getRedTexture().getTextureID());
   GL13.glActiveTexture(GL13.GL_TEXTURE2);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getGreenTexture().getTextureID());
   GL13.glActiveTexture(GL13.GL_TEXTURE3);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getBlueTexture().getTextureID());
   GL13.glActiveTexture(GL13.GL_TEXTURE4);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, terrain.getBlendMap().getTextureID());
 }
 private void prepareTerrain(Terrain terrain) {
   RawModel model = terrain.getModel();
   GL30.glBindVertexArray(model.getVaoID());
   GL20.glEnableVertexAttribArray(0);
   GL20.glEnableVertexAttribArray(1);
   GL20.glEnableVertexAttribArray(2);
   bindTextures(terrain);
   shader.loadShineVariables(1, 0);
 }
Exemple #4
0
 public void move(Terrain terrain) {
   checkInputs();
   super.increaseRotation(0, currentTurnSpeed * DisplayManager.getFrameTimeSeconds(), 0);
   float distance = currentSpeed * DisplayManager.getFrameTimeSeconds();
   float dx = (float) (distance * Math.sin(Math.toRadians(super.getRotY())));
   float dz = (float) (distance * Math.cos(Math.toRadians(super.getRotY())));
   super.increasePosition(dx, 0, dz);
   upwardsSpeed += GRAVITY * DisplayManager.getFrameTimeSeconds();
   super.increasePosition(0, upwardsSpeed * DisplayManager.getFrameTimeSeconds(), 0);
   float terrainHeight = terrain.getHeightOfTerrain(getPosition().x, getPosition().z);
   // float terrainHeight = 0;
   if (super.getPosition().y < terrainHeight) {
     upwardsSpeed = 0;
     isInAir = false;
     super.getPosition().y = terrainHeight;
   }
 }
 private void loadModelMatrix(Terrain terrain) {
   Matrix4f transfomation =
       Maths.createTransformationMatrix(
           new Vector3f(terrain.getX(), 0, terrain.getZ()), 0, 0, 0, 1);
   shader.loadTransformationMatrix(transfomation);
 }