// Animation settings $vpr = [45,0,-90]; $vpt = [0,0,05]; $vpd = 250; // Colors shade = [0.5,0.5,0.45,1]; orange = [1.0,0.5,0.0,1]; black = [0.2,0.2,0.2,1]; white = [0.9,0.9,0.9,1]; // Cone dimensions s = 30; h = s/2; d = s*2; w = h*4.5; // Shadow parameters shadow_angle = 45; // Angle of the shadow (45° = southeast) zoom = 1.5; shad = -1; // -1 = shadow+cone, 0 = cone, 1 = shadow // Shadow projection matrix function shadow_matrix(angle) = [ [1, 0, -cos(angle), 0], [0, 1, -sin(angle), 0], [0, 0, 0, 0], [0, 0, 0, 1] ]; // Helper module for rounded rectangles module rounded_rect(size, radius) { r = (radius > size[0]/2 || radius > size[1]/2) ? min(size[0]/2, size[1]/2) : radius; square_size = [size[0] - 2*r, size[1] - 2*r]; minkowski() { square(square_size, center=true); circle(r); } } // Cone module module cone() { difference() { difference() { union() { // Raised stripe intersection() { color(white) translate([0,0,10]) cylinder(20,8.025,2, center = true, $fn=64); color(white) translate([0,0,11]) cube([20,20,7], center = true); } // Main cone body color(orange) translate([0,0,10]) cylinder(20,8,2, center = true, $fn=64); // Base color(black) translate([0,0,-0.01]) linear_extrude(height = 3, scale = 0.9) { rounded_rect([19, 19], 5, $fn=32); } } // Tip hole color(orange) translate([0,0,13]) cylinder(8, 3, 1, center = false, $fn=32); } // Inner hole color(orange) translate([0,0,8]) cylinder(18,7,2, center = true, $fn=64); } } // Shadow calculation that maintains southeast direction // -- approx // module shadow() { // translate([0, 0, 0.01]) // color(shade) // multmatrix(shadow_matrix(shadow_angle)) // // hull() // modified_cone(); // } // -- accurate module shadow() { translate([0, 0, 0.01]) color(shade) render() // Force rendering to help prevent z-fighting scale([1, 1, 0.001]) // Flatten instead of using hull() multmatrix(shadow_matrix(shadow_angle)) modified_cone(); } module modified_cone() { scale(zoom) rotate([0,0,180-$t*360]) // ANIMATION translate([0,0,9.1]) // cone knocked over rotate([0,111,0]) // cone(); } module final() { // Render the cone if ( shad == 0 || shad == -1 ) { modified_cone(); // Rotated cone } // Render shadow if (shad == 1 || shad == -1) { shadow(); // Southeast-projected shadow } } final();