PDA

View Full Version : Spiral Staircase Shading Macro Idea [CC2/CC3]



Arcana
11-16-2006, 11:53 AM
I'm SOOOO not a CC2/3 scripter...I REALLY need to put forth a bit of effort to learn it...but in the meantime, I was wondering if anyone would like to help me figure out some of the logistics of this particular script idea I have.

Its regarding the CStair macro by Ralf...its an awesome macro, and I'm using it extensively to make staircases in towers, just like it was designed...but the staircases are missing depth.

I put up a post on CC2-L but without the ability to include images its kinda hard to describe, so this post will include an image so you can see what I'm doing.

I'm using the transparency fills of CC3 (10% version) and overlapping them with the ARCS command to create a progressively darker shading overlay.

I made this particular staircase pictured (before and after shading) with the CStair macro and manually overlapped the transparency arcs. But the effect with wallshadow and all is just awesome if you ask me.

I need to take Ralfs macro and remove the fact that it creates both light and dark stair segments and make it so it just creates single shorter and shorter arcs along the ARCS stored points path.

Then I need to figure out if its even possible to create a fillstyle that is not in the current template and use it for the arcs it creates.

So the process should be:
-Stair (shading?) width
-Stair (shading?) depth
-Center Point
-Starting Point
-Ending Angle

It should use the '\Bitmaps\Tiles\Transparencies\solid 10.png' bitmap fill with alpha transparency turned on (even if its not in the current template)

Anyone got any ideas? Here's Ralfs script for reference (I'll remove if there's copyright problems):



//the next macro draws a staircase along an arc
//by Ralf Schemmann (improved by Morgan Olden)
MACRO CSTAIR
RDOFF
SELBYP
COLOR 16
FSTYLE Solid
LSTYLE Solid
GV sw1 ^DStair width:
GV stw1 ^DStep depth:
LWIDTH sw1
IFERR edg
GP p1 ^DCenter:
IFERR edg
GP p2 ^DStarting point:
IFERR edg
ARCS p1 p2 ^D
UNDO
GP p3 @0,0
ARCS p1 p2 p3
ARCS p1 p2 p3
OUTLINEB
GDIST r1 p1 p2
GBRNG a1 p1 p2
GBRNG a2 p1 p3
ifn a1-a2 SkipAngleAdjust
gv a2 a2+360
:SkipAngleAdjust
gv stw1 360/(3.1416*(r1*2))*stw1
GV b1 a1+0
GV b2 a2+0
GV b3 b2-1
GV stepi 1.0
IFP stw1-b3 edg
:step
COLOR 14
FSTYLE Solid
GV a3 b2-(stw1*stepi)+(stw1*1/3)
ARCR p1 r1 a1 a3
ESC COLOR 16
GV a4 b2-(stw1*stepi)
ARCR p1 r1 a1 a4
ESC ARCR p1 r1 a1 a4
ESC
OUTLINEB
GV stepi stepi+1.0
IFP (b2-(stw1*stepi))-b1 step
:edg
REDRAW SELBYD
RDON
ENDM

DaltonSpence
11-25-2006, 09:07 AM
I have a few questions before I start writing the script.
Will your stairs always descend counter-clockwise (ie. start from the bottom)?
Do you want to draw the arc of the stairs or specify the number of steps?
If (in the former case) the step depth does not divide evenly into the arc length of the staircase, do you want to trim the staircase (at top or bottom) or adjust the step depth (top, bottom or all)?
The step shadow is currently 1/3rd the step depth. Do you want to change this? What transparency level should I use for it?
Do you want to add an optional railing on either or both sides?
According to "Architectural Graphic Standards (http://ca.wiley.com/WileyCDA/Section/id-292752.html)", staircases should have at least one landing every twelve feet. Would you like this as an option?
--

Dalton "who's written an aMazing script ... if he could just get it to work" Spence

