Android Open Source - ScalAR Custom Object






From Project

Back to project page ScalAR.

License

The source code is released under:

GNU General Public License

If you think the Android project ScalAR 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 edu.dhbw.andar.pub;
//w w  w. ja va  2 s.c om
import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL10Ext;

import android.opengl.GLU;
import android.opengl.GLUtils;

import edu.dhbw.andar.ARObject;
import edu.dhbw.andar.AndARRenderer;
import edu.dhbw.andar.util.GraphicsUtil;

/**
 * An example of an AR object being drawn on a marker.
 * @author tobi
 *
 */
public class CustomObject extends ARObject {

  
  public CustomObject(String name, String patternName,
      double markerWidth, double[] markerCenter) {
    super(name, patternName, markerWidth, markerCenter);
    float   mat_ambientf[]     = {0f, 1.0f, 0f, 1.0f};
    float   mat_flashf[]       = {0f, 1.0f, 0f, 1.0f};
    float   mat_diffusef[]       = {0f, 1.0f, 0f, 1.0f};
    float   mat_flash_shinyf[] = {50.0f};

    mat_ambient = GraphicsUtil.makeFloatBuffer(mat_ambientf);
    mat_flash = GraphicsUtil.makeFloatBuffer(mat_flashf);
    mat_flash_shiny = GraphicsUtil.makeFloatBuffer(mat_flash_shinyf);
    mat_diffuse = GraphicsUtil.makeFloatBuffer(mat_diffusef);
    
  }
  public CustomObject(String name, String patternName,
      double markerWidth, double[] markerCenter, float[] customColor) {
    super(name, patternName, markerWidth, markerCenter);
    float   mat_flash_shinyf[] = {50.0f};

    mat_ambient = GraphicsUtil.makeFloatBuffer(customColor);
    mat_flash = GraphicsUtil.makeFloatBuffer(customColor);
    mat_flash_shiny = GraphicsUtil.makeFloatBuffer(mat_flash_shinyf);
    mat_diffuse = GraphicsUtil.makeFloatBuffer(customColor);
    
  }
  
  private SimpleBox box = new SimpleBox();
  private FloatBuffer mat_flash;
  private FloatBuffer mat_ambient;
  private FloatBuffer mat_flash_shiny;
  private FloatBuffer mat_diffuse;
  
  /**
   * Everything drawn here will be drawn directly onto the marker,
   * as the corresponding translation matrix will already be applied.
   */
  @Override
  public final void draw(GL10 gl) {
    super.draw(gl);
    
    gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_SPECULAR,mat_flash);
    gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_SHININESS, mat_flash_shiny);  
    gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, mat_diffuse);  
    gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, mat_ambient);

      //draw cube
      gl.glColor4f(0, 1.0f, 0, 1.0f);
      gl.glTranslatef( 0.0f, 0.0f, 12.5f );
      
      
      box.draw(gl);
  }
  @Override
  public void init(GL10 gl) {
    // TODO Auto-generated method stub
    
  }
}




Java Source Code List

com.skylion.speech.GoogleTranslate.java
com.skylion.speech.Narrator.java
com.skylion.speech.Synthesiser.java
edu.dhbw.andar.ARObject.java
edu.dhbw.andar.ARToolkit.java
edu.dhbw.andar.AndARActivity.java
edu.dhbw.andar.AndARRenderer.java
edu.dhbw.andar.CameraHolder.java
edu.dhbw.andar.CameraParameters.java
edu.dhbw.andar.CameraPreviewHandler.java
edu.dhbw.andar.CameraStatus.java
edu.dhbw.andar.Config.java
edu.dhbw.andar.GenericFunctions.java
edu.dhbw.andar.exceptions.AndARException.java
edu.dhbw.andar.exceptions.AndARRuntimeException.java
edu.dhbw.andar.interfaces.MarkerVisibilityListener.java
edu.dhbw.andar.interfaces.OpenGLRenderer.java
edu.dhbw.andar.interfaces.PreviewFrameSink.java
edu.dhbw.andar.pub.CustomActivity.java
edu.dhbw.andar.pub.CustomObject.java
edu.dhbw.andar.pub.CustomRenderer.java
edu.dhbw.andar.pub.SimpleBox.java
edu.dhbw.andar.util.GraphicsUtil.java
edu.dhbw.andar.util.IO.java
edu.dhbw.andobjviewer.AugmentedModelViewerActivity.java
edu.dhbw.andobjviewer.CheckFileManagerActivity.java
edu.dhbw.andobjviewer.Config.java
edu.dhbw.andobjviewer.InstructionsActivity.java
edu.dhbw.andobjviewer.ModelChooser.java
edu.dhbw.andobjviewer.graphics.LightingRenderer.java
edu.dhbw.andobjviewer.graphics.Model3D.java
edu.dhbw.andobjviewer.graphics.Renderer.java
edu.dhbw.andobjviewer.models.Group.java
edu.dhbw.andobjviewer.models.Material.java
edu.dhbw.andobjviewer.models.Model.java
edu.dhbw.andobjviewer.models.Vector3D.java
edu.dhbw.andobjviewer.parser.MtlParser.java
edu.dhbw.andobjviewer.parser.ObjParser.java
edu.dhbw.andobjviewer.parser.ParseException.java
edu.dhbw.andobjviewer.parser.SimpleTokenizer.java
edu.dhbw.andobjviewer.parser.Util.java
edu.dhbw.andobjviewer.util.ArrayIterator.java
edu.dhbw.andobjviewer.util.AssetsFileUtil.java
edu.dhbw.andobjviewer.util.BaseFileUtil.java
edu.dhbw.andobjviewer.util.FixedPointUtils.java
edu.dhbw.andobjviewer.util.MatrixUtils.java
edu.dhbw.andobjviewer.util.MemUtil.java
edu.dhbw.andobjviewer.util.SDCardFileUtil.java