We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello guys,
Could anyone help how to put a "drawing" or image, using the Proscene library? I would like to put on the scene "Human Body" representing the body, and rotate the same, seeing different angles. Below is the example code.
//https://www.openprocessing.org/sketch/100377
import remixlab.proscene.*;
Particle[] particle;
Scene scene;
int nbPart, neckThick, headShape, shoulderSize, armSize, hipSize,lowerSize, upperSize, thighSize, handSize, legSize, footSize;
PFont font;
void setup() {
size(displayWidth, displayHeight, P3D);
background(0);
noFill();
scene = new Scene(this);
scene.addAnimationHandler(this, "animateScene");
scene.setAxesVisualHint(false);
scene.setAnimationPeriod(40); // 25Hz
scene.startAnimation();
nbPart = 2000;
particle = new Particle[nbPart];
for (int i = 0; i < particle.length; i++)
particle[i] = new Particle();
font = loadFont("CourierNewPSMT-48.vlw");
atualizaPontos();
corpo();
}
void draw() {
background(0);
pushStyle();
strokeWeight(0.7);
beginShape(POINTS);
for (int i = 0; i < nbPart; i++) {
particle[i].draw();
}
corpo();
endShape();
popStyle();
}
void keyPressed() {
if ((key == 'x') || (key == 'X'))
scene.setAnimationPeriod(scene.animationPeriod()-2);
if ((key == 'y') || (key == 'Y'))
scene.setAnimationPeriod(scene.animationPeriod()+2);
}
void animateScene(Scene s) {
for (int i = 0; i < nbPart; i++)
if (particle[i] != null)
particle[i].animate();
}
void atualizaPontos(){
neckThick = 3;
headShape = 0;
shoulderSize = 5;
armSize = -1;
hipSize = -3;
lowerSize = -5;
upperSize = 2;
thighSize = -5;
handSize = 15;
legSize = 0;
footSize = 14;
}
void corpo() {
head(headShape);
neck(neckThick);
shoulders(shoulderSize);
upperArms(armSize);
hips(hipSize);
lowerBody(lowerSize);
upperBody(upperSize);
thighs(thighSize);
kneecaps();
hands(handSize);
legs(legSize);
feet(footSize);
}
void mostrarDados(){
println("neckThick: " + neckThick);
println("headShape: " + headShape);
println("shoulderSize: " + shoulderSize);
println("armSize: " + armSize);
println("hipSize: " + hipSize);
println("lowerSize: " + lowerSize);
println("upperSize: " + upperSize);
println("thighSize: " + thighSize);
println("handSize: " + handSize);
println("legSize: " + legSize);
println("footSize: " + footSize);
}
void head(int headSize) {
fill(255);
bezier(300, 70, 10, 308, 30, 10, 372, 30, 10, 385, 70, 10); //scalp
bezier(300, 70, 10, 300-headSize, 120, 10, 315-headSize, 135, 10, 320, 140, 10); //side
bezier(385, 70, 10, 385+headSize, 120, 10, 370+headSize, 135, 10, 365, 140, 10); //side
bezier(320, 140, 10, 340, 155, 10, 345, 155, 10, 365, 140, 10); //chin
}
void neck(int neckWidth) {
fill(255);
bezier(320, 140, 10, 325-neckWidth, 170, 10, 320-neckWidth, 180, 10, 315, 180, 10); //left neck
bezier(365, 140, 10, 355+neckWidth, 170, 10, 365+neckWidth, 180, 10, 365, 180, 10); //right neck
}
void shoulders(int shoulderWidth) {
fill(255);
bezier(210, 200, 10, 305, 190-shoulderWidth, 10, 310, 185-shoulderWidth, 10, 315, 180, 10); //left trapezius
bezier(365, 180, 10, 370, 190-shoulderWidth, 10, 380, 195-shoulderWidth, 10, 480, 200, 10); //right trapezius
bezier(210, 200, 10, 205, 205, 10, 205, 205, 10, 200, 220, 10); // left shoulder
bezier(480, 200, 10, 485, 205, 10, 485, 205, 10, 490, 220, 10); // right shoulder
}
void upperBody(int upperWidth) {
fill(255);
bezier(240, 250, 10, 245-upperWidth, 300+upperWidth, 10, 250-upperWidth, 325+upperWidth, 10, 275, 325, 10); //left pectoral
bezier(450, 250, 10, 450+upperWidth, 300+upperWidth, 10, 430+upperWidth, 325+upperWidth, 10, 415, 325, 10); //right pectoral
bezier(330, 300, 10, 325, 320, 10, 320, 320, 10, 300, 325, 10); //inner boob
bezier(360, 300, 10, 370, 320, 10, 375, 320, 10, 390, 325, 10); //inner boob
}
void lowerBody(int lowerWidth) {
fill(255);
bezier (260, 320, 10, 260-lowerWidth, 350+lowerWidth/2, 10, 270-lowerWidth, 380+lowerWidth/2, 10, 265, 415, 10); // left side
bezier (430, 320, 10, 430+lowerWidth, 350+lowerWidth/2, 10, 420+lowerWidth, 380+lowerWidth/2, 10, 425, 415, 10); // right side
//bezier (270, 380, 260-lowerWidth, 400+lowerWidth/2, 260-lowerWidth, 410+lowerWidth/2, 270, 415); // left flab
//bezier (420, 380, 430+lowerWidth, 400+lowerWidth/2, 430+lowerWidth, 410+lowerWidth/2, 420, 415); // right flab
}
void hips(int hipWidth) {
fill(255);
bezier(265, 410, 10, 265-hipWidth, 430, 10, 255-hipWidth, 435, 10, 260, 450, 10); //left hip
bezier(425, 410, 10, 425+hipWidth, 430, 10, 435+hipWidth, 435, 10, 430, 450, 10); //left hip
}
void thighs(int thighWidth) {
fill(255);
bezier(260, 450, 10, 240-thighWidth, 500, 10, 250-thighWidth, 525, 10, 270, 650, 10); //left thigh side
bezier(335, 480, 10, 340+thighWidth, 500, 10, 330+thighWidth, 525, 10, 320, 650, 10); //right thigh side
bezier(430, 450, 10, 445+thighWidth, 500, 10, 440+thighWidth, 525, 10, 420, 650, 10); //left thigh side
bezier(360, 480, 10, 355-thighWidth, 500, 10, 355-thighWidth, 525, 10, 370, 650, 10); //right thigh side
bezier(335, 480, 10, 340, 483, 10, 340, 483, 10, 360, 480, 10);
}
void kneecaps() {
fill(255);
bezier(270, 650, 10, 270, 655, 10, 265, 655, 10, 270, 690, 10); // left kneecap side
bezier(320, 650, 10, 320, 655, 10, 325, 655, 10, 320, 690, 10); // right kneecap side
bezier(420, 650, 10, 420, 655, 10, 425, 655, 10, 420, 690, 10); // left kneecap side
bezier(370, 650, 10, 370, 655, 10, 365, 655, 10, 370, 690, 10); // right kneecap side
}
void upperArms(int armWidth) {
fill(255);
bezier(200, 220, 10, 190-armWidth, 300, 10, 200-armWidth, 310, 10, 200, 350, 10); // left forearm side
bezier(200, 350, 10, 180-armWidth, 425, 10, 200-armWidth, 500, 10, 200, 500, 10); // left arm side
bezier(240, 250, 10, 240+armWidth, 300, 10, 235+armWidth, 310, 10, 235, 350, 10); // left forearm inside
bezier(235, 350, 10, 240+armWidth, 425, 10, 230+armWidth, 450, 10, 225, 500, 10); // left arm inside
bezier(490, 220, 10, 500+armWidth, 300, 10, 490+armWidth, 310, 10, 490, 350, 10); // right forearm
bezier(490, 350, 10, 510+armWidth, 425, 10, 490+armWidth, 500, 10, 490, 500, 10); // right arm
bezier(450, 250, 10, 450-armWidth, 300, 10, 455-armWidth, 310, 10, 455, 350, 10); // right forearm inside
bezier(455, 350, 10, 460-armWidth, 425, 10, 455-armWidth, 450, 10, 465, 500, 10); // right arm inside
}
void hands(int handWidth) {
fill(255);
bezier(200, 500, 10, 210-handWidth, 530, 10, 175-handWidth, 560, 10, 220, 575, 10); // left hand
bezier(220, 575, 10, 225+handWidth, 575, 10, 220+handWidth, 560, 10, 225, 500, 10); // left hand
bezier(490, 500, 10, 480+handWidth, 530, 10, 500+handWidth, 560, 10, 490, 575, 10); // right hand
bezier(465, 500, 10, 460-handWidth, 575, 10, 455-handWidth, 560, 10, 490, 575, 10); // right hand
}
void legs(int legWidth) {
fill(255);
bezier(270, 690, 10, 255-legWidth, 775, 10, 265-legWidth, 800, 10, 275, 850, 10); //left calf
bezier(320, 690, 10, 320+legWidth, 775, 10, 300+legWidth, 800, 10, 300, 850, 10); //left calf
bezier(420, 690, 10, 435+legWidth, 775, 10, 415+legWidth, 800, 10, 405, 850, 10); //right calf
bezier(370, 690, 10, 370-legWidth, 775, 10, 380-legWidth, 800, 10, 380, 850, 10); //left calf
}
void feet(int footWidth) {
fill(255);
bezier(275, 850, 10, 250-footWidth, 900+footWidth, 10, 280-footWidth, 900+footWidth, 10, 300, 850, 10); // left foot
bezier(405, 850, 10, 430+footWidth, 900+footWidth, 10, 400+footWidth, 900+footWidth, 10, 380, 850, 10); // left foot
}
class Particle {
PVector speed;
PVector pos;
int age;
int ageMax;
public Particle() {
speed = new PVector();
pos = new PVector();
init();
}
public void animate() {
speed.z -= 0.05f;
pos = PVector.add(pos, PVector.mult(speed, 10f));
if (pos.z < 0.0) {
speed.z = -0.8f * speed.z;
pos.z = 0.0f;
}
if (++age == ageMax)
init();
}
public void draw() {
stroke( 255 * ((float) age / (float) ageMax), 255 * ((float) age / (float) ageMax), 255);
vertex(pos.x, pos.y, pos.z);
}
public void init() {
pos = new PVector(0.0f, 0.0f, 0.0f);
float angle = 2.0f * PI * random(1);
float norm = 0.04f * random(1);
speed = new PVector(norm * cos(angle), norm * sin(angle), random(1));
age = 0;
ageMax = 50 + (int) random(100);
}
}
Thank you for attention