Arcana
11-25-2006, 09:45 AM
Will your stairs always descend counter-clockwise (ie. start from the bottom)? The original script I think only drew in one direction (a limitation of ARCS I think)...so I can deal with one direction, but two would be nice.
Do you want to draw the arc of the stairs or specify the number of steps? I think the arc would be better...basing the shading on the path of an ARCS as mentioned before
If (in the former case) the step depth does not divide evenly into the arc length of the staircase, do you want to trim the staircase (at top or bottom) or adjust the step depth (top, bottom or all)? I assume this means you will be implementing the shading into a staircase script altogether, thus redoing the CSTAIR macro altogether? if so, specifying a step depth and then adjusting all of them to fit would be ideal, but isn't required...Ralfs CSTAIR doesn't do this.
The step shadow is currently 1/3rd the step depth. Do you want to change this? What transparency level should I use for it? If you're redoing the CStair to use transparencies for the step shadow too, then 20 or 30% should be enough...1/3rd depth is fine. I think Steps should be outlined in black, but step shadows shouldn't be. The overlapping transparent overlay arcs that show depth like in my example however should always be 10%, since they overlap and get darker.
Do you want to add an optional railing on either or both sides? Would be really cool, but isn't necessary...maybe as a separate macro?
According to "Architectural Graphic Standards (http://ca.wiley.com/WileyCDA/Section/id-292752.html)", staircases should have at least one landing every twelve feet. Would you like this as an option? This would probably be a rairly used option, since I and most mappers when adhering to this rule would probably rather aesthetically place such a landing as opposed to sticking to the twelve feet rule...I wouldn't bother

Questions answered in italics ;) hanks for looking at this!

DaltonSpence
11-25-2006, 11:54 AM
Here's what I've got so far. I've skipped points 1, 5 and 6 (I'll add them later), but the rest are covered.
MACRO MyStairC
savesettings
selsave
color 16
fstyle Solid
lstyle Solid
gv vStepWidth 10
gv vStepWidth ^DEnter the stairway width [10]:
gv vStepDepth 1
gv vStepDepth ^DEnter the step spacing [1]:
lwidth vStepWidth
iferr MSC_Done
gp pCenter ^DCenter:
iferr MSC_Done
gp pStart ^DStarting (bottom) point:
iferr MSC_Done
arcs pCenter pStart ^D
gp pEndPt @0,0
selbyp
outlineb
gdist vRadius pCenter pStart
gbrng vStartAngle pCenter pStart
gbrng vEndAngle pCenter pEndPt
gv vStepAngle vStepDepth*180/(3.141592654*vRadius)
ifn vStartAngle-vEndAngle MSC_SkipAdjust
gv vEndAngle vEndAngle+360
:MSC_SkipAdjust
gn nNumSteps (vEndAngle-vStartAngle)/vStepAngle
gv vStepAngle (vEndAngle-vStartAngle)/nNumSteps
gv vEdgeAngle vStartAngle
color 0
:MSC_Step
gv vRiserAngle vEdgeAngle+vStepAngle
ifp vRiserAngle-vEndAngle MSC_Done
gv vShadowAngle vRiserAngle-vStepAngle/3
lwidth vStepWidth
fstyle solid 20 Bitmap
arcr pCenter vRadius vShadowAngle vRiserAngle ESC
fstyle solid 10 Bitmap
arcr pCenter vRadius vStartAngle vRiserAngle ESC
lwidth 0
line ref pCenter <vRiserAngle,(vRadius-vStepWidth/2) <vRiserAngle,vStepWidth;
gv vEdgeAngle vRiserAngle
goto MSC_Step
:MSC_Done
selrest
getsettings
ENDM
Note that my variable names are self explanatory and labels are prefixed to avoid conflicts. Rather than draw each step separately (and twice), I draw a common staircase background first, then put the shading and edge lines on top of it for effect. As to the optional railings (point 5), I'd prefer that they were in this macro so they could be inserted before the MSC_Step loop for depth shading and step shadows/edges can be narrowed so they don't overlap. What sheet/layer should I draw this in?

--

Dalton "who thinks code readability is important as documentation" Spence

Arcana
11-25-2006, 01:22 PM
Looking good...I've got a dog issue at the house (our dog just bit a groomer) so as soon as I get back from dealing with that, I'll take a look at this.

