Greenspace, a park or landscape design toy

The “Assignment operator likes and dislikes” thread made me believe that it’s a good idea to use Java/C syntax elements instead of the Pascal ones. On the other hand there is currently an amount of Basic mixed in, since that seemed easier to parse.

Janino looks really interesting. For programmers it sure will be the easiest to just write a class that contains all the code to create a plant.

I feel very uncertain at this point. I want to include non-programmer users too, but the current scripting language is already to complex for that - I’m not sure if people who don’t have a scientfic background can imagine the results of a series of roll/turn/pitch commands for the turtle. I don’t want my own syntax just to have a new syntax, but I wanted to have a higher level syntax which makes plant design easier. I must admit, I failed at this so far.

Findings so far:

  • It was good to refresh my parser design knowledge. I had forgottten too much of it.
  • The script interpreter is a bug-nest and time consuming to debug. It’s a one-time effort though.
  • The script language is too complex for the desired goal.
  • Performance isn’t an issue for the scripts, parsing time to tracing time has a relation of about 1:1000
  • Updating the existing scripts after language changes becomes a pain.
  • Language changes will become additionally difficult once other people made scripts and want compatibility/upgrade paths for their scripts.
  • The raytracer has some elusive bugs which do not show in the plants, but annoy me because I can’t track them down.

On the plus side, it’s the first time that I have a higher level tool to describe and render plant structures. So I think it was worth all the effort. And it seems to have potential.

I am not sure if you if you really locked at xtext.
Basically it given you an eclipse plugin with code completion, Syntax highligting and so far.
That alone is far more beginner friendly.
And you get an abstract ecore meta model which you can transform with the elipse M2M tools like xtend. That can help for upgrading.

No offensive but for me creating a dsl without a tool (xtext) is like parsing xml with string methods.

btw. you should use javafx for your gui its far better than swing. Maybe the canvas node for you renderer.

This is exactly how I did with my L-system(s) :). It works very well.

But it will require the people to set up Eclipse? I don’t know if this is beginner friendly. I haven’t really looked at it, you are right. I was mostly done with my parser and interperter at the time of the suggestion. At least I didn’t expect big enhancements coming or being needed.

Maybe I made a bad decision. But I estimated the time that it takes me to

  • get Eclipse
  • set up Eclipse
  • find out how to install the plugin and install it
  • learn the grammer syntax
  • write a grammer for my langauge
  • create the parser and interpreter
  • integrate that with my project

as bigger than the time to write the interpreter right away. The only thing that needs parsing are arithmetic expressions anyway. As you guessed, everything else is just just string comparison.

I’ve been using lex and yacc (flex and bison) in the past, while I was still C coding, so I have an idea what it means to use a compiler compiler. But it didn’t seem worth it this time. I know it’s not professional. But it was quick and easy enough. And I don’t think I’ll need to create many languages soon, so learning the tools would not have given me knowledge of lasting value - till I have to do it again, the tools are likely out of fashion.

I dunno. I make mistakes too. Maybe this was one. At the moment I’m still somewhat convinced that my decisions were right.

With Swing it’s similar. I have about 10 years experience using Swing, while Javafx is all new to me. I believe that Swing will be good enough for this tool. I have an IDE to create Swing UIs very quickly and I know it well. Learning + using a new toolkit and new tools for a simple editor application and a few buttons? I’m not sure if this will really give better results. Maybe if Javafx has a text pane with syntax highlighting, that is the only bigger task that I see. But I believe that subclassing the text area UI and implementing my own text highlighting will be quick. I haven’t done that yet though, and sometimes Swing components are super-tricky, so there could be bad surprises.

To escape the discussion if it makes sense to use a Java compiler and compile the scritps to bytecode or something like that. I decided for a BASIC like syntax. This particularly means that if and while statements got endif and wend now, instead of {} blocks.

A feature which is missing in the current scripting langauge and which I want to add till the next release is parameter passing to the subroutines.

The raytracer delivers a bit better graphical quality now:

Download

http://www.java-gaming.org/user-generated-content/members/132627/gdsi-plantdesigner-r4.jar

