Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Grass, Trees, and Rocks!!!!

Author
Message
NoviceNate333
11
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 24th Feb 2013 08:35
std::cout << "Hello, World!" << endl;

I have a question that i have been trying to figure out for the past couple of days and was wondering if someone on here could possible help me.
I have been trying to place grass on my terrain randomly. I can randomize the x and the z values of the object, but when i assign it to the terrain height it keeps the first value of the first object and all the other 99 objects are at the same height, so all the grass is floating or under the terrain.

Also I have sparkys collision lib, but i cannot figure out how to get the height of an actual terrain.x object. So for now I am using the integrated gdk terrain commands.

Here is my code!!
[img]null[/img]

Attachments

Login to view attachments
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Feb 2013 14:18


You're getting the X and Z coords of the object (using dbObjectPositionX/Z) before actually positioning it.

Do this instead:


"everyone forgets a semi-colon sometimes." - Phaelax
NoviceNate333
11
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 27th Feb 2013 05:02
Wow thank you very much. Now when I Draw the grass the screen it is actually on the ground. I also used the distance formula to find the distance between each bundle of grass,and it only shows the grass that is close to the camera.
I'm drawing 25,000 bundles of grass.

Attachments

Login to view attachments
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 1st Mar 2013 11:55
Just out of curiosity, does it run without annoying slowdowns in as big numbers as 25 000 grass objects?
I seem to recall that you would be better off making ~100 objects with 250 limbs each for this sort of thing. Of course that comes with the problem that you can't instance them or all the limbs Y offsets would be shared.


"Why do programmers get Halloween and Christmas mixed up?"
NoviceNate333
11
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 4th Mar 2013 09:47
The frame rate actually runs at a very decent speed. on windows xp im getting between 30 and 35, and on windows 7/8 I'm getting 45 fps. Since I'm using the distance formula to draw the grass based on where the camera is, at one time only around 100-200 objects are being drawn,but I'm instancing 25,000 grass objects and 1,000 tree objects.
distance code

#include <cmath.h> //in code gen enable /mt setting under runtime lib
int distance;
int xTotal;
int zTotal;
int GetDistance(int Obj)
{
xTotal = pow(dbCameraPositionX()-dbObjectPositionX(Obj),2);
zTotal = pow(dbCameraPositionZ()-dbObjectPositionZ(Obj),2);
distance = sqrt(xTotal+zTotal);
return distance;
}

Then i set up a couple of if statements to show and hide the objects

pysudo code
if object distance < 300 then show the object
if object distance > 300 then hide the object
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Mar 2013 12:41
Hm, I see.

By the way, square root operations are slow, you'd be better off just squaring your range and comparing to that;



"Why do programmers get Halloween and Christmas mixed up?"
NoviceNate333
11
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 31st May 2013 04:53
How do you get the Range data? Is there a range formula?
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 31st May 2013 11:39
Range data...?
Please elaborate


"Why do programmers get Halloween and Christmas mixed up?"
NoviceNate333
11
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 1st Jun 2013 06:02
you said square root operations are too slow that i would be better off squaring range and comparing that. So I have kind of slow frame rate and if that will increase it that would be great

Login to post a reply

Server time is: 2024-11-18 21:53:03
Your offset time is: 2024-11-18 21:53:03