Package models

Source Code of models.Quad

package models;

import processing.core.PApplet;
import processing.core.PConstants;
import processing.core.PVector;
import remixlab.proscene.Frame;
import remixlab.proscene.Quaternion;

import utils.Util;

import codeanticode.glgraphics.GLGraphics;
import codeanticode.glgraphics.GLModel;
import codeanticode.glgraphics.GLTexture;

public class Quad extends Shape3D{
 
 
  protected int numPoints = 4;
 
       
  ///////////////////////////////////////////////////////////////
  // CONSTRUCTORES
  ///////////////////////////////////////////////////////////////
 
 
  public Quad(PApplet parent, GLTexture texture){
    super();
   
    this.parent = parent;
    this.texture = texture; 
   
    //anchor =  new Frame();
   
    renderer = (GLGraphics) parent.g;
   
    createModel();
  }
 
 
 
  private void createModel(){
 
    model = new GLModel(parent, numPoints, GLModel.QUADS, GLModel.DYNAMIC);
     
      // Updating the vertices to their initial positions.
    // al disenar entre -.5 y 5, la relacion de escala es igual al valor en pixels para el z 0
    // o sea, si hago scale(100,100,0) el quad en la pantalla va a medir 100
      model.beginUpdateVertices();
      model.updateVertex(0, -.50f, -.50f, 0);
      model.updateVertex(1, .50f, -.50f, 0);
      model.updateVertex(2, .50f, .50f, 0);
      model.updateVertex(3, -.50f, .50f, 0);   
      model.endUpdateVertices();

      // Enabling the use of texturing...
      model.initTexures(1);
     
      // la textura la voy a pasar desde afuera   
      model.setTexture(0, texture);
    
       // Setting the texture coordinates.
      model.beginUpdateTexCoords(0);
      model.updateTexCoord(0, 0, 0);
      model.updateTexCoord(1, 1, 0);   
      model.updateTexCoord(2, 1, 1);
      model.updateTexCoord(3, 0, 1);
      model.endUpdateTexCoords();
      model.setBlendMode(PConstants.BLEND);
  }
 
 
  public void draw(){
   
   
    renderer.gl.glPushMatrix()
     
 
    renderer.gl.glTranslatef(
                  anchor.position().x,
                  anchor.position().y,
                  anchor.position().z);
   
    renderer.gl.glMultMatrixf(Util.glModelViewMatrix(anchor.matrix()), 0);
    renderer.gl.glScalef(scale.x, scale.y, scale.z)
   
    model.render()
   
   
   
    renderer.gl.glPopMatrix();

  }







  public void setFillColor(float[] color) {
   
    model.setTint(color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255);
    // TODO Auto-generated method stub
   
  }










 
}


TOP

Related Classes of models.Quad

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.