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 / Object Render Distance GDK

Author
Message
DragonsLair
15
Years of Service
User Offline
Joined: 3rd May 2009
Location: Scarborough
Posted: 7th May 2009 13:21
i want objects to only render when they are within a certain distance from the camera. How do I does this in DarkGDK? I am using DirectX 9 if thats any help

I'm new to all this

JRC
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 8th May 2009 03:07
This will only hide the object specified, you will either have to use a for loop to cycle through all your object numbers or manually create hide the object.

Here is the function:


Note: This will hide objects that are further away than the specified distance.

To use this, add this function call before calling dbSync():



Note: You do not have to use a loop to hide your objects, it would technically be more efficient to just call the function I provided for every object you wish to be hidden when it is to far from the camera.

------------------------------------
Currently 1300+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
go2none
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location: London
Posted: 8th May 2009 11:19
Would dbSetCameraRange be effective too, in this case?
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 9th May 2009 17:06
dbSetCameraRange() is better if he wants to hide everything when it's a certain range away, if he wants to hide specific objects ABXG's method is better.

i like orange
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th May 2009 20:35
If you want on/off for the display of your objects then the simple distance test is the way to go, but remember that setting the camera range is a distance test - you'll need to test its performance against the loop that ABXG has suggested to see which is faster.

If you want fade in/fade out then you'll need to also include fog with a far range below the camera cutoff or the distance check.

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 10th May 2009 01:32 Edited at: 10th May 2009 01:32
Quote: "remember that setting the camera range is a distance test"


I thought that setting the camera range was simply a matter of changing the z-near and z-far planes of the projection matrix?

i like orange
DragonsLair
15
Years of Service
User Offline
Joined: 3rd May 2009
Location: Scarborough
Posted: 10th May 2009 18:28
Thanks for all the help. Your right tho I don't wish for anything else but characters and trees to fade out at a certain distance, then buildings but not the terrain.

Whilst we have people here talking, how do I define different variables for characters ie

each character needs to have HP, MP, AP, Inventory etc.

as objects are defined by a number, I was just wondering what the best technique would be to define this.

Thanks for the code above as well, it did the trick. Not as good as Blitz's fade out function but an excellent alternative.

Oh is there a 'fog mode' for the camera as well?

<a href='http://www.dragonslaircommunity.com'>DragonsLairCommunity</a>
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th May 2009 19:03
Quote: "I thought that setting the camera range was simply a matter of changing the z-near and z-far planes of the projection matrix?"

DBPro also uses the near/far camera range to carry out culling at rendering time. Anything that doesn't intersect the view fustrum is culled.

ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 10th May 2009 21:37 Edited at: 10th May 2009 22:15
To get things to fade like you described you could use my method and just define a different distance for different groups of objects.

As far as doing things like HP and the like I would recommend a structure. In the structure would define your variables, you would than also need to an additional variable for each character you have outside of the structure.


EDIT: I screwed up my example code, cold medication is messing with my mind. You can find a decent tutorial for dealing structures via google or the like.

------------------------------------
Currently 1300+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
DragonsLair
15
Years of Service
User Offline
Joined: 3rd May 2009
Location: Scarborough
Posted: 11th May 2009 13:23
iam unot all of my characters in the game are predefined so can this:

stats.maxHP.player = 100 // Players max HP

be used with a variable like:

int player = 1;
stats.maxHP.player = 100 // Players max HP

<a href="http://www.dragonslaircommunity.com">DragonsLairCommunity</a>
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 11th May 2009 19:39
This is a pretty good tutorial for learning structures:

http://www.cplusplus.com/doc/tutorial/structures/

I fixed my code and am now using it in my own project, here is a sample (it's not done yet):

StatsManager.h


StatsManager.cpp


CMI.h


My code has a lot of excess definitions that even I am not using in my project, it's just nice to have the capability to use them for later projects.

Include "StatsManager.h" in your main project. You can than modify data like you would a variable, for example:



I would suggest writing a function that can set up your characters and player, etc. I haven't gotten around to doing this yet.

------------------------------------
Currently 1500+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.

Login to post a reply

Server time is: 2024-11-05 18:40:59
Your offset time is: 2024-11-05 18:40:59