You need to unzip this jar file - it will create a folder named “gdsi-plant-designer-r4”. In this folder you will find two text files, which are the scripts for the plants and the “plant-designer-r4.jar” file, which is an executable jar file. On windows you can run it with a double click from the explorer.

A very brief syntax reference for the scripting language is included in the package (see readme.txt).

The next steps will be to integrate the plant designer into the greenspace simulation. I’ve done the steps manually for the demo plants and took a snapshot of a simple greenspace scene with them.

(right-click -> view image for full size)

Since the plants will be converted to a series of bitmaps when imported to the greenspace simulator, the question of the size of those bitmaps arises.

The park area shown there is 800x600 pixels if it worked as intended. With the shown detail level of plants this appears like a small place, but I like the detail level of the plants.

The map editor can assign individual sizes to plants now. Plants will grow during the year anyways, but now each can have their own individual size variation.

The integration of the plant designer with the map editor needs some more work, though. And many of the existing bitmaps have a low resolution, compared to the plants made by the designer, so I assume I’ll have to do most of them again in a higher resolution.

Looks good. You could allow parameters to your plant building system to animate them changing over seasons. (Leaves can bud, grow, change colors, then fall off. You could have seasonal flowers that regrow the next year as wild hybrids.)

Are you going to use something like that program in the final version or write something else? (Don’t forget that you can use non-realtime rendering.) If you use Java2D I bet you can still fake 3D rendering by treating the images as billboards and only rotating around the vertical axis. Shadows and paths would be different because they would need to be projected on to the ground.

The plant designer link didnt appear for me (404)… Does it have obj (or other) export?

The following link worked for me, if it keeps giving you a 404, you’ll have to wait till the next full release of the project, with the designer included.

http://www.java-gaming.org/user-generated-content/members/132627/gdsi-plantdesigner-r4.jar

The plant designer doesn’t build a mesh internally, but compiles the plant into a series of mathematic formulas which the raytracer can use as input. I’m afraid I can’t offer a mesh export. The current version can export bitmaps of the rendered images, but the demo was just for the show (aka no export included).

Thanks :slight_smile:

[quote=“Best_Username_Ever,post:28,topic:39881”]
I hope that some day the system will be powerful enough to actually do that :slight_smile: Thanks for the ideas!

The plant designer will be included for sure, but I assume there also should be the option to include bitmap based plants and other map elements. Maybe I’ll bundle a simple graphical editor with the project.

I’m fairly undecided to use OpenGL or Java2D so far, and have tried to keep the code open enough that I can decide this some day later. At the moment the display is just bitmaps and Java2D.

I’ve now included two sorts of L-System based trees, one shown in this screenshot. The former photo-postprocessed trees are out, since they didn’t fit to the raytraced plants.

I’ve published a new version of the park designer, also with a new version of the plant designer. The plant designer isn’t very well integrated at the moment though:

http://sourceforge.net/projects/freemapper/files/Greenspace/r4/

Known problems:

  • Plant designer export to the greenspace simulation requires manual steps (aka not functional unless you want to rename and edit files manually)
  • The soils department is subject to a complete redesign
  • The new raytraced plants don’t show a yearly cycle of changes yet
  • The “Green Appelar” tree is misconfigured, better don’t use it.

Hints:

  • Trees are planted small and grow over the time of several ( = 4) simulated years.

Edit:

  • The “Green Appelar” tree is misconfigured, better don’t use it.

I’ve fixed that. If you’ve gotten the original “greenspace_r4.zip” and it seems important enough to you, you can now download the new “greenspace_r4a.zip” with the fix (actually the tree was not only misconfigured, some images were missing altogether):

http://sourceforge.net/projects/freemapper/files/Greenspace/r4/

Beware, the Green Appelar and Dark Bludanga trees can grow rather big over the years.

How are you creating those Images right now?

Are these only images included in your application, which were generated by the raytracer, we saw before?
Why mot make it cool, and let it ray-trace on-the-fly, in the background.
So it reads the script, creates the random tree geometry and finally raytraces it and gives it to the applicaiton, just when you click “generate tree” or something similar…

