Intro to RWX Modeling
Example Scripts
page 2


The “axisalignment” command is used to make a model always face the same direction. It’s usually used with “facer” objects like the 2d trees common in Alpha World Prime. (BTW, see  Creating Renderware Objects and choose RenderWare Scripting (RWX) from the menu there for some neat tips on adding shadows to the tree facers in AW!)

rw-facer.rwx

modelbegin
clumpbegin

materialmode double # makes polygons two-sided!

axisalignment zorienty # makes the model always face the viewer

vertex -.1  0  0 UV 0 1
vertex  .1  0  0 UV 1 1
vertex  .1 .2  0 UV 1 0
vertex -.1 .2  0 UV 0 0

texturemodes foreshorten
surface 1 0 0
texture rw-face mask rw-face!

quad 1 2 3 4

clumpend
modelend



A cube has eight corners, so naturally the easiest way to make a cube model is with 8 vertices. However, if you do that, then you won’t be able to put a different texture on each side of the cube, because each side (quad) will share its vertices with four other quads, and whichever direction you choose to map the texture in, four of the sides are going to be aligned the wrong way. The solution is to make the cube so that each side has its own 4 vertices, even though there will then be 3 vertices at each corner of the cube, that have the same coordinates (but different UV data).
rw-cube3.rwx

modelbegin
clumpbegin

addhint editable

vertex  0.0600 -0.0600  0.0600  uv 1.0000 1.0000 # 1
vertex  0.0600  0.0600  0.0600  uv 1.0000 0.0000 # 2
vertex -0.0600  0.0600  0.0600  uv 0.0000 0.0000 # 3
vertex -0.0600 -0.0600  0.0600  uv 0.0000 1.0000 # 4
vertex -0.0600 -0.0600 -0.0600  uv 1.0000 1.0000 # 5
vertex -0.0600  0.0600 -0.0600  uv 1.0000 0.0000 # 6
vertex  0.0600  0.0600 -0.0600  uv 0.0000 0.0000 # 7
vertex  0.0600 -0.0600 -0.0600  uv 0.0000 1.0000 # 8
vertex -0.0600 -0.0600  0.0600  uv 1.0000 1.0000 # 9
vertex -0.0600  0.0600  0.0600  uv 1.0000 0.0000 # 10
vertex -0.0600  0.0600 -0.0600  uv 0.0000 0.0000 # 11
vertex -0.0600 -0.0600 -0.0600  uv 0.0000 1.0000 # 12
vertex  0.0600 -0.0600 -0.0600  uv 1.0000 1.0000 # 13
vertex  0.0600  0.0600 -0.0600  uv 1.0000 0.0000 # 14
vertex  0.0600  0.0600  0.0600  uv 0.0000 0.0000 # 15
vertex  0.0600 -0.0600  0.0600  uv 0.0000 1.0000 # 16
vertex -0.0600  0.0600 -0.0600  uv 0.0000 0.0000 # 17
vertex -0.0600  0.0600  0.0600  uv 0.0000 1.0000 # 18
vertex  0.0600  0.0600  0.0600  uv 1.0000 1.0000 # 19
vertex  0.0600  0.0600 -0.0600  uv 1.0000 0.0000 # 20
vertex -0.0600 -0.0600 -0.0600  uv 0.0000 1.0000 # 21
vertex  0.0600 -0.0600 -0.0600  uv 1.0000 1.0000 # 22
vertex  0.0600 -0.0600  0.0600  uv 1.0000 0.0000 # 23
vertex -0.0600 -0.0600  0.0600  uv 0.0000 0.0000 # 24

surface .7 .2 0
texturemode lit foreshorten

texture rw-front
quad 1 2 3 4

texture rw-back
quad 5 6 7 8

texture rw-left
quad 9 10 11 12

texture rw-right
quad 13 14 15 16

texture rw-top
quad 17 18 19 20

texture rw-botom
quad 21 22 23 24

clumpend
modelend



The following examples show how texture masking can be used to add detail to a basically simple model. We start with an umbrella shape, just a wide cone top and cylinder under it.
rw-palm1.rwx

modelbegin
clumpbegin

surface .5 .5 0
color .4 .3 0

cylinder .4 .01 .008 10

translate 0 .36 0
color .3 .8 .34
cone .04 .2 12
cone .04 -.2 12

clumpend
modelend



After opening and saving the file in RWXMod, we have the following (vertex numbers were also added using FixRWX)...
rw-palm2.rwx

modelbegin
clumpbegin

addhint editable

rotate 0 0 1 10

