Dynamic Tree Solution

Posted By: Olzii

Dynamic Tree Solution - 08/29/05 04:45

Hi all,

I am developing a car game in big city. My city has many map entities and small models. Because of my small models /over 3000 trees, 2000 lights,.../ my FPS is going down and i decided to write scripts for these small objects.

Now my level has only few small objects /50 trees, 30 lights ,.../ and FPS is good.

My solution is to create few models at startup and change their positions to another tree locations if they go out of camera.

I think this solution will help many people who is making outdoor game.

Here is my code : dynamic_tree.rar

1. You have to place all trees at correct position in your level and build it.
2. Include <trees.wdl> to your game.
3. Press F2 to save all tree locations to <trees.ini> file.
4. Delete all trees from your level and build level.
5. call Read_Trees_Ini function in your main function after load level.
6. Run
Posted By: EX Citer

Re: Dynamic Tree Solution - 08/29/05 06:20

Thatīs a good idea. Is the angle and scale saved too?
Posted By: Olzii

Re: Dynamic Tree Solution - 08/29/05 06:32

Yes, you can save angle and type of objects. I saved (x,y,z,pan,type) for city lights. But in this code it does not exist. You can add it easily.

I have choosed random values for tree's pan and scale in this script.
Posted By: mk_1

Re: Dynamic Tree Solution - 08/29/05 10:17

Great idea.
Posted By: lolek

Re: Dynamic Tree Solution - 08/29/05 10:52

Thanks for that usefull script.
A really good idea!
Posted By: Grafton

Re: Dynamic Tree Solution - 08/29/05 15:27

Thanks for sharing this Olzii, nice contribution to the community!
Posted By: Pappenheimer

Re: Dynamic Tree Solution - 08/29/05 16:40

Sounds like a fantastic solution for an important problem! Thanks a lot!
Posted By: Olzii

Re: Dynamic Tree Solution - 08/30/05 02:57

Thanks all,

I am happy to help people.
Posted By: Olzii

Re: Dynamic Tree Solution - 08/30/05 03:04

Thanks bupaje,

Bupaje sent me PM about James has another good idea.

First, I have placed all my trees at my level . After testing i have wrote this script.

James' s idea is not to place all trees to level. It is a BIG job. We can create just TREE_MAP picture that has tree positions. Another Good Idea ! It will save time.
Posted By: Grafton

Re: Dynamic Tree Solution - 08/30/05 23:53

Code:
 
James' s idea is not to place all trees to level. It is a BIG job. We can
create just TREE_MAP picture that has tree positions. Another Good Idea !
It will save time.



That does sound good! Any idea on how it could be done though?
Posted By: Orange Brat

Re: Dynamic Tree Solution - 08/30/05 23:54

This is a cool contribution. I'm aware of James' idea, and yes that would make it even more user friendly.
Posted By: Olzii

Re: Dynamic Tree Solution - 08/31/05 01:48

My idea is to place all trees at level , after we can save it to file. It will take a long time for big level.
==> Instead you can make your level's scaled top picture and draw your tree positions using some small shapes with different colors.

After you can make some functions which will determine tree positions (X,Y) from picture and also you should find Z poistions using TRACE function and write tree's (X,Y,Z) positions to INI file.
Posted By: Nadester

Re: Dynamic Tree Solution - 08/31/05 02:11

Looks cool. How about for multiple levels, with different tree.ini files? And how about security, couldn't someone just edit the tree.ini and mess up the level? Instead, why not leave all the tree models where they are in game, and then store each one's position in an array when the level is loaded, then destroy it. Sure, it might take another second to load, but it'll get rid of those issues I stated.
Posted By: Olzii

Re: Dynamic Tree Solution - 08/31/05 02:26

Hi Nadester,

1. If you have multiple file you can make different INI files and after changing your one level you can open tree_5.INI file for this level.

2. About security, I am using INI files for my cars, trees, lights, traffic lights, traffic rules, task_points, etc ... About security i have made following solution :
- Change your all .INI file's extension to .PAK file
- bind all your .PAK files to your .WRS archive.
- At startup you have to load all your INI files. Then use file_cpy function to extract and copy your .PAK files from .WRS to .INI files.
- After call your READ_INI functions.
- That's it !

If some people want to change your ini files, it has no effect. You will overwrite your ini files from your .WRS at every startup of your game.
Posted By: Nadester

Re: Dynamic Tree Solution - 08/31/05 02:35

That still isn't secure, just hides it a bit better.
Posted By: Olzii

Re: Dynamic Tree Solution - 08/31/05 02:37

Why it is not secur ? You can encode your INI files. It is up to you.
Posted By: Orange Brat

Re: Dynamic Tree Solution - 08/31/05 03:31

I remember Napo's old INI DLL allowed you to read/write to an encrypted INI file.
Posted By: FRAJO

Re: Dynamic Tree Solution - 08/31/05 13:54

I always add a checksum to my files, and if needed also for ini-files, but normally ini files are for changing something, mostly by user, so why make them unchageable? so if you dont want a file to be changed, create your own format.
A dll plugin wouldnt be bad.
Posted By: alpha12

