Graphics.RockScattering - lordmundi/wikidoctest GitHub Wiki

Rock Scattering

This tool allows you to scatter rocks across the surface of some planet (mainly the moon). This adds realism and 3-dimensional depth to the scene. Below is a before and after screenshot of a site in the Aitken Basin.

Download

  • rocktool_1.0.zip (07/11/2013) - zip file of everything needed
  • rocktool_1.01.zip (08/02/2013)
    • fixes a bug that caused the "Save Config File" feature to generate an "invalid command" error when the Save button was clicked
  • rocktool_1.02.zip (03/18/2014)
    • added in missing rock textures

Installation

  1. Download rocktool_xx.zip and unzip in a convenient location.

  2. Put rock_scatter.tcl in ${USERDATA}/gui, and rock_cfg_generator.py in ${USERDATA}/configs

  3. Unzip rock_models.zip into your ${USERDATA}/models directory.

  4. Unzip rock_textures.zip into your ${USERDATA}/textures directory.

  5. Generate your rock config files (see below).

  6. Edit your "${USERDATA}/user.cfg" file to include the Tcl script and rock configuration files, as shown. (Generating the configuration files is described below. The names will change depending on how you do that).

    DSP_CONFIG { POSTLOAD { "${USERDATA}/configs/user_models.cfg"

         # These files are generated with rock_cfg_generator.py
         "${USERDATA}/configs/rocks_batch1.cfg"
         "${USERDATA}/configs/rocks_batch2.cfg"
         …
    }
    
    DOUG
    {
        # Add or remove elements here that are included with DOUG
        # regardless of display context.  This is a good place for
        # standard menus that provide basic functionality and are not
        # simulation or facility specific
        GUI
        {
                rock_scatter    "${USERDATA}/gui/rock_scatter.tcl"
        } 
    
        command_line
        {
    

    … …

  7. This step will probably be necessary if you are going to load more than about 350 rocks in total. If you are getting an error when you start EDGE that looks like: "plugin(dsp_speedtest3) : Geom data of 219MB exceeds current 'max_geom_buffer_size' of 200MB", then you have more rocks than the program can fit into memory and it will run very slow. To fix this, you will have to override the max_geom_buffer_size parameter and make it bigger. In your main EDGE directory, open the file called edge_settings.cfg. Find the line that starts with DOUG_SPEEDY_ARGS, copy it, and paste it into your user.cfg file in the DEFINES block. At the end of the long argument list, add the option "-max_geom_buffer_size 300". The number has to be bigger than whatever number was printed in the error statement, but 300 should be good enough unless you have a very large number of rocks. So your updated user.cfg file should look like the following:

    DSP_CONFIG { …

    DEFINES
    {
         …
    
         DOUG_SPEEDY_ARGS "-sun PLANET2_SUN . . . -max_geom_buffer_size 300"
    }
    

    … …

How to use

  1. Generate the rock configuration files. The provided python script will automatically generate .cfg files that contain the rocks. You may make multiple "batches", each with their own file. This will allow you to place different batches separately when running the program. For example, you might want to make Small, Medium, and Large batches, so that you can scatter them independently. Or, if it doesn't matter, you can just make one batch and all rocks will be intermixed. To use the program, follow these steps:
    • Change your directory to ${USERDATA}/configs. You should have the rock_cfg_generator.py file here.
    • Run the program with "python ./rock_cfg_generator.py".
    • Then simply follow the directions on the screen. For each batch, you will be asked to input the following parameters:
      1. Batch ID: this is a unique identifier for this batch. It must consist only of letters, numbers, and underscores.
      2. Minimum scale factor: This controls how the rocks are sized. For each rock, the program generates a random scale factor that scales the model. The rock models are generally around 1–2 inches in diameter, so a scale factor of 100 for example will give pretty good size boulders.
      3. Maximum scale factor: the maximum scale factor for the rocks.
      4. Distribution factor (optional): A number between βˆ’1 and 1 that controls how the rock sizes are distributed within your specified range. 0 (default) will give a uniform distribution, negative numbers give more small rocks, and postive numbers give more big rocks (for example, you might want a lot of small-medium rocks, with just a few big boulders. Then you would use a negative number).
    • Below is an example of running the program to make 1 batch. The histogram gives a rough idea on how the program distributed the sizes. You can run the program as many times as necessary to get distributions that you are happy with. Note that the program saves the files as rocks_{batch_id}.cfg. If you enter a batch ID that has already been used, that file will be overwritten.
    • Make sure to take the file names printed at the end of the program and put them in the correct location of your user.cfg file (see Installation section).

Number of batches to generate: 1

Batch 1:
Enter a unique batch ID (e.g. 'small'): testbatch
Number of rocks to generate: 100
Minimum scale value (1.0 will give rock sizes of ~1–2 in.): 1
Maximum scale value (>= min scale): 100
Distribution factor (between βˆ’1 and 1. Hit enter for default): βˆ’0.3
Distribution of rock sizes:

[1.00,10.90): **********************
    [10.90,20.80): ********************************************
    [20.80,30.70): ************************************************
    [30.70,40.60): **********************
    [40.60,50.50): **********************
    [50.50,60.40): ****************
    [60.40,70.30): ******
    [70.30,80.20): ************
    [80.20,90.10): ******
   [90.10,100.00): **

Add the following files to the DSP_CONFIG/POSTLOAD block of your user.cfg file:
/users/bmarsh/dev/edge/userdata.rocks/configs/rocks_testbatch.cfg

  1. Start EDGE. Make sure you set the $USERDATA environment variable to whatever directory you used for the previous steps. There should be a 'Rock Scattering' item in the Options menu.
  2. Place a node where you want your rocks to be scattered. This step is very important, as it is the only way that you can specify to the program where you want your rocks to be centered. The following steps can be taken to do this in an easy way:
    • Use the keyboard controls to fly the camera to the desired location. It does not have to be directly on the surface of the planet, just above where you want the rocks to be centered.
    • From the Edit Nodes window, pick the node that you want to place (this can always be hidden later, so don't worry if you don't actually want it in your scene).
    • Set the parent to whatever camera you are using (this is CM_Cam by default when EDGE loads).
    • Set the (x,y,z) coordinates to (0,0,0).
    • Change the parent again to something else (like MOON). Now you should be able to fly your camera around and the node should be in the desired location. In the screenshot below this has been done with the node CEV_crew_left, at a region on the moon.

  1. Open 'Rock Scattering' from the Options menu and set the parameters. Below is a description of each item in the window:
    • Planet dropdown box - The planet you are placing the rocks on. Choose from the list or type in your own if it is not there.
    • Node textbox - This should be the name of the node you placed in Step 3.
    • Calculate button - This simply displays the position of the node relative to the planet for reference purposes.
    • Batch selector - If you did Step 1 correctly, this should be a list of each of the batch IDs you created. Use this to select the batch you currently want to scatter.
    • 'Number of rocks' slider - Pretty self explanatory. The maximum allowed value will update itself as you place rocks.
    • Scatter radius box - Also pretty self explanatory. This is the maximum distance from the node that rocks can be placed (in inches).
    • Spread slider - This controls how the distances from the central node are distributed. The default value of 0.5 will scatter the rocks uniformly throughout the circle. Smaller numbers will tend to put more rocks near the center, while larger numbers will leave the center relatively clear of rocks and distribute them further away.
    • Used rocks indicator - Shows how many rocks you have used and the total number available, both for the currently selected batch and overall.
    • Scatter - Uses your chosen parameters to scatter rocks around the node.
    • Commit Rocks - Saves the current rock configuration to memory. After clicking the only way to get rid of committed rocks is to Clear every rock from the screen. This button will update the Used rocks indicator, and the maximum value of the number slider will change accordingly. You must click this if you are switching to a new batch and you want to keep what you have.
    • Clear Rocks - Clears every rock from the screen, and sets your used rock counter to 0.
    • Save Config File - Allows you to save a configuration file of the current state so that you can reload the same rock configuration later (described more below).

  1. Scatter, scatter, scatter! Scatter rocks as many times as you wish, until you get a layout that you're happy with. Each time you hit Scatter, any uncommitted rocks will be erased from the screen to be used again. So, if you just want to add more on top of what you already have, make sure you hit Commit! You may also change parameters after clicking Commit to get different groups of rocks to do different things (you can even place multiple nodes, or move the previous one, to get various clusters with different centers). For example, you might want to scatter some small rocks over a large region, and then cluster some big boulders in a smaller area around your node of interest. If you want multiple clusters a nice trick is to scatter a few rocks over a large area and then use the rock nodes themselves as the centers (to find out the node name, Right click→"Pick a model to edit" and hover your mouse over the desired rock). Below is a screenshot of the same site as above, but this time with rocks:

  1. Save the configuration to a .cfg file (optional). Do this if you want to save the current rock configuration for use at a later time. Click the Save button, and you will be prompted to Commit the current state if you have not done so already. Then, choose a new file to save to. You can also optionally change the cutoff sizes for the LOD (level of detail) parameters. When you are done with all this, click Create and a .cfg file will be generated that can be placed in your user.cfg file. Doing this will load the exact same rock configuration in another instance of EDGE. Note that the positions of other non-rock nodes (like the one you placed) will not be saved, so if you want to save those you will have to do that separately.