Kevin Song
I'm a student at UT (that's the one in Austin) who studies things.
Same requirements as Project 2, but in 3D.
3D Version of this took 6 days!
Scenes you can animate:
https://www.youtube.com/watch?v=0Gi0ssQkWok&t=4120s
I hate to make it sound like everything is really difficult but....this is the kind of job that takes someone with 10 years of practice days to do really well.
No. Textures map onto a single surface, overlapping shapes are more than one surface. You would have to join the shapes.
Not in the Phong model, because all objects are opaque. If you allow object transparency, there are some analogues (but this falls squarely in the realm of "advanced shading models").
No. Light intensities are added.
Most systems require raster images for textures.
This is all handled for you, though we'll have a peek at how this is done at the end of next week.
these eyes will not be blinded by the lights
Many different variations:
Classical mechanics is the study of forces on bodies.
Based on well-understood laws (Newtonian)
If the car is going 25mph, it's kind of important to know whether it's moving left or right!
25 mph?
25 mph?
We can represent velocity and acceleration as vectors.
Vectors have direction and magnitude.
In 1D, vectors are just (signed) numbers.
Addition
Scaling
We can set rules and relationships between our three quantities to modify physical behavior.
For now, we'll work with a simple, intuitive version of Newton's Laws of Motion:
float y = 0.0;
float r = 30.0;
float vel = 0.0;
float accel = 0.03;
void setup(){
size(500, 500);
}
void draw() {
ellipse(250, y, r, r);
vel += accel;
y += vel;
if (y > height) {
y = 0.0;
}
}
Gravity is a downward force (we already have this).
Friction is a force which opposes the velocity.
Spring force is the force needed to compress a spring
Coefficient of restitution describes the loss of energy when objects collide.
float y = 0.0;
float r = 30.0;
float vel = 0.0;
float accel = 0.0;
float gravity = 0.05;
float coef_fric = 0.001;
float coef_rest = 0.8;
void setup(){
size(500, 500);
ellipseMode(RADIUS);
}
void draw() {
background(210);
ellipse(250, y, r, r);
accel = gravity;
vel += accel;
vel -= coef_fric * vel;
y += vel;
if (y > (height - r)) {
vel = -(coef_rest * vel);
y = height - r; // Massive hack
}
}
Note: we still haven't solved the problem that our simulation is unprincipled---but it sure looks more interesting!
Particle
class with at least the members shown to the right.class Particle {
float y = 0.0;
float r = 30.0;
float vel = 0.0;
float accel = 0.0;
float gravity = 0.05;
// Update the particle's acceleration
void applyForce(){}
// Take a step using the current
// accleration + velocity settings
void advanceTime(){}
// Draw the particle
void draw(){}
}
where N > 1
In 2D, a particle will need six variables to hold its state:
In 3D, we'll need nine variables.
Now imagine that we have 50 particles (we're about to have that!). How many variables do we need?
class Particle {
float x;
float y;
float vx;
float vy;
float ax;
float ay;
void applyForce(){
// Code code code...
}
}
The PVector
class lets us store vectors in a class in Processing.
PVector p1 = new PVector(1,2);
PVector p2 = new PVector(2,4);
PVector p3 = p1.add(p2);
PVector p4 = p3.mult(2);
// Alternate way of creating p4
PVector p5 = p1.add(p2).mult(2);
Basic math operations (+, -, /, *, ^
) are not defined on classes, so we need to use methods like .add()
or .mult()
to do math on PVector
s.
class Particle {
PVector pos;
PVector vel;
PVector accel;
void applyForce(){
// Code code code...
}
}
applyForce()
so that it takes a PVector
indicating the force acting on the particle at the time.Examples: smoke, water, fire, clouds, dust, galaxies, etc.
Generally, there will be three "stages" in a particle system, though these can be thought more as decisions to make than as discrete stages.
Fireworks
Snowstorm
Particle
Additional rules (usually written as methods) can make the behavior of our Particle
class more complex and interesting:
Linked from https://en.wikipedia.org/wiki/Particle_system#/media/File:Particle_Emitter.jpg
Take the Particle class you've written and do one of the following with it:
In either case, you should add some randomness to the initial velocity of the particles so that they don't all do exactly the same thing. The random()
method may be useful for this.
By Kevin Song
I'm a student at UT (that's the one in Austin) who studies things.