I put mine as follows:

Stairs Layer: UP AND DOWN
Stairs Sheet: SYMBOLS FLAT

Stairs Shading Layer: UP AND DOWN SHADING
Stairs Shading Sheet: SYMBOLS FLAT

DaltonSpence
11-25-2006, 03:51 PM
Hope your dog issues are resolved successfully. I'm inserting some error checking in the macro, and I need a minimum acceptable step width and depth. Using "Architectural standards for starship deckplans (http://www.io.com/~thrash/navarch.html)" by Christopher Thrash as a guide, minimum stair width should be 2.5' with 2' between railings. (Should railing thickness be fixed or variable?) Step tread depth is a little trickier, but my best guess (at least until I can get to the library and check their copy of "Architectural Graphic Standards (http://ca.wiley.com/WileyCDA/Section/id-292752.html)") is that anything less than 6" would be a hazard. At the moment, all errors are fatal and end the macro. What do you think?

EDIT: Here is the revised code without the minimums but with railing support. I'm breaking it into sections for comments.

MACRO MyStairC
savesettings
selsave
rdoff
sgetname sOldSheet
Save current map setting and sheet.
gv vStepWidth 5
gv vStepWidth ^DEnter stairway width [5]:
ifn vStepWidth MSC_Error1
ifz vStepWidth MSC_Error1
gv vStepDepth 1
gv vStepDepth ^DEnter step spacing [1]:
ifn vStepDepth MSC_Error1
ifz vStepDepth MSC_Error1
gv vRailWidth 0.2
gv vRailWidth ^DEnter railing width [0.2]
ifn vRailWidth MSC_Error0
gv vTreadWidth vStepWidth-2*vRailWidth
ifn vTreadWidth MSC_Error2
lwidth vStepWidth
iferr MSC_Done
gp pCenter ^DCenter:
iferr MSC_Done
gp pStart ^DStarting point:
iferr MSC_Done
gdist vRadius pCenter pStart
ifn vRadius-vStepWidth/2 MSC_Error3
Input and check data for errors.
sset SYMBOLS FLAT
color 16
fstyle Solid
lstyle Solid
setlayer UP AND DOWN
arcs pCenter pStart ^D
gp pEndPt @0,0
selbyp
outlineb
Draw staircase background.

gbrng vStartAngle pCenter pStart
ifz vRailWidth MSC_NoRail
color 14
lwidth vRailWidth
offset1 (vStepWidth-vRailWidth)/2
pStart pCenter
pStart <vStartAngle,1;
outlineb
:MSC_NoRail
Draw the railings if necessary.

gbrng vEndAngle pCenter pEndPt
gv vStepAngle vStepDepth*180/(3.141592654*vRadius)
ifn vStartAngle-vEndAngle MSC_SkipAdjust
gv vEndAngle vEndAngle+360
:MSC_SkipAdjust
gn nNumSteps (vEndAngle-vStartAngle)/vStepAngle
gv vStepAngle (vEndAngle-vStartAngle)/nNumSteps
gv vEdgeAngle vStartAngle
color 0
Calculate initial and constant angles required. Note how the step angle is recalculated to evenly divide into the angular width of the staircase.

:MSC_Step
gv vRiserAngle vEdgeAngle+vStepAngle
ifp vRiserAngle-vEndAngle MSC_Done
lwidth 0
setlayer UP AND DOWN
line ref pCenter <vRiserAngle,vRadius-vTreadWidth/2 <vRiserAngle,vTreadWidth
golayer UP AND DOWN SHADING
gv vShadowAngle vRiserAngle-vStepAngle/3
lwidth vTreadWidth
fstyle solid 20 Bitmap
arcr pCenter vRadius vShadowAngle vRiserAngle ESC
lwidth vStepWidth
fstyle solid 10 Bitmap
arcr pCenter vRadius vStartAngle vRiserAngle ESC
gv vEdgeAngle vRiserAngle
goto MSC_Step
Draw the step edges, shadows and shading.
:MSC_Error0
msgbox ERROR! Invalid data entered.
The previously entered data
must be greater than zero.

