more renderabilitys
This commit is contained in:
		
							parent
							
								
									6e14005163
								
							
						
					
					
						commit
						ff50ee35aa
					
				
							
								
								
									
										93
									
								
								koffer.scad
									
									
									
									
									
								
							
							
						
						
									
										93
									
								
								koffer.scad
									
									
									
									
									
								
							| @ -14,10 +14,20 @@ DEPTH = 5; // [1:1:10] | |||||||
| 
 | 
 | ||||||
| DIMENTION = "2d"; // [2d: 2d export view, 3d: 3d render] | DIMENTION = "2d"; // [2d: 2d export view, 3d: 3d render] | ||||||
| POSITION = "inplace"; // [inplace: in place, origin: at the origin] | POSITION = "inplace"; // [inplace: in place, origin: at the origin] | ||||||
| RENDER = "all"; // [bot: bottom, lid: lid, front: front, back: back, left: left, right: right, all: all] | //RENDER = "all"; // [bot: bottom, lid: lid, front: front, back: back, left: left, right: right, all: all] | ||||||
|  | RENDER = "all"; | ||||||
| 
 | 
 | ||||||
| LAYOUT_SEPERATION = 15; // [1:1:50] | LAYOUT_SEPERATION = 15; // [1:1:50] | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | /*[lid]*/ | ||||||
|  | 
 | ||||||