Re: Dynamic Tree Solution - 09/19/05 13:28

link dead?
Code:

Not Found

The requested URL /dynamic_trees.rar was not found on this server.
Apache/2.0.52 (Fedora) Server at wap.starsoft.mn Port 80


Posted By: Why_Do_I_Die

Re: Dynamic Tree Solution - 09/19/05 19:41

Link seems to be down , anyone have this script , in it's original state or altered , sounds like a very good solution to having many entities per level , being limited to a certain amount is unideal for city levels and the like , if anyone has this send me a PM , thnx in advance.
Posted By: Olzii

Re: Dynamic Tree Solution - 09/20/05 00:46

Hi guys,

I have uploaded it again. You can download it now.

Olzii
Posted By: Why_Do_I_Die

Re: Dynamic Tree Solution - 09/20/05 15:28

Thnx Olzii
Posted By: Why_Do_I_Die

Re: Dynamic Tree Solution - 09/20/05 16:24

btw , can anyone who know scripting explain how to add it to multiple levels , or how to save the position and scale of each entity ?
Posted By: Olzii

Re: Dynamic Tree Solution - 09/21/05 03:37

I think that your each level has separate .wmp level file. Using my functions you may write each level's entities to different files :
lvl_1_tree.ini, lvl_2_tree.ini, lvl_3_tree.ini ,...
Posted By: Josh_Arldt

Re: Dynamic Tree Solution - 09/22/05 09:26

Pretty nifty idea Olzii.
This should prove usefull.
Thanks for contributing it.
Posted By: dead_poet

Re: Dynamic Tree Solution - 10/09/05 17:53

a little speed issue...

instead of
Code:
 vec_sub(my.skill4,vector(Trees[TreeArrRows*i],Trees[TreeArrRows*i+1],Trees[TreeArrRows*i+2])); 


you can use
Code:
 vec_sub(my.skill4,Trees[TreeArrRows*i+0]); 


if i am not wrong...
the vector command is very slow, i noticed..
Posted By: Locoweed

Re: Dynamic Tree Solution - 10/23/05 00:10

The link is actually up.

Is there a simple example level with source that anyone has made showing this code working? Someone ask me some questions on how plausible it would be to use in certain situations, but it would be nice to see it in action before I can reply to them.
Posted By: Olzii

Re: Dynamic Tree Solution - 10/24/05 02:42

Hi friend!

Here is my car example : demo

If you want to see how dynamic tree script is working, please run this demo and wait 2 minutes /Until it generates thousands of random tree positions/.

I think my dynamic tree script's link is not dead, may be server was down. You can download it now.

Olzii
Posted By: frozenbaby

Re: Dynamic Tree Solution - 10/24/05 19:03

Ok ... this one I DON'T get - d/l'ed your demo. Loaded it and waited the 2 minutes (actually 5) and didn't see a single entity created? Level was kinda "kewl" (cool) - and the car's reactions were fine - 'cept when I rolled the car and it continued to "play" on it's side.

Guess my question is - what did this have to do with tree creation when I didn't see any dynamic trees created? Or am I missing something?
Posted By: Olzii

Re: Dynamic Tree Solution - 10/25/05 07:03

Hi frozenbaby,

May be you should wait until it generating thousands of random posiitions using trace /3600 tree positions/, you can see counting number for tree positions . After waiting for 5-10 minutes, you should drive around, then you will see these trees.
Posted By: Grafton

Re: Dynamic Tree Solution - 10/25/05 14:03

Hello Olzii, thanks again for sharing your work and ideas! The demo worked fine
for me, but it seems to just generate trees at random locations. This isnt what
the original code does at all, right?

I am trying to make a small level with just a skybox and floor that uses the
code to move 15 trees around to keep them in front of the camera as a demo, but
I am having no luck yet.

The color map idea is great! Anymore ideas on that?
Posted By: Olzii

Re: Dynamic Tree Solution - 10/26/05 01:49

Hello Josiah,

In this example, i am only using 50 trees in 3600 tree positions. I didn't create trees, it will be jerky if i use ent_create everytime.

How are moving your 15 trees ? You can post your code here and ask.

My idea is to create some trees at a pool. Then they will appear at place that you want.
Posted By: Matt_Aufderheide

Re: Dynamic Tree Solution - 02/08/06 11:02

Is this file still available?
Posted By: Olzii

Re: Dynamic Tree Solution - 02/09/06 02:23

No, now my server is down. I am buying a new server.

May be you should ask people who had downloaded it ( for example Josiah) .

Olzii
Posted By: Matt_Aufderheide

Re: Dynamic Tree Solution - 09/24/09 11:53

I know this is an old thread but i am still looking for this script if anyone has it...
Posted By: Pappenheimer

Re: Dynamic Tree Solution - 09/24/09 12:39

http://www.puppenheim.org/trees_o.wdl

I think it is a version, that I didn't change too much.
The script has the drawback that it decreases the frame rate extremely when there is no tree near the player.
Posted By: Matt_Aufderheide

Re: Dynamic Tree Solution - 09/24/09 17:05

thanks!
© 2024 lite-C Forums