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 / DKShop.dll and frustum culling...

Author
Message
Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 7th Apr 2006 11:05
A while ago LostInThought wrote up a neat little frustum culling system, but it uses a single function from DKShop ( DK Get Matrix4 Element( ClipMatrix, i ) ). Im trying to convert the code to c++, but forgot all about that .dll.

In short, is it possible to call this DK get matrix function from within dark sdk? How would I go about doing it if its possible (im kinda newb to dlls in c++).

Heres Lost's frustum code...



Thanks in advance

All you need is zeal
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 7th Apr 2006 16:11
I never understood why DBP didn't have a way to get the matrix data back anyway. I think they added it just for Shader support not knowing (or caring about) it's potential. Maybe you can use a shader just to extract the data All you need to get is the clipmatrix elements

I know absolutely nothing about shader though.

SET VERTEX SHADER MATRIX

may help.

Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 7th Apr 2006 17:29
Think it would be too ultra crappy if I wrote a frustum culling system that used the 'object visible' command? I could just scale a cube to whatever size then use that... I only used that command once before and I remember it being slow as hell, but wouldnt it be doing the exact same thing your code does?

All you need is zeal
Dmitry K
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Russia
Posted: 7th Apr 2006 19:43
float DK_Vectors_GetMatrixElement( int Matrix, int Element )
{
float res = 0.0;
D3DXMATRIX mat = dbGetMatrix(Matrix);
if (Element>=0 && Element<=15) res = mat[Element];

return res;
}


Specs: P4 2.4GHz, DIMM 256 266Mhz, 60GB HD 7200rpm ATA-133, GeForce NX6600, CD-RW+DVD, WinXP
Zealous
20
Years of Service
User Offline
Joined: 13th Sep 2004
Location: Colorado Springs
Posted: 7th Apr 2006 21:19
ooohhhh thanks will try that tonight!

All you need is zeal
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 8th Apr 2006 06:58
Something else I don't know if you noticed from an edit of mine in my thread. Calling limb position is so slow that if you assign the positions of static limbs to an array before the main loop (program load), my code runs 5 times faster (takes 2ms to run it with array from 10ms with calling commands on 4096 limbs). I don't know about the DGSDK speeds as I still haven't bought it yet lol.

Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 8th Apr 2006 16:14 Edited at: 8th Apr 2006 16:22
@ lost say what now? Youre talking about get limb position?

anyway I got your frustum cull code converted to c++, so please save yourself the time once you start using sdk . However, before you start using it maybe you can help me figure out why it doesnt work lol! I copied it exactly... why wont it work...

Do you see anything wrong?



I ran a test with a cube, and its ALMOST working, but its acting like the bounding box is much larger than it really is. Maybe its some stupid mistake... I need some sleep..

All you need is zeal
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 8th Apr 2006 16:29 Edited at: 8th Apr 2006 17:03
well the DBP multiply matrix functions seem to work backwards. I wonder if DGSDK's are correct. Try swapping this:

dbMultiplyMatrix4(clipMatrix, viewMatrix, projectionMatrix);

to this:

dbMultiplyMatrix4(clipMatrix, projectionMatrix, viewMatrix);

I am quite sleepy myself however and may be wrong. I'll check back after I get some sleep.

[edit]
Quote: "//*** note to self, could optimize this? all done with vectors?"


If sqrt is faster in c++ than vectors are for getting distances then yes.

[edit2] Actually you could optimize it alot I guess. The opposing planes are just inverses of the other. No need to run the distance calc for each I guess. I'll play with this in a few days and probably do quite a bit of optimizing myself. I was so put down by the DBP limb hiding bug (oops I mean optimization or lack there of) that I stopped with it. It is a good bit faster with U6 now though

[edit3] Since you are using c++ this article may help you more than my modded code.

http://crownandcutlass.com/features/technicaldetails/frustum.html

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 10th Apr 2006 15:42 Edited at: 10th Apr 2006 15:45
The only problem I have found with the code (In DBP) is DBP seems to have the matrixs a bit oversized (motly the portion behind the viewing area). I see nothing wrong with your code either 0_o. I made a couple of more posts in my thread and am making a more portable version now. What code are you using to setup the bounding for the cube to test against?

http://forum.thegamecreators.com/?m=forum_view&t=67369&b=6&p=0

Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 11th Apr 2006 03:03
Well dang.. I tryed swapping the matrix multiplication, but it didnt help. All im doing is a simple box...

