GPWiki.org
GPWiki.org
It is currently Wed May 22, 2013 6:36 pm

All times are UTC




Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: DX Playing with D3D
PostPosted: Thu Feb 26, 2009 6:49 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
Although I can produce 3D graphics already using custom manipulation of coordinate data and picture files, my routines in VB6 run extremely slowly. So I've began these past couple of days looking at D3D.

But I'm having some trouble with all the definitions, and what must be enabled or called in the pipeline to make it draw something.

I've looked at some demos/tutorials but it hasn't really helped me. I'm just overwhelmed with all the random lines 'this line does xyz' and I have no idea what that means, or what it is.

What I'd like to do is this:

for n=1 to number_of_triangles
* I'll choose myself some 3d coordinates to define a triangle
* I'll choose a texture bitmap I want that triangle to be drawn with.
* I'll specify the three 2d coordinates for how the corners of the triangle relate to points in the texture bitmap.
next n

for m=1 to number_of_lights
* add a directional light vector to the scene. (If I add no lights then I should see nothing, and if there is only one light, then anything on the opposite side of an object to the light vector should be black)
next m

* define the camera position, the viewing vector, and the viewing frustrum

* draw scene


Can somebody help me get started with this, please.

I'd like my first 3d picture to be a surface plot of a math function, like water droplet ripples. I'm happy generating triangles for that, but I don't know how to set up DX and feed this data into DX. I'd also like to see it illuminated properly as described and not just a silhouette of flat texture.

