POV-Ray : Newsgroups : povray.text.scene-files : Classic Trek Interiors - deckrooms.inc Server Time
22 Dec 2024 09:31:51 EST (-0500)
  Classic Trek Interiors - deckrooms.inc (Message 1 to 1 of 1)  
From: Jo Jaquinta
Subject: Classic Trek Interiors - deckrooms.inc
Date: 7 Mar 2005 15:45:18
Message: <422cbd5e@news.povray.org>
For the conversation on p.b.i...

// Persistence of Vision Ray Tracer Scene Description File
// File: deckrooms.inc
// Vers: 3.5
// Desc: Stateroom macros for Deck systems
// Date: 02/11/05
// Auth: Joseph Jaquinta
//

// scale units in meters

#declare deck_dumb = 0;
#declare deck_smart = 0;

#macro deck_room_bounds(leftAngle, rightAngle, insideRadius, outsideRadius)
   #local sinLeft = -sin(radians(leftAngle));
   #local cosLeft = cos(radians(leftAngle));
   #local sinRight = -sin(radians(rightAngle));
   #local cosRight = cos(radians(rightAngle));
   #local sgnSinLeft = sgn(sinLeft);
   #local sgnSinRight = sgn(sinRight);
   #local sgnCosLeft = sgn(cosLeft);
   #local sgnCosRight = sgn(cosRight);

   //#debug 
concat("p1=(",str(cosLeft*outsideRadius,5,2),",",str(sinLeft*outsideRadius,5,2),")\n")
   //#debug 
concat("p2=(",str(cosLeft*insideRadius,5,2),",",str(sinLeft*insideRadius,5,2),")\n")
   //#debug 
concat("p3=(",str(cosRight*outsideRadius,5,2),",",str(sinRight*outsideRadius,5,2),")\n")
   //#debug 
concat("p4=(",str(cosRight*insideRadius,5,2),",",str(sinRight*insideRadius,5,2),")\n")

   #local 
lowBound=<min(cosLeft*outsideRadius,cosLeft*insideRadius,cosRight*outsideRadius,cosRight*insideRadius)-DECK_WALL_THICK,-e,min(sinLeft*outsideRadius,sinLeft*insideRadius,sinRight*outsideRadius,sinRight*insideRadius)-DECK_WALL_THICK>;
   #local 
highBound=<max(cosLeft*outsideRadius,cosLeft*insideRadius,cosRight*outsideRadius,cosRight*insideRadius)+DECK_WALL_THICK,DECK_HEIGHT+e,max(sinLeft*outsideRadius,sinLeft*insideRadius,sinRight*outsideRadius,sinRight*insideRadius)+DECK_WALL_THICK>;
   //#debug concat("leftAngle=",str(leftAngle,5,2),", 
rightAngle=",str(rightAngle,5,2),".\n")
   //#debug 
concat("bounds1=<",str(lowBound.x,5,2),",",str(lowBound.y,5,2),",",str(lowBound.z,5,2),">,<",str(highBound.x,5,2),",",str(highBound.y,5,2),",",str(highBound.z,5,2),">\n")
   #if (sgnSinLeft != sgnSinRight)
     #if (sgnCosLeft < 0)
       #local lowBound = 
<-outsideRadius-DECK_WALL_THICK,lowBound.y,lowBound.z>;
       //#debug concat("  clip left (-x).\n")
     #else
       #local highBound = 
<outsideRadius+DECK_WALL_THICK,highBound.y,highBound.z>;
       //#debug concat("  clip right (+x).\n")
     #end
   #else
     #if (sgnCosLeft != sgnCosRight)
       #if (sgnSinLeft > 0)
         #local highBound = 
<highBound.x,highBound.y,outsideRadius+DECK_WALL_THICK>;
         //#debug concat("  clip top (+z).\n")
       #else
         #local lowBound = 
<lowBound.x,lowBound.y,-outsideRadius-DECK_WALL_THICK>;
         //#debug concat("  clip bottom (-z).\n")
       #end
     #end
   #end
   //#debug 
concat("bounds2=<",str(lowBound.x,5,2),",",str(lowBound.y,5,2),",",str(lowBound.z,5,2),">,<",str(highBound.x,5,2),",",str(highBound.y,5,2),",",str(highBound.z,5,2),">\n")
   box { lowBound, highBound }
#end

#macro deck_room_bounds_30pps(leftAngle, rightAngle, insideRadius, 
outsideRadius)
   #local sinLeft = sin(radians(leftAngle));
   #local cosLeft = cos(radians(leftAngle));
   #local sinRight = sin(radians(rightAngle));
   #local cosRight = cos(radians(rightAngle));
   #if (sinLeft < 0)
     #local sgnSinLeft = -1;
   #else
     #if (sinLeft > 0)
       #local sgnSinLeft = 1;
     #else
       #local sgnSinLeft = 0;
     #end
   #end
   #if (sinRight < 0)
     #local sgnSinRight = -1;
   #else
     #if (sinRight > 0)
       #local sgnSinRight = 1;
     #else
       #local sgnSinRight = 0;
     #end
   #end
   #if (cosLeft < 0)
     #local sgnCosLeft = -1;
   #else
     #if (cosLeft > 0)
       #local sgnCosLeft = 1;
     #else
       #local sgnCosLeft = 0;
     #end
   #end
   #if (cosRight < 0)
     #local sgnCosRight = -1;
   #else
     #if (cosRight > 0)
       #local sgnCosRight = 1;
     #else
       #local sgnCosRight = 0;
     #end
   #end

   #if (sgnSinLeft = sgnSinRight)
     #if (sgnCosLeft = sgnCosRight)
       #local 
