Jello Cube Simulation
Simulating a Mass-Spring System
Pranav Rathod
Date: February 19, 2025
For this assignment, I successfully implemented a physically based simulation of a Jello Cube using a mass-spring system. The cube deforms, oscillates, and reacts realistically to forces based on Newton’s laws of motion, Hooke’s law, and damping forces.
Video Demonstration
Core Features Implemented:
- 
Acceleration Computation ( computeAcceleration()inphysics.cpp):- Structural, shear, and bend spring forces
- External force field (if present)
- Collision response with the bounding box
 The elasticity of the Jello Cube is modeled using a mass-spring system, where forces follow Hooke’s Law: - F: restoring force
- k: spring constant
- x: current length
- x0: rest length
 Each mass point connects to others via structural, shear, and bend springs, allowing the cube to deform and recover naturally. - 
Damping Forces: To stabilize the system and reduce oscillations, damping forces are computed as: - k_d: damping coefficient
- (v_A - v_B): velocity difference
- L: displacement vector between connected points
 
 
- 
Euler and RK4 Integration: Both integration methods were implemented to advance the simulation over time with tunable timestep values. - 
Collision Detection & Penalty Response (Bounding Box): Ensures all control points stay within [-2, 2]by applying a spring force when out of bounds.
 
- 
- 
External Force Field: Trilinear interpolation was used to calculate external force values from a 3D grid defined in the .wfile.- Grid Indexing – mapping position to force grid
- Interpolation – blending 8 surrounding vectors
 
- 
OpenGL Visualization: - Wireframe and shaded surface rendering modes
- Real-time camera controls
- Toggle visibility for structural, shear, and bend springs
 
Extra Credit Implemented
Inclined Plane Collision
- 
Supported via user-defined coefficients in the world file: 
- 
Rendering: Drawn dynamically in showInclinedPlane()using 4 corners based on the plane equation.
- 
Collision Detection & Response: - Each control point is checked against the plane.
- If below, a penalty force pushes it above the surface.
- Includes damping opposite to velocity to absorb energy.
 
- 
Implemented in applyCollisionForces()insidephysics.cpp.
The inclined plane adds more complexity and realism to the cube’s motion and response.
Development Environment
- OS: MacOS
- Editor: Visual Studio Code
- Compiler: Clang++ (C++17)
- Build System: Makefile
- Libraries: OpenGL, GLUT (Mac Frameworks)
Compilation Instructions
- 
Build the project make
- 
Run the simulation with a world file ./jello world/jello.w
- 
Create a world file ./createWorld
- 
Clean build artifacts make clean
Note: The Makefile auto-detects MacOS and links the correct OpenGL/GLUT frameworks.
Notes
- The simulation was tested using multiple world files including custom-generated ones.
- Performance is interactive with frame rates > 15fps at 640x480.
- A Mac executable is included, but the grader may recompile on Windows as needed.
 
 