Subject:
|
Re: terrain in LDraw
|
Newsgroups:
|
lugnet.cad.dev
|
Date:
|
Fri, 10 Aug 2001 13:46:06 GMT
|
Viewed:
|
637 times
|
| |
 | |
Jaco:
> Could you give some example command lines please?
pgm_to_ldraw -colour 2 -height 30 < terrain.pgm >
terrain.dat
(or were you asking for a bit more than that?)
Lets try to make a 32 by 32 knob 30 plates high relatively
soft all-green landscape:
fractal_landscape -width 32 -height 32 -h 0.95 -z_max 30
> terrain.pgm
pgm_to_ldraw -colour 2 -height 30 < terrain.pgm >
terrain.dat
ldglite-run -s0.5 terrain.dat
If we want to colour the landscape above as a beach, we
either have to make a copy of "terrain.pgm" which we edit by
hand, or we have to do something like the following rather
ugly piece of Perl+command interpreter:
pnmdepth 9 < terrain.pgm | pnmnoraw | perl -pe
's/^9$/382/' | perl -pe 's/(^| )[012]( |$)/ blue /g' | perl
-pe 's/(^| )[34]( |$)/ sand /g' | perl -pe 's/(^| )[56789](
|$)/ green /g' | perl -pe 's/(^| )[012]( |$)/ blue /g' |
perl -pe 's/(^| )[34]( |$)/ sand /g' | perl -pe 's/(^|
)[56789]( |$)/ green /g' | perl -pe 's/blue/1/g' | perl -pe
's/sand/382/g' | perl -pe 's/green/2/g' >
terrain-colour_map.pgm
(all on one line) The file "terrain-colour_map.pgm" now
contains LDraw colour numbers for blue, sand and green
depending on the height of that part of the terrain. We can
use this to make a "colour-mapped" terrain model:
pgm_to_ldraw -map terrain-colour_map.pgm -height 30 <
terrain.pgm > terrain.dat
ldglite-run -s0.5 terrain.dat
If we then want to fix the water level, we can do that too:
echo "P2\n1 1\n30\n8" | pnmscale -width 32 -height 32 >
terrain-water_level.pgm
pnmarith -maximum terrain-water_level.pgm terrain.pgm |
pnmnoraw > terrain-level_water.pgm
pgm_to_ldraw -map terrain-colour_map.pgm -height 30 <
terrain-level_water.pgm > terrain.dat
ldglite-run -s0.5 terrain.dat
Jacob
PS: This example has been tested on a Linux system and
depends on various other programs, which are not
included in my fractal landscape generator package.
--
"It is very easy to get ridiculously confused about the
tenses of time travel, but most things can be resolved
by a sufficiently large ego."
|
|
Message has 1 Reply:  | | Re: terrain in LDraw
|
| I wrote: [...] (...) [...] A slightly cleaned up version of this example can be found in the updated source distribution of my fractal landscape generator. Play well, Jacob -- (URL) (24 years ago, 10-Aug-01, to lugnet.cad.dev)
|
Message is in Reply To:
23 Messages in This Thread:         
         
       
               
         
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|