lowBound=<min(cosLeft,cosRight)*min(outsideRadius,insideRadius),-e,min(sinLeft,sinRight)*min(outsideRadius,insideRadius)>;
       #local 
highBound=<max(cosLeft,cosRight)*max(outsideRadius,insideRadius),DECK_HEIGHT+e,max(sinLeft,sinRight)*max(outsideRadius,insideRadius)>;
       #declare deck_smart = deck_smart + 1;
     #else
       #local lowBound=<-outsideRadius,-e,-outsideRadius>;
       #local highBound=<outsideRadius,DECK_HEIGHT+e,outsideRadius>;
       #declare deck_dumb = deck_dumb + 1;
     #end
   #else
     #local lowBound=<-outsideRadius,-e,-outsideRadius>;
     #local highBound=<outsideRadius,DECK_HEIGHT+e,outsideRadius>;
     #declare deck_dumb = deck_dumb + 1;
   #end
   box { lowBound, highBound }
#end

// left & right from POV of center of circle
// leftAngle      : left/anticockwise side
// rightAngle     : right/clockwise side
// insideRadius   : inner wall
// outsideRadius  : outer wall
// leftWall       : 0 = skip, 1 = solid, 2 = partition, 3 = door
// rightWall      : 0 = skip, 1 = solid, 2 = partition, 3 = door
// insideWall     : 0 = skip, 1 = solid, 2 = solid with doors
// outsideWall    : 0 = skip, 1 = solid, 2 = solid with doors
#macro deck_room(leftAngle, rightAngle, insideRadius, outsideRadius, 
leftWall, rightWall, insideWall, outsideWall)
union
{
   #local w = outsideRadius - insideRadius;
   #local a = rightAngle - leftAngle;
   // left wall
   #if (leftWall = 1)
     object { deck_wall(w) translate x*insideRadius rotate y*leftAngle }
   #end
   #if (leftWall = 2)
   union
   {
     object { deck_wall(w*.25) }
     object { deck_partition(w*.25) translate x*w*.25 }
     object { deck_wall(w*.25) translate x*w*.75 }
     translate x*insideRadius rotate y*leftAngle
   }
   #end
   #if (leftWall = 3)
   union
   {
     difference
     {
       object { deck_wall(w) }
       object { deck_door1_cutout() translate x*w*.75 }
     }
     object { deck_door1(1) translate x*w*.75 }
     translate x*insideRadius rotate y*leftAngle
   }
   #end
   // right wall
   #if (rightWall = 1)
     object { deck_wall(w) translate x*insideRadius rotate y*rightAngle 
}
   #end
   #if (rightWall = 2)
   union
   {
     object { deck_wall(w*.25) }
     object { deck_partition(w*.25) translate x*w*.25 }
     object { deck_wall(w*.25) translate x*w*.75 }
     translate x*insideRadius rotate y*rightAngle
   }
   #end
   #if (rightWall = 3)
   union
   {
     difference
     {
       object { deck_wall(w) }
       object { deck_door1_cutout() translate x*w*.75 }
     }
     object { deck_door1(1) translate x*w*.75 }
     translate x*insideRadius rotate y*rightAngle
   }
   #end
   // inside wall
   #if (insideWall = 1)
     object { deck_wall_curved(a, insideRadius) rotate y*(-a/2 + 
rightAngle) }
   #end
   #if (insideWall = 2)
   union
   {
     difference
     {
       object { deck_wall_curved(a, insideRadius) }
       object { deck_door1_curved_cutout(insideRadius) }
     }
     object { deck_door1_curved(1, insideRadius) }
     rotate y*(-a/2 + rightAngle)
   }
   #end
   // outside wall
   #if (outsideWall = 1)
     object { deck_wall_curved(a, outsideRadius) rotate y*(-a/2 + 
rightAngle) }
   #end
   #if (outsideWall = 2)
   union
   {
     difference
     {
       object { deck_wall_curved(a, outsideRadius) }
       object { deck_door1_curved_cutout(outsideRadius) }
     }
     object { deck_door1_curved(1, outsideRadius) }
     rotate y*(-a/2 + rightAngle)
   }
   #end
}
#end

#macro deck_room_lounge(leftAngle, rightAngle, insideRadius, 
outsideRadius, leftWall, rightWall, insideWall, outsideWall)
   deck_room(leftAngle, rightAngle, insideRadius, outsideRadius, 
leftWall, rightWall, insideWall, outsideWall)
#end