goto MSC_Done
:MSC_Error1
msgbox ERROR! Invalid data entered.
The previously entered
data must be greater than
or equal to zero.

goto MSC_Done
:MSC_Error2
msgbox ERROR! No space between railings.
The width of the staircase is less
than the combined width of both hand
rails leaving no space between them.

goto MSC_Done
:MSC_Error3
msgbox ERROR! Radius of staircase too small.
The distance from the center of the
staircase to the center of the first
step is less than half of the width
of the step.

Display whatever error message is required.
:MSC_Done
sset sOldSheet
rdon
selrest
getsettings
ENDMRestore map settings and old sheet name.

--

Dalton "who think macros without error traps are asking for trouble" Spence

RPMiller
11-26-2006, 12:22 PM
According to my architecture book from college standard stairs have a rise of 7" and a run of 11". So each step is 11" deep.

DaltonSpence
11-26-2006, 06:03 PM
According to my architecture book from college standard stairs have a rise of 7" and a run of 11". So each step is 11" deep. That is a 32.5� slope. The minimum depth I suggested was a safety thing, based on the 6" a ladder is supposed to be away from a wall. Also, these are most likely modern standards, not medieval ones (unless your textbook is really old :wink: ), so I think some latitude is allowed. According to my measurements (which I made a few minutes ago), the concrete steps in my apartment building are 4' wide, 7" tall and 10" deep. I imagine that medieval structures would vary from the average even more than that.

Anyway, I made some more mods to the macro and got it to work. EDIT: Added option to control the direction of the staircase.

MACRO MS_InVars
gn nErrNum -1
gv vStepWidth 5
gv vMinValue 2.5
gv vStepWidth ^DEnter stairway width [5]:
ifn vStepWidth-vMinValue MSC_Error0
gv vStepDepth 1.0
gv vMinValue 0.5
gv vStepDepth ^DEnter step spacing [1]:
ifn vStepDepth-vMinValue MSC_Error0
gv vRailWidth 0.2
gv vRailWidth ^DEnter railing width [0.2]
ifn vRailWidth MSC_Error1
gv vTreadWidth vStepWidth-2*vRailWidth
gv vMinValue 2.0
ifn vTreadWidth-vMinValue MSC_Error2
exitm
:MSC_Error0
gn nErrNum 0
gl sLastLine minimum value of
apnd sLastLine vMinValue
apnd sLastLine _feet.
msgbox ERROR! Invalid data entered.
The previously entered data must
be greater than or equal to the
sLastLine

exitm
:MSC_Error1
gn nErrNum 1
msgbox ERROR! Invalid data entered.
The previously entered
data must be greater than
or equal to zero.

exitm
:MSC_Error2
gn nErrNum 2
msgbox ERROR! Hand rails too close together
The distance between the hand rails
is less than the minimum value of
vMinValue

ENDMI separated out most of the user input section into a different macro because I plan on writing more stair building macros and these variables will be common to all of them. I also incorporated the minimum value checking I talked about.

MACRO MyStairC
savesettings
selsave
sgetname sOldSheet
MS_InVars
ifp nErrNum+1 MSC_Done
lwidth vStepWidth
iferr MSC_Done
gp pCenter ^DCenter:
iferr MSC_Done
gp pStart ^DStarting point:
iferr MSC_Done
gdist vRadius pCenter pStart
ifn vRadius-vStepWidth/2 MSC_Error3The initial setup and variable initialization section specific to circular staircases.
gn nStartAtTop 0
askbox Direction of Staircase.
Does the staircase ascend in a
clockwise direction (ie. the
starting point was at the top
of the stairs)?

iferr MSC_EndAtTop
gn nStartAtTop 1
:MSC_EndAtTopEDIT: Added the above section to control the direction of the shading. Other changes are below.

sheet SYMBOLS FLAT
color 16
lstyle Solid
fstyle Basic Stone 2 Bitmap
setlayer UP AND DOWN
arcs pCenter pStart ^D
gp pEndPt @0,0
selbyp
outlinebDraw staircase background.