Thanks for any help. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2009 6:00 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
so nobody knows :(


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2009 6:59 pm 
Technomaniac
User avatar

Joined: Mon Aug 23, 2004 12:24 am
Posts: 3096
Location: Washington , USA
Have you been able to get DX running? I wouldn't try to jump straight into lighting a mathematically generated images :)

I would:
    Get a window up, understand the device.
    Draw a triangle in screen-coordinates (you seem to know the mathematics of the pipeline well, so I assume you know what homogeneous coordinates are and whatnot)
    Set up the projection, viewing, and world matrices to draw your triangle in 3D space.
    Draw your triangles generated from your equation.
    Add lighting.


As you go make everything a class, of course. A device should be wrapped in a class, same with a Mesh, a Camera, a Light.

How far have you gotten?

_________________
GMan
Black Ninja Games
Imagine ASCII art here!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2009 9:33 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
Looking at the tutorials and demos, I don't recognise the lines of code to know that I need them, nor do I really understand what any of the instructions are doing. So all I can do is cut and paste them from demos.

When I try and cut down the content of these demo to remove the demo elements and add my own elements, then I'm guessing at what I'm deleting, and it basically becomes a broken demo.

It feels like I'm trying to speak in chinese by copying the symbols from a leaflet that happens to have chinese symbols on it.

From the coordinates in the program to draw a cube (the gpwiki demo) it looks like triangles are being defined by streaming coordinate triples for the vertices. But then it defines coordinates again, and defines triangles again by referring to that second list, which looks ridiculous.

The lighting functions don't seem to work proper in the demo either. A triangle is either fully illuminated or it isn't illuminated at all; there's no partial illumination from surfaces on a slant to the light source.

3D maths I'm happy and confident with. I know how 3D engines and illumination models work. I can make them. But the speed of VB6 is my nemesis, because it can't do all of that pixel level work in realtime. So D3D. But I'm finding it totally inaccessible. :x

I don't want a hard coded demo that needs a ton of guessed editing to make it do what I want. I don't want an full feature 3D engine like dxice. I don't want to be loading in model files and going down that road either. Nor I don't want meshes. I want to work with just triangles. I just want some straightforward routines as I've described above in my first post.

Even just a compact d3d program to draw a properly illuminated properly textured 3D triangle would be a great start.

(sorry, this is just annoying me)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 01, 2009 6:24 am 
Technomaniac
User avatar

Joined: Mon Aug 23, 2004 12:24 am
Posts: 3096
Location: Washington , USA
No problem :> When I said Mesh I meant triangle-soup btw.

So I guess I'll just propose a more concrete thing to try and see what you need help on.

Is there anything in this articleyou need clarification on?

_________________
GMan
Black Ninja Games
Imagine ASCII art here!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 01, 2009 11:36 am 
Babirusa
User avatar

Joined: Thu Aug 19, 2004 2:55 pm
Posts: 9241
Location: The Netherlands
Maybe this one is interesting, it's a while ago I've checked out the code though:

http://www.persistentrealities.com/getfile.php?id=115 - "Nice lighting demonstration, using Direct3D and math."

_________________
Serious game developer

http://www.persistentrealities.com
http://www.persistentrealities.com/vbfibre
http://www.ambiances.nl


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 01, 2009 2:41 pm 
Digerati

Joined: Fri Sep 24, 2004 3:15 am
Posts: 1791
Location: No longer near Boston, MA
Yeah, this is why I hate using libraries like DirectX (or even OpenGL.) A lot of it just looks like arcane incantations when you first see it :x

_________________
My games webpage: http://www.spacedoutgame.com
My Youtube channel for generally touhou gaming videos, personal projects, and whatever else.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 01, 2009 4:00 pm 
Bibliotherapist
User avatar

Joined: Wed Dec 21, 2005 6:23 pm
Posts: 6210
Location: Manchester, UK
Sadistic Penguin wrote:
Yeah, this is why I hate using libraries like DirectX (or even OpenGL.) A lot of it just looks like arcane incantations when you first see it :x


Do you hate using programming languages for the same reason? :P

_________________
God must love stupid people, he made so many.
theraje: 'God doesn't love stupid people, they're just easier to make'
http://sharedillusions.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 02, 2009 4:12 am 
Digerati

Joined: Fri Sep 24, 2004 3:15 am
Posts: 1791
Location: No longer near Boston, MA
workmad3 wrote:
Sadistic Penguin wrote:
Yeah, this is why I hate using libraries like DirectX (or even OpenGL.) A lot of it just looks like arcane incantations when you first see it :x


Do you hate using programming languages for the same reason? :P


Usually the logic is more obvious in a new language as well as more interesting, where a new library feels more like a necessary evil IMO.

_________________
My games webpage: http://www.spacedoutgame.com
My Youtube channel for generally touhou gaming videos, personal projects, and whatever else.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 02, 2009 10:20 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
:x


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 02, 2009 11:58 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
Success!

My first d3d program.


Image


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 8:52 am 
Technomaniac
User avatar

Joined: Mon Aug 23, 2004 12:24 am
Posts: 3096
Location: Washington , USA
Mine was just a triangle T.T

(nice)

_________________
GMan
Black Ninja Games
Imagine ASCII art here!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 11:47 am 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
Now...

(1) How do I get it to interpolate / antialias the texture?

(2) How do I tell a triangle which bit of a texture to use?

(3) How do I attenuate over distance, so the back of the scene is darker than the front?

(4) As triangles are created as New objects of a triangle class, how do I edit a triangle once it has been "added" to D3D, like if I want to move something in the scene without recreating the whole thing?

(5) How do I interpolate lighting without using a mesh? (Gouroud and/or Phong illumination) I know I must specify normal vectors for the triangle corners but I don't see where they are made.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 12:37 pm 
Bibliotherapist
User avatar

Joined: Wed Dec 21, 2005 6:23 pm
Posts: 6210
Location: Manchester, UK
1) Set a texture filter, or write a shader to perform it on the GPU
2) Set texture coordinates (using a custom vertex format)
3) Use a shader
4) Update the triangle data in the vertex buffer and redraw? (Can't quite remember with DX3d). With 3d, you don't normally worry about redrawing the entire scene though due to the fact that attempting a dirty rects solution in 3d is a lot harder than just pumping out the entire scene again.
5) Use a custom vertex format and probably define a shader :)

Custom vertex formats are described here:
http://www.toymaker.info/Games/html/fvf.html

There's also some stuff about doing it in VB here:
http://www.gamedev.net/reference/articl ... le1308.asp

_________________
God must love stupid people, he made so many.
theraje: 'God doesn't love stupid people, they're just easier to make'
http://sharedillusions.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 07, 2010 10:45 am 
Ankle Nibbler

Joined: Tue Jun 29, 2010 6:41 pm
Posts: 129
Just a suggestion. Wouldn't it be easier to rather use a rendering engine? Such as Ogre 3D? That way you can get OpenGL, DX8 and DX9 to work in your game without rewriting it or changing any code.

It does most of the math for complicated stuff itself, such as importing models, creating a camera etc.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Thu Mar 03, 2011 11:38 pm 
Gamer Geek

Joined: Sat Apr 29, 2006 4:22 am
Posts: 33
Jasmine wrote:
Success!

My first d3d program.


Image


Nice! It could very well be the preamble for a VB 3D game latter on... :)


Top
 Profile  
 
 Post subject: Re: DX Playing with D3D
PostPosted: Tue Mar 08, 2011 11:33 am 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
you noticed that too, huh?

_________________
I ain't pushing no moon buttons.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group