Animations:
- Karla G
- 27 mar 2015
- 3 Min. de lectura
This are some easy animations for your programs:
import remixlab.bias.event.*;
import remixlab.bias.event.shortcut.*;
import remixlab.bias.agent.profile.*;
import remixlab.bias.agent.*;
import remixlab.dandelion.agent.*;
import remixlab.proscene.*;
import remixlab.dandelion.core.*;
import remixlab.dandelion.constraint.*;
import remixlab.fpstiming.*;
import remixlab.util.*;
import remixlab.dandelion.geom.*;
import remixlab.bias.core.*;
float one, two, three, four; // Coounters for rotating and translate
Scene scene; //A variable of type scene for the setup of the camera
void setup(){
scene = new Scene(this); //Thanks to the library, set the camera is this easy
one=0;
two=0;
three=0;
four=0;
// Set the inicial values of the varibles
size(800,800,P3D); //window size with 3D support
}
void draw(){
background(33,33,33);//Background Color
ambientLight(100,255,100); //AMBIENT LIGHT
directionalLight(255,0,0, 0,1,0); //DIRECTIONAL LIGHT
directionalLight(0,0,255, -1,0,0);
pointLight(0,200,0, 10,-10,0); //POINT LIGHT
// The first three objects are spheres that rotate in diagonal
pushMatrix(); /*For the camera I'm using I found
necessary and easier to use push and popMatrix.*/
noStroke();//As is an sphere, no Stroke will make it look more round
fill(255,255,255);//The color that the shape will be
scale(.5);//For having an smaller object, I scale it to 1/2
one=one+sin(45)/12;//A variable one that sums a constant quantity
rotate(one,one,-one,0);//The variable is used to rotate in a constant path
translate(0,0,130);//The object will be 130 pxs far from 0,0,0
rotate(one,0,0,0);//This indicates only a X-axis rotation.
//Materials
ambient(0,0,255);
specular(255,255,255);
drawDrawing();//An mehot is called. The method contains a drawn shape
popMatrix(); /*If the matrix is elemined, the pre-stablished axis
of the camera moves with the objects that rotate or translate.*/
/*
After the first time one is set, the sum will not have to be
repeated, if the operation: "one=one+sin(45)/12" was repeated,
the variable one, would increase each of the times the operation
is repeated. That's why in the next shapes that use the variable
one, don't have to repeat the operation.
Also, the next two shapes, as are the same at the last one, have
almost the same explanation.
*/
pushMatrix();
noStroke();
fill(255,255,255);
scale(.5);
rotate(one+2,one,-one,0);/*For change only the rotation of this
shape, I just sum 2 in the X-axis rotation, so this shape will
be 2 in front of the last shape*/
translate(0,0,130);
rotate(one,0,0,0);
//Materials
ambient(33,33,255);
specular(80,15,170);
drawDrawing();
popMatrix();
pushMatrix();
noStroke();
fill(255,255,255);
scale(.5);
rotate(one+4,one,-one,0);/*In this case I put +4 so the shape will be 2
in font of the last shape too. With this, the three shapes can rotate in
the same orbit and velocity just as if they were followinf each other*/
translate(0,0,130);
rotate(one,0,0,0);
drawDrawing();
popMatrix();
//Here the boxes beggin. Yep, no more spheres.
/*Also, most of the tools used here, are the same ones as the mentioned
before.*/
pushMatrix();
strokeWeight(3);//Weight of the lines of the shape
stroke(255,255,255);//Color of the lines in the shape WHITE
fill(255,255,255);
two=two+sin(45)/12;//Counter variable
scale(.5);
rotate(two,two,two,0);//The path of rotation changes by var two
translate(0,0,80);
rotate(two,0,1,0);//Rotation in the axis of the shape
drawSquaring();//The shape
popMatrix();
pushMatrix();
noStroke();
stroke(255,255,255);
fill(255,255,255);
scale(.5);
rotate(two+2,two,two,0);//Shape with same path but 2 spaces in front
translate(0,0,80);
rotate(two,0,1,0);
drawSquaring();
popMatrix();
pushMatrix();
strokeWeight(3);
stroke(255,255,255);
fill(255,255,255);
scale(.5);
rotate(two+4,two,two,0);//Shape with the same path but different position in orbit
translate(0,0,80);
rotate(two,0,1,0);
drawSquaring();
popMatrix();
// The Diamond in the middle
pushMatrix();
three=three-PI/45;//The counter three
strokeWeight(2);
stroke(25,25,112);//Color of the lines of the shape
rotate(three,0,1,0);//The rotation in the diamond
translate(0,0,10);
scale(2);
drawDiamond(); //This is the shape I did by myself
popMatrix();
//The stars
pushMatrix();
strokeWeight(1);
stroke(255,255,255);
fill(255,255,255);
scale(.8);//The star is scaled to 0.8 of its original size
four=four+PI/90;//A counter four
rotate(four,0,1,0);/*In the case of the stars, they only move in x
Not in a diagonal path*/
translate(0,0,120);
rotate(four,0,1,0);
//Material
ambient(33,33,255);
specular(80,15,170);
drawStar(); //This is another shape made by me (a star)
popMatrix();
pushMatrix();
strokeWeight(1);
stroke(255,255,255);
fill(255,255,255);
scale(.8);
rotate(four+2,0,1,0);
translate(0,0,120);
rotate(four,0,1,0);
//Material
ambient(5,180,30);
specular(12,12,100);
drawStar();
popMatrix();
pushMatrix();
strokeWeight(1);
stroke(255,255,255);
fill(255,255,255);
scale(.8);
rotate(four+4,0,1,0);
translate(0,0,120);
rotate(four,0,1,0);
//Material
ambient(0,139,139);
specular(139,0,139);
drawStar();
popMatrix();
}
//This are the figures I created or used for the setup
void drawDrawing(){
sphere(20);
}
void drawSquaring() {
box(30);
}
void drawDiamond(){
beginShape(TRIANGLES);
vertex(-5,0,0);
vertex(0,10,-5);
vertex(5,0,0);
vertex(5,0,0);
vertex(5,0,-10);
vertex(0,10,-5);
vertex(0,10,-5);
vertex(5,0,-10);
vertex(-5,0,-10);
vertex(-5,0,-10);
vertex(0,10,-5);
vertex(-5,0,0);
vertex(-5,0,0);
vertex(0,-10,-5);
vertex(5,0,0);
vertex(5,0,0);
vertex(5,0,-10);
vertex(0,-10,-5);
vertex(0,-10,-5);
vertex(5,0,-10);
vertex(-5,0,-10);
vertex(-5,0,-10);
vertex(0,-10,-5);
vertex(-5,0,0);
endShape();
}
void drawStar(){
beginShape(TRIANGLES);
vertex(0,0,0);
vertex(2,-3,0);
vertex(-2,-3,0);
vertex(0,0,0);
vertex(-2,-3,0);
vertex(-3.3,0.6,0);
vertex(0,0,0);
vertex(2,-3,0);
vertex(3.3,0.6,0);
vertex(0,0,0);
vertex(0,3.2,0);
vertex(3.3,0.6,0);
vertex(0,0,0);
vertex(0,3.2,0);
vertex(-3.3,0.6,0);
vertex(2,-3,0);
vertex(0,-9,-2);
vertex(-2,-3,0);
vertex(-2,-3,0);
vertex(-9,-3,-2);
vertex(-3.3,0.6,0);
vertex(2,-3,0);
vertex(9,-3,-2);
vertex(3.3,0.6,0);
vertex(0,3.2,0);
vertex(6.5,7.2,-2);
vertex(3.3,0.6,0);
vertex(0,3.2,0);
vertex(-6.5,7.2,-2);
vertex(-3.3,0.6,0);
vertex(0,0,-4);
vertex(2,-3,-4);
vertex(-2,-3,-4);
vertex(0,0,-4);
vertex(-2,-3,-4);
vertex(-3.3,0.6,-4);
vertex(0,0,-4);
vertex(2,-3,-4);
vertex(3.3,0.6,-4);
vertex(0,0,-4);
vertex(0,3.2,-4);
vertex(3.3,0.6,-4);
vertex(0,0,-4);
vertex(0,3.2,-4);
vertex(-3.3,0.6,-4);
vertex(2,-3,-4);
vertex(0,-9,-2);
vertex(-2,-3,-4);
vertex(-2,-3,-4);
vertex(-9,-3,-2);
vertex(-3.3,0.6,-4);
vertex(2,-3,-4);
vertex(9,-3,-2);
vertex(3.3,0.6,-4);
vertex(0,3.2,-4);
vertex(6.5,7.2,-2);
vertex(3.3,0.6,-4);
vertex(0,3.2,-4);
vertex(-6.5,7.2,-2);
vertex(-3.3,0.6,-4);
vertex(0,-9,-2);
vertex(2,-3,-4);
vertex(2,-3,0);
vertex(0,-9,-2);
vertex(-2,-3,-4);
vertex(-2,-3,0);
vertex(-9,-3,-2);
vertex(-2,-3,-4);
vertex(-2,-3,0);
vertex(-9,-3,-2);
vertex(-3.3,0.6,-4);
vertex(-3.3,0.6,0);
vertex(9,-3,-2);
vertex(2,-3,-4);
vertex(2,-3,0);
vertex(9,-3,-2);
vertex(3.3,0.6,-4);
vertex(3.3,0.6,0);
vertex(6.5,7.2,-2);
vertex(0,3.2,-4);
vertex(0,3.2,0);
vertex(6.5,7.2,-2);
vertex(3.3,0.6,-4);
vertex(3.3,0.6,0);
vertex(-6.5,7.2,-2);
vertex(0,3.2,-4);
vertex(0,3.2,0);
vertex(-6.5,7.2,-2);
vertex(-3.3,0.6,-4);
vertex(-3.3,0.6,0);
endShape();
}
Comments