gbrng vStartAngle pCenter pStart

gbrng vEndAngle pCenter pEndPt
ifz vRailWidth MSC_NoRail
color 14
fstyle Solid
lwidth vRailWidth
gv vOffset (vStepWidth-vRailWidth)/2
arcr pCenter vRadius-vOffset vStartAngle vEndAngle
outlineb
arcr pCenter vRadius+vOffset vStartAngle vEndAngle
outlineb
:MSC_NoRailDraw the railings if necessary.

gv vStepAngle vStepDepth*180/(3.141592654*vRadius)
ifn vStartAngle-vEndAngle MSC_SkipAdjust
gv vEndAngle vEndAngle+360
:MSC_SkipAdjust
gn nNumSteps (vEndAngle-vStartAngle)/vStepAngle
gv vStepAngle (vEndAngle-vStartAngle)/nNumSteps
gv vEdgeAngle vStartAngle
color 0Calculate initial and constant angles required. Note how the step angle is recalculated to evenly divide into the angular width of the staircase.

:MSC_Step
gv vRiserAngle vEdgeAngle+vStepAngle
ifp vRiserAngle-vEndAngle MSC_Done
lwidth 0
setlayer UP AND DOWN
line ref pCenter <vRiserAngle,vRadius-vTreadWidth/2 <vRiserAngle,vTreadWidth;
golayer UP AND DOWN SHADING
gv vShadowAngle vRiserAngle-vStepAngle*(1+nStartAtTop)/3
lwidth vTreadWidth
fstyle solid 20 Bitmap
ifp nStartAtTop MSC_UpCW1
arcr pCenter vRadius vShadowAngle vRiserAngle ESC
goto MSC_UpCCW1
:MSC_UpCW1
arcr pCenter vRadius vEdgeAngle vShadowAngle ESC
:MSC_UpCCW1
lwidth vStepWidth
fstyle solid 10 Bitmap
ifp nStartAtTop MSC_UpCW2
arcr pCenter vRadius vStartAngle vRiserAngle ESC
goto MSC_UpCCW2
:MSC_UpCW2
arcr pCenter vRadius vRiserAngle vEndAngle ESC
:MSC_UpCCW2
gv vEdgeAngle vRiserAngle
goto MSC_StepDraw the step edges, shadows and shading. EDIT: Changed the above section to control the direction of the shading.

:MSC_Error3
msgbox ERROR! Radius of staircase too small.
The distance from the center of the
staircase to the center of the first
step is less than half of the width
of the step.

Display whatever error message is required specific to circular staircases. The other error tests are done in the general input macro.

:MSC_Done
sheet sOldSheet
selrest
getsettings
ENDMRestore map settings and old sheet name. Note that I've switched to using sheet instead of sset because the latter considers the blanks in a sheet name to be delimiters.

Below is a sample staircase I created with the macro. Tell me what you think.

--

Dalton "who's actually getting his macros to work today!" Spence

Arcana
11-26-2006, 06:56 PM
Hmmm...I just tried your most recent...and assuming I pasted it in correctly...I got nothing but black steps. It drew the steps pretty well, but I ended up with a 5' wide black arc after it was done.

DaltonSpence
11-26-2006, 11:45 PM
Hmmm...I just tried your most recent...and assuming I pasted it in correctly...I got nothing but black steps. It drew the steps pretty well, but I ended up with a 5' wide black arc after it was done. Well, it works for me (as you can see above). Are you sure you have all the correct bitmap fills loaded? The ones required are:
"Basic Stone 2 Bitmap" for the step surface,
"solid 10 bitmap" for the depth shading and
"solid 20 bitmap" for the step shadows.I've made some more changes recently to add a choice between clockwise and counterclockwise shading. You might notice that the "loose spiral" stairs (Sample1a.png and Sample1c.png) above have 21 steps. With 7" risers that's a total floor-to-floor height of 12'3" (assuming one step is at floor level). I'm thinking that the "tight spiral" has the same number of steps with an additional 360 turn hidden from view, which allows for stacked stairs with 6.5' headroom and a 16 square foot landing. I may turn these images into symbols.

