Creating many static models on terrain

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
afgho
Posts: 14
Joined: 2012-06-12, 13:08

Creating many static models on terrain

Post by afgho » 2012-07-12, 15:56

Hello,

i am looking at creating many static models on a terrain (grass, trees, rocks) however i don't know where to start.

How can i get a specific terrain in the map from the code? This is mainly to access the method GetHeightData so i can place models based on height data.

How do i create a static model from the code (non animated)? (similar to creating entities?)

Also, is the vegetation system usable? If yes then how? I see many screenshots of it.

Not related but i have another question, can someone edit map/scripts files on client side so as to cheat? Is there any protections for that?
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: Creating many static models on terrain

Post by Carsten » 2012-07-12, 21:51

Hello afgho,
afgho wrote:i am looking at creating many static models on a terrain (grass, trees, rocks) however i don't know where to start.

How can i get a specific terrain in the map from the code? This is mainly to access the method GetHeightData so i can place models based on height data.

How do i create a static model from the code (non animated)? (similar to creating entities?)
With "the code", are you referring to CaWE (the map editor) or to Cafu (the engine)?

Do I understand you right that you want to place static models programmatically?
(Something like a spraycan tool comes to mind, that "sprays" static detail models...)

The by far easiest way to place many static detail models is via copy and paste: If you paste them in "batches", it should be possible to place many of them with little work.
Also, is the vegetation system usable? If yes then how? I see many screenshots of it.
Unfortunately, not yet.
The code is there (the screenshots were made from it), but it's not yet integrated in a useful manner.
This is the subject of ticket #10, to which I also have a bunch of notes on my desk (will add them to the ticket soon). Vegetation support is very important to me, but currently I have more pressing issues to complete.

Once the support for vegetation/trees/plants is in place, the next step is to enhance CaWE to allow the creation of many plants easily and quickly ("trees spraycan"). (Of course it could be used with other static objects as well.)
Not related but i have another question, can someone edit map/scripts files on client side so as to cheat? Is there any protections for that?
Inherently, yes:
We use a client-server networking model, and thus the (map on the) server is authoritative.
This alone makes cheating very difficult, I cannot see a way to cheat by having the client use a specially prepared map in place of the original one.

On the other hand, this alone won't make cheating impossible. It's well possible that we'll need some extra defenses in the future. Note however that this seems to be a broad topic that is near impossible to fix totally: even most or all of the commercial titles seem unable to stop it completely.
Best regards,
Carsten
afgho
Posts: 14
Joined: 2012-06-12, 13:08

Re: Creating many static models on terrain

Post by afgho » 2012-07-12, 23:06

With "the code", are you referring to CaWE (the map editor) or to Cafu (the engine)?

Do I understand you right that you want to place static models programmatically?
(Something like a spraycan tool comes to mind, that "sprays" static detail models...)
I was referring to Cafu, what i want to do precisely is to load some kind of "vegetation map" that i can paint easily over the heightmap in a paint program then use it to place plants/rocks on the terrain algorithmically, pixels would determine the density of plants/trees/rocks to spawn but i don't get how i can create static models in Cafu and how to get the terrain height data to place them correctly (using MapTerrainT::GetHeightData i presume but how to get the terrain object of the actual map?).

Using CaWe would be a pain even using copy&paste, there will be plenty rocks/trees.
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: Creating many static models on terrain

Post by Carsten » 2012-07-14, 10:37

afgho wrote:I was referring to Cafu, what i want to do precisely is to load some kind of "vegetation map" that i can paint easily over the heightmap in a paint program then use it to place plants/rocks on the terrain algorithmically, pixels would determine the density of plants/trees/rocks to spawn but i don't get how i can create static models in Cafu and how to get the terrain height data to place them correctly (using MapTerrainT::GetHeightData i presume but how to get the terrain object of the actual map?).

Using CaWe would be a pain even using copy&paste, there will be plenty rocks/trees.
Unfortunately, this is not (yet) easily possible:
I assume that the models that you want to create can be "static", that is, not entities that would be capable of "thinking", individual reference, and subject to network synchronization.

For this kind of models, we have "ModelDef" map primitives. As with "PlantDef"s, these primitives are known to CaWE, but not yet well supported: I'm not even sure at the moment if you can plant them via the normal Map Editors user interface.

However, "ModelDef"s are the right of map primitives to accomplish what you're looking for, but while it would be possible to create them in Cafu directly, you rather have to modify the map loader in CaBSP, procedurally adding "ModelDef" instances when the map is loaded.

Inserting them this early in the map, i.e. before it is compiled, is necessary because also these primitives must be inserted in the BSP tree and other data structures properly. Doing this in Cafu as an afterthought would be a pain, inserting them before CaBSP begins processing them map will automatically take care of them.

CaBSP loads the map in the first couple of lines of the LoadWorld() function:

Code: Select all

        MapFileReadHeader(TP);

        while (!TP.IsAtEOF())
        {
            MFEntityList.PushBack(MapFileEntityT(MFEntityList.Size(), TP));
        }
The relevant data structures are defined in the MapFile.* files in Libs/.
Best regards,
Carsten
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest