|
Best way to do things ( random grass generator)
#179721
01/24/08 15:55
01/24/08 15:55
|
Joined: Aug 2007
Posts: 286
DestroyTheRunner
OP
Member
|
OP
Member
Joined: Aug 2007
Posts: 286
|
Hi I have a function that generates 500 sprites of a grass image(32bits TGA) in randomly positions over the level. I found out that I needed a bit more than 1000 to cover my level decently. So i made a function that any sprite that is X(eg. 5000) quants farther from the player, gets its invisble flag on.(for speed and rendering improvment) But IF i make a function that maintan a max number of sprites 200(which is enough to fool the vision of the player) and as i walk, it creates and removes sprites using the same distance comparison. Which one do you think is the best? ( speed, memory, rendering...) ps. I´m not using no ones particular generator code and no generator tutorial code(if there is any). thanks 
|
|
|
Re: Best way to do things ( random grass generator
[Re: Joozey]
#179725
01/24/08 17:32
01/24/08 17:32
|
Joined: Aug 2007
Posts: 286
DestroyTheRunner
OP
Member
|
OP
Member
Joined: Aug 2007
Posts: 286
|
ok sorry if i couldnt be a bit clear... 200 grass sprites only apply to the vision of the player. example, the level has to have 1000 grass sprites to cover the land decently, but i need 200 visible. But im getting a problem with it, I´ll explain to you the real thing so you can have a more clear vision of the problem: "Basically im throwing rocks at a castle, and when it hits the castle wall, it disappears and create 10 small rocks with c_move and c_trace running on each of them ( each small rock has 12 faces), then they fall to the ground and some seconds later they disappear and all their functions terminated." NOW the problem, if there is more than ~300 grass sprites in the level EVEN WITH THEIR FLAG INVISIBLE ON, and i throw the rock at the castle, when it creates those 10 small rocks, the FPS drops from 60 to 35/40! until they disappear and it comes back to 60. So the most i could get was 200 grass and the FPS still drops 8 to 10fpss(~52fps) Did you get the Drama?  (my current pc specs is AMD Athlon 1600mhz 256mb ram Video Card GeForce4 but i get the same results in a P4 2.6 512ram video card ATI Radeon 345m 128 shared with the ram memory)
|
|
|
Re: Best way to do things ( random grass generator
[Re: Joozey]
#179727
01/24/08 17:46
01/24/08 17:46
|
Joined: Aug 2007
Posts: 286
DestroyTheRunner
OP
Member
|
OP
Member
Joined: Aug 2007
Posts: 286
|
Quote:
If you create 200 grass sprites around the player at random locations, and you move the player forward, the grass sprites outside the visibility range should be relocated to some new location around the player that just appeared in visibility range. That's the most effective way.
you are right, thats was what i was trying to achieve creating and removing grass entities... but still about the c_move stuff... the rocks has their sprite collision detection OFF already AND they rarely make it to collide with a sprite. And still 200 makes the FPS to drop but its playable, im only affraid when the game get more stuff in its vision or level, whats goind to happen... 
I will try to come up with a code that makes what you said before, have any more thoughts or ideas about the FPS drop and anything else?
thanks
|
|
|
Re: Best way to do things ( random grass generator
[Re: DestroyTheRunner]
#179728
01/24/08 18:21
01/24/08 18:21
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
I don't know actually what causes the fps drop, for 10 small rocks moving with c-move, IMO there shouldn't be a drop of 20fps. You could post a new post with this specific question and give some more details.
Last edited by Joozey; 01/24/08 18:21.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Best way to do things ( random grass generator
[Re: Joozey]
#179729
01/24/08 18:52
01/24/08 18:52
|
Joined: Aug 2007
Posts: 286
DestroyTheRunner
OP
Member
|
OP
Member
Joined: Aug 2007
Posts: 286
|
well yeah.. it does if theres like 500 grass and i create this 10 small rocks i get this drop for some moments and then it gets back to 60. =/ I am in need of one more help from you, to make it like 200 entities and 1 function running, i should not put any while in their initial function. So far I have made this: Code:
var grass_array_x[1000]; var grass_array_y[1000]; var grass_array_index;
function define_grass_pos() { while(grass_array_index < 1000) { grass_array_x[grass_array_index] = random(10000); grass_array_y[grass_array_index] = random(10000); grass_array_index += 1; } }
So I have defined 1000 positions (x,y) inside my level in a random area of 10,000. Now I need to create 200 grasses and move them into 200 player nearest positions of this 1000 total positions. So how am I going to move the grasses between this positions if i cant have a while loop inside their functions? because otherwise it will make 200 running functions. I was trying to find an Entity Array so i could directly move them. but it doesnt seems to have Entity Arrays only Var and string arrays. So am i really going to define 200 ENTITIES MANUALLY? eg. entity* grass1; entity* grass2; ...  ? ps. the reason I pre-defined 1000 postitions randomly only once is because once you loaded the game, and the positions are defined, even if you walk out from an area and the grass is removed from there to fill another position, i wanted to when you go back to that place, the grass is put back in the same place, instead of you walk in the same area 10 times and see the grass in 10 different places everytime you walk in that area. ( it may be stupid, maybe the player wont notice it but i wanted it this way unless i really need to change it)
Last edited by DestroyTheRunner; 01/24/08 18:57.
|
|
|
|