Android Open Source - RollOverSphere---a-simple-libgdx-game Cube Mesh






From Project

Back to project page RollOverSphere---a-simple-libgdx-game.

License

The source code is released under:

MIT License

If you think the Android project RollOverSphere---a-simple-libgdx-game listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.igorcrevar.rolloverchuck.mesh;
/*from  w  ww.j  a va2  s  . c o m*/
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.igorcrevar.rolloverchuck.GameData;

public class CubeMesh implements IMesh {
  private Mesh mesh;
  
  public CubeMesh(GameData gameData) {
    mesh = getMesh(0.5f);
  }
  
  @Override
  public void draw(ShaderProgram shaderProgram) {
    mesh.render(shaderProgram, GL20.GL_TRIANGLES);
  }

  @Override
  public void dispose() {
    mesh.dispose();
  }

  private Mesh getMesh(float size) {
    short[] indices = new short[] { 
      // Faces definition
      0, 1, 3, 0, 3, 2,     // Face front
      4, 5, 7, 4, 7, 6,     // Face right
      8, 9, 11, 8, 11, 10,   // ...
      12, 13, 15, 12, 15, 14, 
      16, 17, 19, 16, 19, 18, 
      20, 21, 23, 20, 23, 22, 
    };
        
    float[] vertices = new float[] {
      -size, -size, size, 0.0f, 0.0f,
      size, -size, size, 0.0f, 1.0f, 
      -size, size, size, 1.0f, 0.0f, 
      size, size, size, 1.0f, 1.0f,

      size, -size, size, 0.0f, 0.0f,
      size, -size, -size, 0.0f, 1.0f,  
      size, size, size, 1.0f, 0.0f,
      size, size, -size, 1.0f, 1.0f,

      size, -size, -size, 0.0f, 0.0f,
      -size, -size, -size, 0.0f, 1.0f,
      size, size, -size, 1.0f, 0.0f, 
      -size, size, -size, 1.0f, 1.0f,

      -size, -size, -size, 0.0f, 0.0f, 
      -size, -size, size, 0.0f, 1.0f, 
      -size, size, -size, 1.0f, 0.0f,
      -size, size, size, 1.0f, 1.0f,

      -size, -size, -size, 0.0f, 0.0f, 
      size, -size, -size, 0.0f, 1.0f,
      -size, -size, size, 1.0f, 0.0f,
      size, -size, size, 1.0f, 1.0f,

      -size, size, size, 0.0f, 0.0f,
      size, size, size, 0.0f, 1.0f,
      -size, size, -size, 1.0f, 0.0f, 
      size, size, -size, 1.0f, 1.0f,
    };   
     
    // populate normal also
        Mesh newMesh = new Mesh(true, vertices.length / 5, indices.length, VertexAttribute.Position(), VertexAttribute.TexCoords(0));
        newMesh.setIndices(indices);
        newMesh.setVertices(vertices);
        return newMesh;
  }
}




Java Source Code List

com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
com.igorcrevar.rolloverchuck.DesktopRunner.java
com.igorcrevar.rolloverchuck.GameConsts.java
com.igorcrevar.rolloverchuck.GameData.java
com.igorcrevar.rolloverchuck.GameListener.java
com.igorcrevar.rolloverchuck.GameManager.java
com.igorcrevar.rolloverchuck.GameType.java
com.igorcrevar.rolloverchuck.IActivityRequestHandler.java
com.igorcrevar.rolloverchuck.ISceneManager.java
com.igorcrevar.rolloverchuck.IScene.java
com.igorcrevar.rolloverchuck.mesh.CubeMeshWithNormals.java
com.igorcrevar.rolloverchuck.mesh.CubeMesh.java
com.igorcrevar.rolloverchuck.mesh.FieldMesh.java
com.igorcrevar.rolloverchuck.mesh.IMesh.java
com.igorcrevar.rolloverchuck.mesh.SphereMesh.java
com.igorcrevar.rolloverchuck.objects.BoxObject.java
com.igorcrevar.rolloverchuck.objects.ChuckObject.java
com.igorcrevar.rolloverchuck.objects.ChuckSpriteObject.java
com.igorcrevar.rolloverchuck.objects.EndGameButtonsObject.java
com.igorcrevar.rolloverchuck.objects.FieldObject.java
com.igorcrevar.rolloverchuck.objects.GameButton.java
com.igorcrevar.rolloverchuck.objects.IntroSceneButtonsObject.java
com.igorcrevar.rolloverchuck.objects.MainWallObject.java
com.igorcrevar.rolloverchuck.objects.StarsObject.java
com.igorcrevar.rolloverchuck.objects.TextButton.java
com.igorcrevar.rolloverchuck.objects.TrailObject.java
com.igorcrevar.rolloverchuck.objects.boxes.BoxManager.java
com.igorcrevar.rolloverchuck.objects.boxes.BoxRegionManager.java
com.igorcrevar.rolloverchuck.objects.boxes.BoxRegion.java
com.igorcrevar.rolloverchuck.objects.boxes.BoxTypeFactory.java
com.igorcrevar.rolloverchuck.objects.boxes.IBoxRegion.java
com.igorcrevar.rolloverchuck.objects.boxes.IBoxType.java
com.igorcrevar.rolloverchuck.physics.CollisionSolver.java
com.igorcrevar.rolloverchuck.physics.ICollisionIterationHandler.java
com.igorcrevar.rolloverchuck.physics.SphereMoving.java
com.igorcrevar.rolloverchuck.points.PlayerPoint.java
com.igorcrevar.rolloverchuck.points.PointsManager.java
com.igorcrevar.rolloverchuck.scenes.GameLoadingScene.java
com.igorcrevar.rolloverchuck.scenes.GameScene.java
com.igorcrevar.rolloverchuck.scenes.IntroScene.java
com.igorcrevar.rolloverchuck.scenes.GameMode.ArcadeGameMode.java
com.igorcrevar.rolloverchuck.scenes.GameMode.IGameMode.java
com.igorcrevar.rolloverchuck.scenes.GameMode.StressFreeGameMode.java
com.igorcrevar.rolloverchuck.utils.CollisionHelper.java
com.igorcrevar.rolloverchuck.utils.GameHelper.java
com.igorcrevar.rolloverchuck.utils.IMyFontDrawerFont.java
com.igorcrevar.rolloverchuck.utils.Mathf.java
com.igorcrevar.rolloverchuck.utils.MyFontDrawerBatch.java
com.igorcrevar.rolloverchuck.utils.MyFontDrawerDefaultFont.java
com.igorcrevar.rolloverchuck.utils.MyFontDrawer.java
com.igorcrevar.rolloverchuck.utils.ShaderAssetLoader.java
com.wayilookatgames.rolloverball.MainActivity.java