--

Dalton "who hates going down stairs in the dark" Spence[/list]

RPMiller
11-27-2006, 10:37 AM
This has got to be one of the coolest macros I've seen. This is definitely going to get some use later. ;) I'm wondering what other sorts of things this could be used for such as a curving mountain pass or the like. Can you throw up a quick example using wooden stairs also?

DaltonSpence
11-27-2006, 03:48 PM
This has got to be one of the coolest macros I've seen. This is definitely going to get some use later. ;) I'm wondering what other sorts of things this could be used for such as a curving mountain pass or the like. Can you throw up a quick example using wooden stairs also?I'm afraid that's not so simple; to keep the wood grain aligned to the edge of each step I'd need to place an appropriately scaled and rotated bitmap symbol for each one. (Two actually; a rectangle for the main step and a right triangle to fill the gap between that and the outer rim.) You wouldn't happen to have a PNG of a 6'x2' plank I could use for this?

--

Dalton "who's learned woodgrain fill in symbols doesn't rotate" Spence

RPMiller
11-27-2006, 04:05 PM
That is actually what I was wondering about.

Regarding the plank, I actually created one for ProFantasy in the very early stages of CC3 before they started in the Beta program. I don't have it handy on this computer, but something tells me that Arcana has one laying around ( see the forums background. ;))

Arcana
11-27-2006, 07:31 PM
I do have one laying around somewhere...its worn though like the background...I don't have it here, so it might be on my work computer in my textures directory...if not I'll go take a picture of one for you from my fence sometime tomorrow and doctor it up. What resolution would you like?

DaltonSpence
11-27-2006, 08:33 PM
Unfortunately they are a bit dark for our purposes; the depth shading wood wipe out any details after three or four steps. I've taken a plank out of the "Wooden Floor Horizontal_VH.PNG" bitmap and shrunk it down to 500x100 bits (5'x1' at VH resolution) to experiment with. To make this work I will have to rescale the symbol so that the lower left and upper right hand corners touch the inner and outer walls of the stairwell respectively at the assigned step depth. Looks like I'm in for some geometry homework tonight. (Yes,I know this leaves a gap between the front of the upper step and the back of the lower one for the outside half of the step, but I can't see a way around that.)

--

Dalton "who may start getting a bit board with this macro" Spence

RPMiller
11-27-2006, 11:35 PM
That looks a little like the plank I submitted... I wonder... Anyway, I can't wait to see it in action!

DaltonSpence
11-28-2006, 02:46 AM
Your wish is my command. Well, not really, but the test seemed to go well. The problem seemeds to be the last board; since the leading inner corner is flush with the wall, the trailing inner corner would jut out. To fix this, I added a threshold board at the top. Should this be a plain stone threshold instead?

--

Dalton "who's been stairing at this computer screen too long" Spence

Arcana
11-28-2006, 07:23 AM
Well The original version is lighter...light grey to be exact...and had I taken a picture from my fence, it would have been naturally lighter. But this looks amazing...Thats REALLY nice work man...I mean REALLY!

Arcana
11-28-2006, 09:42 AM
Now you just need to put the whole thing in a package (or .mac file) and attach it here :D

RPMiller
11-28-2006, 12:15 PM
Very nice! Is there a way to change the threshold "step" at macro run? I think that would be the best. I am very impressed. This works very nice.

DaltonSpence
11-29-2006, 01:23 AM
Very nice! Is there a way to change the threshold "step" at macro run? I think that would be the best. I am very impressed. This works very nice.Do you want to select types of different threshold steps from a symbol catalog or merely turn it on and off? I can do the latter but have no clue about the former. (If I did, I'd add different stair steps to the catalog for selection as well.) Below is an example using a homemade "Basic Stone Block" symbol as a threshold step.

--

Dalton "who wishes there was a `solid 5 Bitmap' for lighter depth shading" Spence

RPMiller
11-29-2006, 11:53 AM
I think it would be just as easy to draw the threshold and fill it with the bitmap that I'm using for the floor already. I don't think it needs to be a symbol per se.