The trees were made with a script that generates a scene for the PovRay raytracer ( http://www.povray.org )

The greenspace simulation is based on an old map editor code of mine which underwent several reincarnations, but stayed a 2D/bitmap/sprite based application. So behind the scenes it’s all just bitmaps.

Tracing these plants is somewhat time consuming, both with PovRay and my selfmade raytracer. But on modern computers it doesn’t take hours anymore, but less than a minute to generate a plant or tree. With PovRay I have a problem though that it needs several steps to trace the plant, generate a mask, and another pass to generate a ground shadow for it. I haven’t automated this process fully yet. With my own tracer I get the bitmaps in the right format right away, but I must first write some more turtle scripts for plants.

Maybe some day I can render the plants behind the scenes once the player chooses a type, location and view :slight_smile:

At the moment all the images are genrated before a release and stored in the “tiles.tica.zip” archive. You can open that with my tilemaster application:

I think at some day I must bundle tilemaster with the gardening simulation, since that is the only easy way to include new bitmaps which were not made by the plant designer/inbuilt raytracer. Well most of the tilemaster code is already in the last release, so it won’t be a big step.

Edit: The last release of tilemaster has a problem with some of the really big images late in the tileset. You need to set the canvas size to about 1500x1500 pixels to see them. There shouldn’t happen anything bad, though. I fixed the bug in the code meanwhile, but didn’t publish a new tilemaster release yet.

After some struggling with vector math, the raytracer can now build intersection and difference objects from other basic objects (CSG). I bet there are still a lot of bugs lurking, but it was a step forward.

Also, a new plant script, to create snowdrops:

The flower bell needs more detail, but since this is a tiny sort of plant, it shouldn’t matter much. I need to add an interface to the scripting language to set the shinyness of the surfaces, and the amount of ambient light they receive. This way I could make the flower appear softer white.

This all looks very interesting.

Some years ago I was quite hooked on povray.
I once created a script that would generate a randomized building with each and every brick modeled with slightly randomized positioning to make it look natural. It took quite some time to make it even finish without running out of memory… which meant that my idea to render a whole generated city with that never came to be :slight_smile:

Do you have some sort of ‘end-goal’ with this project?

The brick house presumably worked as well as my pine with each needle modeled as a small object. It worked fine till I wanted to place a second pine in a scene, and my PC ran out of memory. PovRay is very interesting for sure, though.

I have a blurry idea to let players develop parks and garden in a loosely collaborative way, share the plants that they’ve created, maybe trade them. Maybe let them work together (via network) on a park. Maybe add more simulation there, e.g. animals. Maybe add game-like elements like challenges, threats (moles, locusts, bad weeds …). Many “maybe” ideas ;D

For trading I’ll need to set up a database somewhere, and an auction-like interface where one can enter offers and bids. I once spent a day or two on this and noticed it’s quite some work. Collaborative editing of a map (via network) will be less work, but I haven’t done anything serious in that direction yet.

At the moment it’s in the stage of creating tools, though. The script-based plant designer, also a small bitmap editor to postprocess the rendered plants, or just create bitmap-based plants and map objects. And finally a better map editor.

I don’t know if this ever will get somewhere. The ideas are very far flung, and the scope that I’ve sketched above is quite big. For the moment it’s fine though to see the plant designer get more versatile and powerful and make simple arrangements of plants with the map editor.

I like povray as well but I found it a bit tricky to use it as a sub-module for rendering things in windows. The runner (at that time) sometimes popped up an annoying dialog box.
I modified the code for it but then it is not ok to distribute it any longer according to the povray license.

A while I had been pondering about using Povray this way, but I didn’t like the idea of having to ship platform dependent binaries with a Java utility. IMO it kills one of the core benefits of java, the ease of installation/running on multiple platforms.

IIRC you can distribute modified Povray executables though, as long as you make clear that they are modified by you, and that the original team is not responsible for support. IIRC there is/has been MegaPov, an extended version of Povray which was distributed, so it should be possible.

Most plants got a yearly lifecycle now. Some snapshots from one year passing:

Brown grass is too brown, makes it hard to see anything. Most real grass just gets yellowish-brown and lighter.