#macro deck_room_bedroom(leftAngle, rightAngle, insideRadius, 
outsideRadius, leftWall, rightWall, insideWall, outsideWall)
   deck_room(leftAngle, rightAngle, insideRadius, outsideRadius, 
leftWall, rightWall, insideWall, outsideWall)
#end

#macro deck_room_bathroom(leftAngle, rightAngle, insideRadius, 
outsideRadius, leftWall, rightWall, insideWall, outsideWall)
   deck_room(leftAngle, rightAngle, insideRadius, outsideRadius, 
leftWall, rightWall, insideWall, outsideWall)
#end

#macro deck_room_stateroom_onedouble(leftAngle, rightAngle, 
insideRadius, outsideRadius, leftWall, rightWall, insideWall, outsideWall)
union
{
   #local a = (rightAngle - leftAngle)/5;
   // lounge
   deck_room_lounge(leftAngle+a*0, leftAngle+a*2, insideRadius, 
outsideRadius, leftWall, 2, insideWall, outsideWall)
   // bedroom
   deck_room_bedroom(leftAngle+a*2, leftAngle+a*4, insideRadius, 
outsideRadius, 0, 3, insideWall, outsideWall)
   // bathroom
   deck_room_bathroom(leftAngle+a*4, leftAngle+a*5, insideRadius, 
outsideRadius, 0, rightWall, 1, 1)
   bounded_by { deck_room_bounds(leftAngle, rightAngle, insideRadius, 
outsideRadius) }
}
#end

#macro deck_room_stateroom_twodoubles(leftAngle, rightAngle, 
insideRadius, outsideRadius, leftWall, rightWall, insideWall, outsideWall)
union
{
   #local a = (rightAngle - leftAngle)/9;
   // left lounge
   deck_room_lounge(leftAngle+a*0, leftAngle+a*2, insideRadius, 
outsideRadius, leftWall, 2, insideWall, outsideWall)
   // left bedroom
   deck_room_bedroom(leftAngle+a*2, leftAngle+a*4, insideRadius, 
outsideRadius, 0, 3, insideWall, outsideWall)
   // bathroom
   deck_room_bathroom(leftAngle+a*4, leftAngle+a*5, insideRadius, 
outsideRadius, 0, 0, 1, 1)
   // right bedroom
   deck_room_bedroom(leftAngle+a*5, leftAngle+a*7, insideRadius, 
outsideRadius, 3, 0, insideWall, outsideWall)
   // right lounge
   deck_room_lounge(leftAngle+a*7, leftAngle+a*9, insideRadius, 
outsideRadius, 2, rightWall, insideWall, outsideWall)
   bounded_by { deck_room_bounds(leftAngle, rightAngle, insideRadius, 
outsideRadius) }
}
#end

// leftDouble : 0 = none, 1 = present
// rightDouble : 0 = none, 1 = present
#macro deck_room_stateroom_quad(leftAngle, rightAngle, insideRadius, 
outsideRadius, leftWall, rightWall, insideWall, outsideWall, leftDouble, 
rightDouble)
union
{
   #local a = (rightAngle - leftAngle)/(8 + leftDouble*4 + rightDouble*4);
   #local ang = leftAngle;
   #if (leftDouble > 0)
     // left lounge
     deck_room_lounge(ang+a*0, ang+a*2, insideRadius, outsideRadius, 
leftWall, 2, insideWall, outsideWall)
     // left bedroom
     deck_room_bedroom(ang+a*2, ang+a*4, insideRadius, outsideRadius, 0, 
3, insideWall, outsideWall)
     #local ang = ang + a*4;
     #local leftWall = 0;
   #end
   #if (rightDouble > 0)
     // right bedroom
     deck_room_bedroom(ang+a*8, ang+a*10, insideRadius, outsideRadius, 
0, 3, insideWall, outsideWall)
     // right lounge
     deck_room_lounge(ang+a*10, ang+a*12, insideRadius, outsideRadius, 
1, rightWall, insideWall, outsideWall)
     #local rightWall = 3;
   #end
   // left bathroom
   deck_room_bathroom(ang+a*0, ang+a*1, insideRadius, outsideRadius, 
leftWall, 3, 1, 1)
   // left bedroom
   deck_room_bedroom(ang+a*1, ang+a*3, insideRadius, outsideRadius, 0, 
2, insideWall, outsideWall)
   // mid lounge
   deck_room_lounge(ang+a*3, ang+a*5, insideRadius, outsideRadius, 0, 0, 
insideWall, outsideWall)
   // right bedroom
   deck_room_bedroom(ang+a*5, ang+a*7, insideRadius, outsideRadius, 2, 
0, insideWall, outsideWall)
   // right bathroom
   deck_room_bathroom(ang+a*7, ang+a*8, insideRadius, outsideRadius, 3, 
rightWall, 1, 1)
   bounded_by { deck_room_bounds(leftAngle, rightAngle, insideRadius, 
outsideRadius) }
}
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.