vertex  0.0100  0.0000  0.0000  # 1
vertex  0.0080  0.4000  0.0000  # 2
vertex  0.0080  0.0000 -0.0058  # 3
vertex  0.0064  0.4000 -0.0047  # 4
vertex  0.0030  0.0000 -0.0095  # 5
vertex  0.0024  0.4000 -0.0076  # 6
vertex -0.0030  0.0000 -0.0095  # 7
vertex -0.0024  0.4000 -0.0076  # 8
vertex -0.0080  0.0000 -0.0058  # 9
vertex -0.0064  0.4000 -0.0047  # 10
vertex -0.0100  0.0000  0.0000  # 11
vertex -0.0080  0.4000  0.0000  # 12
vertex -0.0080  0.0000  0.0058  # 13
vertex -0.0064  0.4000  0.0046  # 14
vertex -0.0030  0.0000  0.0095  # 15
vertex -0.0024  0.4000  0.0075  # 16
vertex  0.0030  0.0000  0.0094  # 17
vertex  0.0024  0.4000  0.0075  # 18
vertex  0.0080  0.0000  0.0058  # 19
vertex  0.0064  0.4000  0.0046  # 20
vertex  0.0000  0.4000  0.0000  # 21
vertex  0.2000  0.3600  0.0000  # 22
vertex  0.1732  0.3600 -0.1000  # 23
vertex  0.0999  0.3600 -0.1732  # 24
vertex  0.0000  0.3600 -0.2000  # 25
vertex -0.1000  0.3600 -0.1732  # 26
vertex -0.1732  0.3600 -0.0999  # 27
vertex -0.2000  0.3600  0.0000  # 28
vertex -0.1732  0.3600  0.1000  # 29
vertex -0.0999  0.3600  0.1732  # 30
vertex  0.0000  0.3600  0.2000  # 31
vertex  0.1000  0.3600  0.1731  # 32
vertex  0.1732  0.3600  0.0999  # 33
vertex  0.0000  0.4000  0.0000  # 34
vertex -0.2000  0.3600  0.0000  # 35
vertex -0.1732  0.3600 -0.1000  # 36
vertex -0.0999  0.3600 -0.1732  # 37
vertex  0.0000  0.3600 -0.2000  # 38
vertex  0.1000  0.3600 -0.1732  # 39
vertex  0.1732  0.3600 -0.0999  # 40
vertex  0.2000  0.3600  0.0000  # 41
vertex  0.1732  0.3600  0.1000  # 42
vertex  0.0999  0.3600  0.1732  # 43
vertex  0.0000  0.3600  0.2000  # 44
vertex -0.1000  0.3600  0.1731  # 45
vertex -0.1732  0.3600  0.0999  # 46

color 0.281250 0.796875 0.312500
ambient 0.500000
diffuse 0.500000
triangle 21 22 23
triangle 21 23 24
triangle 21 24 25
triangle 21 25 26
triangle 21 26 27
triangle 21 27 28
triangle 21 28 29
triangle 21 29 30
triangle 21 30 31
triangle 21 31 32
triangle 21 32 33
triangle 21 33 22
triangle 34 35 36
triangle 34 36 37
triangle 34 37 38
triangle 34 38 39
triangle 34 39 40
triangle 34 40 41
triangle 34 41 42
triangle 34 42 43
triangle 34 43 44
triangle 34 44 45
triangle 34 45 46
triangle 34 46 35

# (we can see from the color command that the cone-shaped top ends here)

color 0.375000 0.296875 0.000000
quad 19 1 2 20
quad 17 19 20 18
quad 15 17 18 16
quad 13 15 16 14
quad 11 13 14 12
quad 9 11 12 10
quad 7 9 10 8
quad 5 7 8 6
quad 3 5 6 4
quad 1 3 4 2

clumpend
modelend



Now we add texture. UV data is added to the cone-shaped top using Texmap.  First we place the “#texbegin” and “#texend” lines before and after the vertices belonging to the cone top, to tell Texmap to only add UV’s to those vertices. Then we run Texmap on the file with “fronds” in the “named section” box and using Top-to-Bottom mapping. Finally we add the “texture” command to the RWX file, specifying the frond and mask bitmaps.


pfrond1.jpg                  pfrond1m.bmp

(Note that the texture bitmap must be a .jpg and the mask must be a 2-color .bmp file. The mask image here is actually a .jpg only because web pages don’t support embedded .bmp’s.)

rw-palm3.rwx

modelbegin
clumpbegin

addhint editable

rotate 0 0 1 10

vertex  0.0100  0.0000  0.0000  # 1
vertex  0.0080  0.4000  0.0000  # 2
vertex  0.0080  0.0000 -0.0058  # 3
vertex  0.0064  0.4000 -0.0047  # 4
vertex  0.0030  0.0000 -0.0095  # 5
vertex  0.0024  0.4000 -0.0076  # 6
vertex -0.0030  0.0000 -0.0095  # 7
vertex -0.0024  0.4000 -0.0076  # 8
vertex -0.0080  0.0000 -0.0058  # 9
vertex -0.0064  0.4000 -0.0047  # 10
vertex -0.0100  0.0000  0.0000  # 11
vertex -0.0080  0.4000  0.0000  # 12
vertex -0.0080  0.0000  0.0058  # 13
vertex -0.0064  0.4000  0.0046  # 14
vertex -0.0030  0.0000  0.0095  # 15
vertex -0.0024  0.4000  0.0075  # 16
vertex  0.0030  0.0000  0.0094  # 17
vertex  0.0024  0.4000  0.0075  # 18
vertex  0.0080  0.0000  0.0058  # 19
vertex  0.0064  0.4000  0.0046  # 20

#texbegin fronds
vertex  0.0000  0.4000  0.0000 UV  0.5000  0.5000  # 21
vertex  0.2000  0.3600  0.0000 UV  1.0000  0.5000  # 22
vertex  0.1732  0.3600 -0.1000 UV  0.9330  0.2500  # 23
vertex  0.0999  0.3600 -0.1732 UV  0.7497  0.0670  # 24
vertex  0.0000  0.3600 -0.2000 UV  0.5000  0.0000  # 25
vertex -0.1000  0.3600 -0.1732 UV  0.2500  0.0670  # 26
vertex -0.1732  0.3600 -0.0999 UV  0.0670  0.2503  # 27
vertex -0.2000  0.3600  0.0000 UV  0.0000  0.5000  # 28
vertex -0.1732  0.3600  0.1000 UV  0.0670  0.7500  # 29
vertex -0.0999  0.3600  0.1732 UV  0.2503  0.9330  # 30
vertex  0.0000  0.3600  0.2000 UV  0.5000  1.0000  # 31
vertex  0.1000  0.3600  0.1731 UV  0.7500  0.9327  # 32
vertex  0.1732  0.3600  0.0999 UV  0.9330  0.7497  # 33
vertex  0.0000  0.4000  0.0000 UV  0.5000  0.5000  # 34
vertex -0.2000  0.3600  0.0000 UV  0.0000  0.5000  # 35
vertex -0.1732  0.3600 -0.1000 UV  0.0670  0.2500  # 36
vertex -0.0999  0.3600 -0.1732 UV  0.2503  0.0670  # 37
vertex  0.0000  0.3600 -0.2000 UV  0.5000  0.0000  # 38
vertex  0.1000  0.3600 -0.1732 UV  0.7500  0.0670  # 39
vertex  0.1732  0.3600 -0.0999 UV  0.9330  0.2503  # 40
vertex  0.2000  0.3600  0.0000 UV  1.0000  0.5000  # 41
vertex  0.1732  0.3600  0.1000 UV  0.9330  0.7500  # 42
vertex  0.0999  0.3600  0.1732 UV  0.7497  0.9330  # 43
vertex  0.0000  0.3600  0.2000 UV  0.5000  1.0000  # 44
vertex -0.1000  0.3600  0.1731 UV  0.2500  0.9327  # 45
vertex -0.1732  0.3600  0.0999 UV  0.0670  0.7497  # 46
#texend

color .3 .8 .3
surface .5 .5 0
lightsampling vertex
texturemode lit foreshorten
texture pfrond1 mask pfrond1m # texture and mask
triangle 21 22 23
triangle 21 23 24
triangle 21 24 25
triangle 21 25 26
triangle 21 26 27
triangle 21 27 28
triangle 21 28 29
triangle 21 29 30
triangle 21 30 31
triangle 21 31 32
triangle 21 32 33
triangle 21 33 22
triangle 34 35 36
triangle 34 36 37
triangle 34 37 38
triangle 34 38 39
triangle 34 39 40
triangle 34 40 41
triangle 34 41 42
triangle 34 42 43
triangle 34 43 44
triangle 34 44 45
triangle 34 45 46
triangle 34 46 35

texture null # turn texture off again for the "trunk"
color .38 .3 0
quad 19 1 2 20
quad 17 19 20 18
quad 15 17 18 16
quad 13 15 16 14
quad 11 13 14 12
quad 9 11 12 10
quad 7 9 10 8
quad 5 7 8 6
quad 3 5 6 4
quad 1 3 4 2

clumpend
modelend


 More Examples