Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Framecount*i

$
0
0

Can someone explain this framecount*i,and how it is used in the sketch.Because when i put out i,from the equation the vertices dont move independently.Thanks in advance

import peasy.*;
import saito.objloader.*;

OBJModel model ;
OBJModel tmpmodel ;

PeasyCam cam;
float easing = 0.005;

int VertCount;
PVector[] Verts;

void setup()
{
  size(800, 600, P3D);
  frameRate(30);
  noStroke();

  model = new OBJModel(this, "Model2.obj", "absolute", TRIANGLES);
  model.enableDebug();
  model.scale(100);
  model.translateToCenter();

  tmpmodel = new OBJModel(this, "Model2.obj", "absolute", TRIANGLES);
  tmpmodel.enableDebug();
  tmpmodel.scale(100);
  tmpmodel.translateToCenter();

  cam = new PeasyCam(this, width/2, height/2, 0, 500);
}

void draw()
{
  background(129);
  lights();

  int VertCount = model.getVertexCount ();
  PVector[] Verts = new PVector[VertCount];

  //cam.rotateY(0.05);
  cam.setMouseControlled(true);

  //println(frameCount);
  pushMatrix();
  translate(width/2, height/2, 0);

  for (int i = 0; i < VertCount; i++) {
    //PVector orgv = model.getVertex(i);

    Verts[i]= model.getVertex(i);

    //PVector tmpv = new PVector();
    if (frameCount> 100) {

      float randX = random(-0.05, 0.05);
      float randY = random(0, 0.05);
      float randZ = random(0, 0.05);

      ////HERE

      float norX = abs(cos((frameCount+i))) * randX;
      float norY = abs(cos((frameCount+i)) * randY);
      float norZ = abs(cos((frameCount+i)) * randZ);

      Verts[i].x+=Verts[i].x*norX;
      Verts[i].y+=Verts[i].y*norY;
      Verts[i].z+=Verts[i].z*norZ;

      if (Verts[i].x > width/2|| Verts[i].x < -width/2) {
        Verts[i].x+=Verts[i].x*-0.05;
      }
      if (Verts[i].y > height/2|| Verts[i].y < -height/2) {
        Verts[i].y+=Verts[i].y*-0.05;
      }

      if (Verts[i].z < -600/2 || Verts[i].z > 600/2) {  //note that Zaxis goes 'into' the screen
        Verts[i].z+=Verts[i].z*-0.05;
      }
    }

    PVector locas = new PVector(Verts[i].x, Verts[i].y, Verts[i].z);
    tmpmodel.setVertex(i, locas.x, locas.y, locas.z);
  }

  noStroke();
  tmpmodel.draw();
  popMatrix();

  translate(width/2, height/2, 0);
  noFill();
  stroke(255);
  box(width, height, 600);
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles