Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.core.*;
- import peasycam.*;
- class Flight {
- PVector origin;
- PVector destination;
- }
- public class FlightAnimation extends PApplet {
- float radius = 150;
- PeasyCam cam;
- PVector lightPosition = new PVector(300, 300, 200);
- Flight flight;
- PVector target; // Target point for "fly to" animation
- void setup() {
- size(600, 600, P3D);
- cam = new PeasyCam(this);
- background(0);
- smoothLighting();
- // Define flight data (Moscow to Washington coordinates are estimates)
- flight = new Flight();
- flight.origin = new PVector(0, radius * sin(radians(55.75)), radius * cos(radians(55.75))); // Moscow (latitude, longitude)
- flight.destination = new PVector(0, radius * sin(radians(38.90)), radius * cos(radians(38.90))); // Washington (latitude, longitude)
- // Define target point (replace with your desired coordinates)
- target = flight.destination; // Initially target the flight destination
- }
- void draw() {
- pointLight(255, 255, 255, lightPosition.x, lightPosition.y, lightPosition.z);
- noStroke();
- fill(200);
- sphere(radius);
- // Draw flight path
- stroke(255);
- strokeWeight(2);
- line(flight.origin.x, flight.origin.y, flight.origin.z, flight.destination.x, flight.destination.y, flight.destination.z);
- // Simple plane at origin (replace with your plane model)
- pushMatrix();
- translate(flight.origin.x, flight.origin.y, flight.origin.z);
- rotateX(HALF_PI); // Adjust rotation for desired plane orientation
- box(10, 20, 5); // Replace with your plane dimensions
- popMatrix();
- // "Fly to" animation (comment out for a simple rotation)
- // float angleX = lerp(cam.getRotationX(), atan2(target.z, target.x), 0.01f);
- // float angleY = lerp(cam.getRotationY(), asin(target.y / radius), 0.01f);
- // cam.setRotation(angleX, angleY);
- // Simple rotation animation (uncomment for basic rotation)
- float angle = frameCount * 0.01f;
- rotateY(angle);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement