Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- @Author: Jan-David Schulz
- Aufgabe 4: 3DCG - WS 2019/2020
- Mit den Maustasten kann man sich im Canvas bewegen, um die Formen zu betrachten
- Keys to use: / Q-A / S-X / R-F / H-N / UP-DOWN / LEFT
- / BaseSegmente / SideSegmente / Radius / Höhe / Größe / toggle Fill
- */
- import peasy.*;
- PeasyCam cam;
- //Farbe für die Formen festlegen
- private color c1 = color(100, 13, 190);
- private color c2 = color(200, 60, 100);
- //Formen
- private Kegel kegel;
- private Zylinder zylinder;
- private int radius = 5;
- private int hoehe = 15;
- private int baseSegmente = 10;
- private int sideSegmente= 5;
- private int size = 20;
- private boolean fill = true;
- private float drehen = 0.0f;
- void setup() {
- size(1000, 1000, P3D);
- cam = new PeasyCam(this, 100);
- cam.setMinimumDistance(800);
- cam.setMaximumDistance(2000);
- kegel=new Kegel();
- zylinder=new Zylinder();
- }
- public void draw() {
- lights();
- background(0);
- pushMatrix();
- //Mittelpunkt des Canvas
- translate(width/2, height/2);
- //kontinuierliche Drehung der Elemente im Canvas
- drehen +=0.05f;
- //Push Kegel
- pushMatrix();
- strokeWeight(0.03);
- stroke(255);
- //translate(-200, 0, 0);
- kegel.draw(hoehe, radius, baseSegmente, c1, size, 90, 0, drehen, fill);
- popMatrix();
- //Push Zylinder ----------------------------------------------------------------------------------------------------------------------
- pushMatrix();
- strokeWeight(0.05);
- stroke(255);
- //translate(-200, 0, 0);
- zylinder.draw(hoehe, radius, baseSegmente,sideSegmente, c1, size, 90, 0, drehen, fill);
- popMatrix();
- popMatrix();
- }
- public void keyPressed() {
- if (keyPressed) {
- if (key == 'r') {
- radius++;
- }
- if (key == 'f') {
- radius--;
- }
- if (key == 'h') {
- hoehe++;
- }
- if (key == 'n') {
- hoehe--;
- }
- if (key == 's') {
- sideSegmente++;
- }
- if (key == 'x') {
- sideSegmente--;
- }
- if (key == 'q') {
- baseSegmente++;
- }
- if (key == 'a' && baseSegmente > 1) {
- baseSegmente--;
- }
- if (keyCode == UP) {
- size += 5;
- }
- if (keyCode == DOWN) {
- size -= 5;
- }
- if (keyCode == LEFT) {
- fill=!fill;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement