Brief instructions for the RWX preprocessor
BETA & EXPERIMENTAL - HANDLE WITH CARE

WHAT IS IT GOOD FOR?
It enhances the RWX source code with variables and calculation formulas.
Up to 1000 variables can be defined, several operators and functions can be used. The result is (hopefully) an RWX file that can be used in ActiveWorlds based worlds.
download rwp.zip

Current version 1.03 dated 12/18/2001
about 36k download size
DOWNLOAD AND INSTALL
Click the link to the left to download rwp.zip
Copy it anywhere to your HD. Extract / unzip the contents of the ZIP archive (it contains only the rwp.exe file) into any folder on your HD, best into one where your PATH points to.
SETUP
No setup required, but I recommend to define a specific extension to be processed with RWP.EXE, for example *.RWP, so you can just double-click the RWP files in the windows explorer and get an RWX result.
USAGE
The following example should explain the idea and syntax :
Your source model.rwp Preprocessed result model.rwx
  ClumpBegin
$$include model.rwi
$base=0
    Vertex -45 -.03  45 UV  0  0
    Vertex  45 -.03  45 UV 30  0
    Vertex  45 -.03 -45 UV 30 30
    Vertex -45 -.03 -45 UV  0 30
    Quad [$base+1] [$base+2] [$base+3] [$base+4]
$base=$base+4
    Vertex -45 -.33  45 UV  0  0
    Vertex  45 -.33  45 UV 30  0
    Vertex  45 -.33 -45 UV 30 30
    Vertex -45 -.33 -45 UV  0 30
    Quad [$base+1] [$base+2] [$base+3] [$base+4]
$x=45
$y=sin($x)
    Vertex [$x] [$y] 0
    Vertex [asin($y)] [$x] 0
    Color [$red]
    Texture [$tex1]
  ClumpEnd
  ClumpBegin


    Vertex -45 -.03  45 UV  0  0
    Vertex  45 -.03  45 UV 30  0
    Vertex  45 -.03 -45 UV 30 30
    Vertex -45 -.03 -45 UV  0 30
    Quad 1 2 3 4

    Vertex -45 -.33  45 UV  0  0
    Vertex  45 -.33  45 UV 30  0
    Vertex  45 -.33 -45 UV 30 30
    Vertex -45 -.33 -45 UV  0 30
    Quad 5 6 7 8


    Vertex 45 0.707107 0
    Vertex 45.000018 45 0
    Color 1 .3 .3
    Texture stone019
  ClumpEnd
Your include file model.rwi
$red=1 .3 .3
$tex1=stone019
Hints
[1.00] While rwp.exe works, it writes a log file with all problems that occured. If you didn't rename rwp.exe, the log file will be called rwp.LOG
[1.00] rwp.exe accepts wildcards, you can type rwp *.rwp and it will process all files with .rwp extension
[1.03] Instead of letting rwp.exe decide about the result filename, you can specify it in the command line, separated from the source filename with a @ (AT sign). This helps creating series of models from the same template. Example :
rwp -dtex1=stone07 model.rwp@model01.rwx -dtex1=rosa1 model.rwp@model02.rwx
Separator changed from : (colon) to @ (at) in 1.03 (...duh...)
[1.00] All variable assignments have to start with a $ in the first column. They can refer only to previously defined variables
[1.01] Instead of defining the variables in the code, you can set them from the command line : rwp -Dname=value *.rwp
[1.01] Command line variables are valid from the first file behind their definition, that means, that in rwp a.rwp -dblue="0 0 1" b.rwp only the second file knows the variable
[1.01] If a command line variable is modified in a source file, it keeps this modified value in the next file, whereas all variables that are defined inside of a .rwp file are treated as locals and not visible in the next .rwp
[1.01] Include statements have to start with $$ in the first column. Includes can be nested, you can include more files from included files
[1.01] Variables from included files are visible in the file that includes them
[1.01] Included files can contain all the code that RWP files can contain (RWP and RWX commands)
[1.02] Variables can now refer themselves in assignment formulas, a bug sometimes caused problems in the previous version (needed for loops!)
[1.00] The asin() example shows problems with floating point precision, but that should not matter too much, it's just "not so nice" :-/
Float control structures
$$include filename [1.01] pulls lines from an external file into the currently processed source file. These commands can be RWX and/or RWP commands
$$loop together with $$endloop cause a piece of code to be repeated. This loop can only be left with $$break (see below)
$$break should only occur between $$loop and $$endloop. It should depend on a $$if condition (see below). It is the only statement to leave a loop
$$if condition together with $$endif make the code, that stands between them, depend on a condition. This code is only executed if the condition is true

Example for a working loop (staircase generator)
ModelBegin
  ClumpBegin
    Vertex -.02 0  .05
    Vertex -.02 0 -.05

# Modify $x start value to change the number of steps
$x=.1
$y=0
$q=3

$$loop

    Vertex [$x] [$y]      .05
    Vertex [$x] [$y+.02]  .05
    Vertex [$x] [$y]     -.05
    Vertex [$x] [$y+.02] -.05
    Triangle 1 [$q] [$q+1]
    Triangle 2 [$q+3] [$q+2]
    Quad [$q+1] [$q] [$q+2] [$q+3]

$$if $q > 5
    Triangle 1 [$q-3] [$q]
    Triangle 2 [$q+2] [$q-1]
    Quad [$q] [$q-3] [$q-1] [$q+2]
$$endif

$x=$x-.02
$y=$y+.02
$q = $q + 4

$$if $x < 0
$$break
$$endif

$$endloop

    Vertex -.02 [$y]  .05
    Vertex -.02 [$y]  -.05
    Triangle 1 [$q-3] [$q]
    Triangle 2 [$q+1] [$q-1]
    Quad [$q+1] [$q] [$q-3] [$q-1]

  ClumpEnd
ModelEnd

Arithmetic Operators
 + Add
 - Subtract
 * Multiply
 / Divide
 % Divide modulo
 ^ Raise to the power of

Conditional (boolean) Operators for $$if
 < less than
 <= less than or equal
 == equal
 != not equal
 <> not equal (alias of !=)
 >= greater than or equal
 > greater than

Functions
log10(), sqrt(), log2(), asin(), acos(), atan(), log(), exp(), sin(), cos(), tan()

cd / Back to my home
cd .. Back to my ActiveWorlds page
replace (ATNOSPAM)! Report problems to me,
please write only in english or german

Valid HTML 4.0!