|  | LID_ANGLE = 45; // [0:170] | ||||||
|  | /* | ||||||
|  | %square([600, 300]); | ||||||
|  | %square([700, 400]); | ||||||
|  | %square([400, 700]); | ||||||
|  | */ | ||||||
| function finger(flip=[1,0], dir="y") = [ | function finger(flip=[1,0], dir="y") = [ | ||||||
| 	[ | 	[ | ||||||
| 		0, 0 | 		0, 0 | ||||||
| @ -65,7 +75,7 @@ module fingers(flip=[1,1], dir="y", number=2, nub=true){ | |||||||
| 		); | 		); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module render(3dPos, 3dRotation, 2dPos){ | module renderPart(3dPos, 3dRotation, 2dPos){ | ||||||
| 	if (DIMENTION == "2d"){ | 	if (DIMENTION == "2d"){ | ||||||
| 		if (POSITION == "inplace") | 		if (POSITION == "inplace") | ||||||
| 			translate(2dPos) | 			translate(2dPos) | ||||||
| @ -85,24 +95,52 @@ module render(3dPos, 3dRotation, 2dPos){ | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| if (RENDER == "bot" || RENDER == "all") | function split(str, sep=" ", i=0, word="", v=[]) = | ||||||
|  | 	(i == len(str)) ? concat(v, word) : | ||||||
|  | 		(str[i] == sep) ? split(str, sep, i+1, "", concat(v, word)) : | ||||||
|  | 			split(str, sep, i+1, str(word, str[i]), v); | ||||||
|  | 
 | ||||||
|  | module render(name, 3dPos, 3dRotation, 2dPos){ | ||||||
|  | 	if (RENDER == "all") | ||||||
|  | 		renderPart(3dPos, 3dRotation, 2dPos) children(); | ||||||
|  | 	else { | ||||||
|  | 		for (i = split(RENDER, ",")){ | ||||||
|  | 			if (i == name){ | ||||||
|  | 				renderPart(3dPos, 3dRotation, 2dPos) children(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| render( | render( | ||||||
|  | 	name = "bot", | ||||||
| 	2dPos = [0, 0], | 	2dPos = [0, 0], | ||||||
| 	3dPos = [0, 0, 0], | 	3dPos = [0, 0, 0], | ||||||
| 	3dRotation = [0, 0, 0] | 	3dRotation = [0, 0, 0] | ||||||
| ) | ) | ||||||
| 	bottom(); | 	bottom(); | ||||||
| 
 | 
 | ||||||
| if (RENDER == "front" || RENDER == "all") | /* | ||||||
| render( | render( | ||||||
|  | 	name = "front", | ||||||
| 	2dPos = [-(WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), 0], | 	2dPos = [-(WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), 0], | ||||||
| 	3dPos = [0, MATT_THIKNESS, 0], | 	3dPos = [0, MATT_THIKNESS, 0], | ||||||
| 	3dRotation = [90, 0, 0] | 	3dRotation = [90, 0, 0] | ||||||
|  | ) | ||||||
|  | 	front();*/ | ||||||
|  | render( | ||||||
|  | 	name = "front", | ||||||
|  | 	2dPos = [ | ||||||
|  | 		0, | ||||||
|  | 		2*DEPTH*UNIT + 4*MATT_THIKNESS + 2*LAYOUT_SEPERATION | ||||||
|  | 	], | ||||||
|  | 	3dPos = [0, MATT_THIKNESS, 0], | ||||||
|  | 	3dRotation = [90, 0, 0] | ||||||
| ) | ) | ||||||
| 	front(); | 	front(); | ||||||
| 
 | 
 | ||||||
| if (RENDER == "back" || RENDER == "all") |  | ||||||
| render( | render( | ||||||
|  | 	name = "back", | ||||||
| 	2dPos = [ | 	2dPos = [ | ||||||
| 		-(WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), | 		-(WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), | ||||||
| 		HIEGHT*UNIT + MATT_THIKNESS + LAYOUT_SEPERATION | 		HIEGHT*UNIT + MATT_THIKNESS + LAYOUT_SEPERATION | ||||||
| @ -112,8 +150,8 @@ render( | |||||||
| ) | ) | ||||||
| 	back(); | 	back(); | ||||||
| 
 | 
 | ||||||
| if (RENDER == "left" || RENDER == "all") |  | ||||||
| render( | render( | ||||||
|  | 	name = "left", | ||||||
| 	2dPos = [ | 	2dPos = [ | ||||||
| 		-(DEPTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), | 		-(DEPTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), | ||||||
| 		2*HIEGHT*UNIT + 2*MATT_THIKNESS + 2*LAYOUT_SEPERATION | 		2*HIEGHT*UNIT + 2*MATT_THIKNESS + 2*LAYOUT_SEPERATION | ||||||
| @ -123,8 +161,8 @@ render( | |||||||
| ) | ) | ||||||
| 	side(); | 	side(); | ||||||
| 
 | 
 | ||||||
| if (RENDER == "right" || RENDER == "all") |  | ||||||
| render( | render( | ||||||
|  | 	name = "right", | ||||||
| 	2dPos = [ | 	2dPos = [ | ||||||
| 		-(DEPTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), | 		-(DEPTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), | ||||||
| 		3*HIEGHT*UNIT + 4*MATT_THIKNESS + 3*LAYOUT_SEPERATION | 		3*HIEGHT*UNIT + 4*MATT_THIKNESS + 3*LAYOUT_SEPERATION | ||||||
| @ -134,32 +172,37 @@ render( | |||||||
| ) | ) | ||||||
| 	side(); | 	side(); | ||||||
| 
 | 
 | ||||||
| if (RENDER == "lid" || RENDER == "all") | totalDepth = DEPTH*UNIT + MATT_THIKNESS*2; | ||||||
|  | 
 | ||||||
|  | /*if (RENDER == "lid" || RENDER == "all") | ||||||
| render( | render( | ||||||
| 	2dPos = [ | 	2dPos = [ | ||||||
| 		WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION, | 		WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION, | ||||||
| 		0 | 		0 | ||||||
| 	], | 	], | ||||||
| 	3dPos = [MATT_THIKNESS, 0, HIEGHT*UNIT + MATT_THIKNESS], | 	3dPos = [ | ||||||
| 	3dRotation = [90, 0, 90] | 		MATT_THIKNESS, | ||||||
|  | 		totalDepth - totalDepth*cos(LID_ANGLE), | ||||||
|  | 		HIEGHT*UNIT + MATT_THIKNESS + totalDepth*sin(LID_ANGLE) | ||||||
|  | 	], | ||||||
|  | 	3dRotation = [-LID_ANGLE, 0, 0] | ||||||
|  | ) | ||||||
|  | 	lid();*/ | ||||||
|  | render( | ||||||
|  | 	name = "lid", | ||||||
|  | 	2dPos = [ | ||||||
|  | 		0, | ||||||
|  | 		DEPTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION | ||||||
|  | 	], | ||||||
|  | 	3dPos = [ | ||||||
|  | 		MATT_THIKNESS, | ||||||
|  | 		totalDepth - totalDepth*cos(LID_ANGLE), | ||||||
|  | 		HIEGHT*UNIT + MATT_THIKNESS + totalDepth*sin(LID_ANGLE) | ||||||
|  | 	], | ||||||
|  | 	3dRotation = [-LID_ANGLE, 0, 0] | ||||||
| ) | ) | ||||||
| 	lid(); | 	lid(); | ||||||
| 
 | 
 | ||||||
| // if (RENDER == "lid" || RENDER == "all"){ |  | ||||||
| // 	if (DIMENTION == "2d"){ |  | ||||||
| // 		lid(); |  | ||||||
| // 	} |  | ||||||
| // 	if (DIMENTION == "3d"){ |  | ||||||
| // 		if (POSITION == "inplace") |  | ||||||
| // 			translate([MATT_THIKNESS, 0, HIEGHT*UNIT + MATT_THIKNESS]) |  | ||||||
| // 			linear_extrude(MATT_THIKNESS) |  | ||||||
| // 				lid(); |  | ||||||
| // 		if (POSITION == "origin") |  | ||||||
| // 			linear_extrude(MATT_THIKNESS) |  | ||||||
| // 				lid(); |  | ||||||
| // 	} |  | ||||||
| // } |  | ||||||
| 
 |  | ||||||
| module bottom(){ | module bottom(){ | ||||||
| 	translate([MATT_THIKNESS, MATT_THIKNESS]) | 	translate([MATT_THIKNESS, MATT_THIKNESS]) | ||||||
| 		union(){ | 		union(){ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user