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 / Quick Direct3D DrawPrimitive Question

Author
Message
Coldfire
16
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 4th Mar 2011 05:01 Edited at: 4th Mar 2011 05:11
I am trying to create a object-less triangle function--textured preferably, but for now i just want to get a triangle to render properly. The function works but is not relative to the camera. I thought perhaps adding the camera position to each of the vertex would work, but it acts as though it is still relative to the screen instead of the camera.

Here is a listing of the function:


Thanks in advance.

Edit: I have actually noticed that no matter the coordinates of vertices, the triangle stays the same. Maybe I should look into a tutorial instead of trying to understand it through the SDK docs.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 4th Mar 2011 08:47 Edited at: 4th Mar 2011 08:49
this triangle is in local space, read about transformations here: (this is a very good site) http://www.toymaker.info/Games/html/matrices.html

Coldfire
16
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 4th Mar 2011 12:42 Edited at: 4th Mar 2011 13:25
Thanks for the info and the link! Looks much easier to read than the SDK docs, lol.

Edit: I gave it a read through, and it is very good! One thing I am curious of though, is there a way to access the dbp view matrix? Or should I just use gdk commands to retrieve camera position and rotation and then convert to radians?

Thanks for your help!
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 4th Mar 2011 15:00
Try these commands:



Coldfire
16
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 4th Mar 2011 18:51
That's just what I was hoping for! Thank you both!
Coldfire
16
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 5th Mar 2011 03:49 Edited at: 5th Mar 2011 03:53
Well, I've been toying around with this, but I am still having the same issues. I'm sure I'm doing this completely wrong, but I thought I was on the right track.

I create the projection matrix at initialization, using dbGetProjectionMatrix(0) (i assume the int is the camera), then I set the transform to the projection matrix-also at initialization.

And as for the guts of the triangle function:

I create an empty world matrix and leave it alone. Since my triangle creation command is draw globally in the world matrix, I figured that should be left alone. I could be wrong. After that I set the transform to the world matrix--every frame.

Then, I create the view matrix using dbGetViewMatrix(0) (also assuming the int is camera). Afterwords, I set the transform to the view matrix--also every frame.

I guess I was kinda hoping that was the way it worked, but I was obviously wrong. Here is a listing of my header for further examination:



I hate to ask, but if someone has some free time, could you possibly show a small example of using direct3d to draw a triangle to a gdk camera? My goal is to be able to display triangles without objects as quickly as possible.

Edit: cleaned up code a bit.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 5th Mar 2011 04:23
You aren't binding your vertex buffer anywhere, so it can't draw your triangle. Try following THIS tutorial.

Login to post a reply

Server time is: 2024-11-19 12:35:17
Your offset time is: 2024-11-19 12:35:17