checker = isBoxInFrustum(0.0f,0.0f,0.0f,1000.0f,1000.0f,1000.0f);

And the results are messed up to say the least. If your back is to the cube, it does return 0, but just about everything else returns a 1.

Anyone else have any ideas as to what could be wrong?

All you need is zeal
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 11th Apr 2006 04:46
Well the frustum is a bit oversized. I noticed this in the DBP code. It's like DBP/ DGSDK offsets the camera differently than where you specify it. Can you compile and exe and send it to me or post it showing what you are getting (with the matrixs swapped back around). I am thinking I may need to offset the frustum as it may not be taking into account the aspect and or fov properly. I'll run some tests. Also note I posted new code in the very bottom of my thread that saves 2 distance checks and 3 matrix4 creations per frustum extraction. I'll buy DGSDK as soon as APEX finishes the .net product more than likely.

Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 11th Apr 2006 15:02 Edited at: 11th Apr 2006 15:04
whipped up a little sample program, hopefully somebody can figure out whats going on. Here is the source...



And here is a compiled exe ------------>

All you need is zeal

Attachments

Login to view attachments
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 11th Apr 2006 15:03 Edited at: 11th Apr 2006 15:31
And I was just about to go to bed too. I'll have a look first lol.

Weird that is exactly how it acts when the matrixs are backwards in DBP. I'll post a code for you to try in a sec. There may be a bug in the matrix commands of DBP.

Try this: change clipRange = 1 to clipRange = 4

[edit] Or your DK Get Matrix4 Element() may be bugged. In any case I'll post the code shortly.

[edit2] Looking over your code I found a bug in mine and corrected my post in the culling thread. When specifying the sizes for box, cube, and sphere culling use radius or half sizes.

Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 11th Apr 2006 15:45
Wow I changed the clipRange to 4 and now the RIGHT plane seems to work (you get accurate results on the right side of the screen). All the other planes are still jacked up.

Heres the new exe ------>

All you need is zeal

Attachments

Login to view attachments
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 11th Apr 2006 16:00 Edited at: 11th Apr 2006 16:05
Try this code and compare with my values. Hold the 1 key down for clip matrix values, 2 for view matrix, and 3 for projection matrix.



Sorry but I am too sleepy to convert it over. And do not move your mouse at all until you check all 3 values. I ran the exe 3 times and hit print screen each.

My values are in the SS attached. You values should be close.

well its 9am here. I'm gonna get some sleep. I'll check back around 2pm

Attachments

Login to view attachments
Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 12th Apr 2006 14:31
Well that dbpro source works fine (although the original dbpro source always worked too). I guess the questions is whats different from my c++ version. Will have a closer look later...

BTW what screenshots? that attachment has my c++ exe

All you need is zeal
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 12th Apr 2006 14:44 Edited at: 12th Apr 2006 15:55
Not here. I just downloaded it. It has the ss in it.

http://forum.thegamecreators.com/xt/xt_apollo_download.php?i=841585

[edit] If it's a cache thing I'll upload it to my site and post a link. Though I am not as sleepy today so I could just post the numbers.

[edit2] The matrix datas were as follows (lets see which one(s) is off in your code):







Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 12th Apr 2006 19:17
Well I saved all my values and printed them out, here are the screens for each matrix. They do look different from yours...

All you need is zeal

Attachments

Login to view attachments
Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 12th Apr 2006 22:12
I decided to jack this guys code...

http://crownandcutlass.com/features/technicaldetails/frustum.html

and im still having problems. Something HAS to be messed up with either the projection or 'view' matrix info darkSDK is spitting out. Other than this part...



I copied the dudes code exactly.

Oddly enough, it DOES work against the right side of the screen. Looks to be 100% accurate... the other sides are messed up good though. Could it be the box in frustum function?...

All you need is zeal
Zeal
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 12th Apr 2006 22:21
roflcopter!!11one!1

looks like it was the box in frustum function all along. not sure whats wrong with it but that guys sphere in frustum and cube in frustum functions work perfectly. ehe

All you need is zeal
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 12th Apr 2006 23:44 Edited at: 13th Apr 2006 00:08
Cool. Looks like your numbers were different because your resolution was different. And your camera was in a different spot compared to my SS's. Did you put all of this in your test code?



I'll have a look at the box in frustum.

[edit] I forgot I was supposed to go to work early today ... gotta run Try this function. My c++ isn't very good so I may be overlooking something obvious in your other code.



Login to post a reply

Server time is: 2024-11-19 06:47:00
Your offset time is: 2024-11-19 06:47:00