Start a effekt on a animated segmentobject after some time in the scene
in
Programming Questions
•
1 year ago
I`m trying to find a way to start a effect that I made in this code to make the twisted "hole" that spins around the wire after some seconds or so. I can`t figure out what to place in the code and where. Here is the code:
Thanks for any help in advance! :)
- int pts = 30; //Speed of the
float angle = 0;
float radius = 90.0; //Size of the wire
// lathe segments
int segments = 60;
float latheAngle = 100;
float latheRadius = 50.50; //Twist inside the twist (MUST NOT BE OVER A RADIUS OF 1000!!! It will results in fatal error)
//vertices
PVector vertices[], vertices2[];
// for shaded or wireframe rendering
boolean isWireFrame =true; //transparent wire
// for optional helix
boolean isHelix = true; // Stretched wire
float helixOffset = 10; // Lenght of the twist
void setup(){
size(1400, 2400, P3D);
}
void draw(){
background(00,00,00,00);
// basic lighting setup
lights();
// 2 rendering styles
// wireframe or solid
if (isWireFrame){
stroke(211, 105, 3); // Color of the wire
noFill();
}
else {
noStroke();
fill(150, 195, 145);
}
//center and spin toroid
translate(width/2, height/200, -500);
rotateX(frameCount*PI/250);
rotateY(frameCount*PI/580);
rotateZ(frameCount*PI/190);
// initialize point arrays
vertices = new PVector[pts+10];
vertices2 = new PVector[pts+6000];// Twist of the
// fill arrays
for(int i=0; i<=pts; i++){
vertices[i] = new PVector();
vertices2[i] = new PVector();
vertices[i].x = latheRadius + sin(radians(angle))*radius;
if (isHelix){
vertices[i].z = cos(radians(angle))*radius-(helixOffset*
segments)/600000; // Starting spin effect
}
else{
vertices[i].z = cos(radians(angle))*radius;
}
angle+=340.0/pts; // Twist effect
}
// draw toroid
latheAngle = 0;
for(int i=0; i<=segments; i++){
beginShape(QUAD_STRIP);
for(int j=0; j<=pts; j++){
if (i>0){
vertex(vertices2[j].x, vertices2[j].y, vertices2[j].z);
}
vertices2[j].x = cos(radians(latheAngle))*vertices[j].x;
vertices2[j].y = sin(radians(latheAngle))*vertices[j].x; //Trying to make a cool effect with the shape
vertices2[j].z = vertices[j].z;
// optional helix offset
if (isHelix){
vertices[j].z+=helixOffset;
}
vertex(vertices2[j].x, vertices2[j].y, vertices2[j].z);
}
// create extra rotation for helix
if (isHelix){
latheAngle+=770.10/segments;
}
else {
latheAngle+=330.20/segments;
}
endShape();
}
}
Thanks for any help in advance! :)
1