home · software · code · tutorials · site map

3664
Congressman warns of current GA- Russia conflict in 2002!!!
Ron Paul in an interview with Jim Lehrer says in 2002 interview that by the US adopting a preemptive first Strike Doctrine would eventually lead to Russia invading GA
3552
Girls Get the Anime Look with Extra-Wide Contact Lenses
Girls in Japanese comics, cartoon videos or anime share a common look - big eyes that, by making the rest of the face look small, add the cuteness and sex appeal prized by many Japanese men. Since no amount of cosmetic surgery will make actual human eyes larger, some girls are trying another way to up their cute quotient: extra-wide contact lenses!
1262
'Everyone Will Remember Me as Some Sort of Monster'
A troubled teenager. An assault rifle. Eight slain in a mall. It was national news for a few days. Then it was forgotten.
822
Repurpose Your Nintendo as a Lunchbox (PICS)
I had a broken NES, a rotary tool, two small hinges, some glue and Alpha Flight's Sasquatch. What I ended up with was a lunchbox that gets all kinds of funny looks.
3104
Once You Look, You Can't Look Away (Pic)



Jan
31

GM6 D3D from the Ground Up - Chapter 1

2007 @ 09:25 PM

Welcome to my new series of tutorials for Game Maker 6.1's Direct3D wrapping. I will explain it and its concepts starting from the ground up - assuming no prior 3D knowledge.

Chapter 1 - Introduction to 3D and D3D

3D is an acronym meaning three-dimensional: an object is being described having three dimensions that can be measured: width, height, and depth.

Illusions

You can't actually view an object in 3D on a computer monitor. However, it can be alluded to via perspective: the illusion of things becoming smaller as the recede into the distance. Perspective is just one element of art that has been employed for years by traditional artists when simulating nature on a two dimensional canvas.

Effects in 3D

Rendering is transcribing the geometric description of a 3D object and representing it on the computer monitor.

Shading and Shadows

This is another trick employed by traditional artists trying to accurately depict nature for a very long time. Difference in color usually denotes a change in surface. A shadow appears on a surface when rays of light are broken before it hits said surface. Therefore, it can only exist in three dimensions. Portrayed accurately in 2D, it can dramatically enhance the 3D quality of the image.

Texture

Only so much can be done with pure shapes shaded with color. When that limit is reached, you can depend upon textures. Textures are real-life images applied to a 3D polygon to increase the detail greatly without having to describe the object with thousands of polygons - which can get very slow.
When you apply this texture to the polygon, you map it. You supply the texture image and a bunch of coordinates on the texture, texels, and the 3D graphics rasterizer will map the textures texels to corresponding vertices of the polygon. After the mapping is done, the texture is usually filtered to minimize the detrimental effects of the stretching and moving done whilst mapping the image.

Blending and Transparency

Blending is the combination of objects on the screen. There are different ways to blend things that are drawn with others in the scene to produce a large array of effects. For example, you can make an object slightly translucent. It will blend in partly with its background, creating the illusion that you can see through it.

Anti-Aliasing

A pixel is the smallest dot that you can draw on the screen. Aliasing is the effect seen when objects appear with "jaggies" - individual pixels contrast with the background and created a jagged border. But when the borders are blended in with the background, it smooths them out. This is called "antialiasing."

3D Graphics Programming in GM

Now that we have covered some of the 3D concepts, we can actually start applying them via Game Maker's Direct3D wrapper.

Direct3D

Direct3D is a proprietary Microsoft 3D graphics library. It is widely deployed and well instituted. Game Maker 6.1 wraps some of its basic functions. Much more could be done with it, but at this point, things are relatively limited.

Coordinate Systems

We have to learn how to do something that has been talked about quite a bit in our 3D concepts introduction - describing a 3D object. Everything must be described in relation to a reference frame. Something you may be familiar with is window coordinates. They are measured in rows and columns of pixels. For example, in a 1024x768, a pixel in the middle would be located at (512, 384). That's a relatively common and well known coordinate system.

Cartesian Coordinates

Again, you should be familiar with this. Throughout your education, you should have graphed things quite a bit in math classes. This was most likely the coordinate system you were using.
Here, the origin is at (0,0). Coordinates are transcribed in (x,y) notation. There exists axes in this system: lines representing dimensions going infinitely in both the positive and negative directions. Where two axes intersect to form right angles, they define a plane, or simply a flat surface.

Coordinate Clipping

We have to describe our window and how D3D shall translate the 3D coordinates to window coordinates. To do this, we define bounds of the Cartesian system to occupy our window. These bounds form the region known as the clipping region. Basically, we're limiting our coordinate system rather than having each axis spanning infinitely.

Vertices

A vertex is simply a point in space. You can think of it as a coordinate pair, triplet, etc. When you draw an object in 3D, it is composed of various primitives. The most simple primitive is the vertex. Constructing geometry from vertices is like connecting the dots. This is how you form polygons.

The 3D Cartesian Coordinate System

We need to extend our familiar 2D coordinate system to include another axis. We are going to append the z-axis onto the already existing x and y axes. As the x-axis goes horizontally and the y-axis vertically, the z-axis stretches infinitely from and toward the viewer. To describe it loosely, the positive z-axis comes out of the monitor while the negative z-axis recedes into the monitor.

Projections: Going from 3D to 2D

How exactly does Direct3D draw these 3D coordinates on our obviously 2D screen? Basically, it uses a lot of trigonometry and matrix operations. Fortunately, we don't have to deal with any of that low-level stuff. We simply define a Projection for Direct3D. It will use our project to project, or flatten, our 3D information onto the 2D screen.

Types of Projections

Orthographic
This is also known as parallel projection. Here, a rectangular viewing volume is defined. Anything outside this volume is simply ignored. No perspective will be used here. Everything will appear the same size. Therefore, we can use this to draw 2D things such as text, images, GUI, etc. onto our 3D game.
Perspective
This is the more common perspective used. It adds perspective to the drawn 3D objects. The viewing volume is no longer rectangular, but is now a frustum. You can visualize the frustum has a camera cone, or a pyramid with a blunt point. Objects further back into the volume a drawn smaller than those closer to the viewer.

<< Previous Chapter       Next Chapter >>


 Del.icio.us  Digg  Furl  Google  Reddit  Slashdot


world of warcraft gold on December 22, 2007 at 3:06 PM

Buy FFXI Gil,cheap ffxi gil,cheapest ffxi gil,Final Fantasy XI Gil sale.We provide cheap eve online isk to reliable customer.Cheap world of warcraft gold for sale,lowest price gold for wow,as low as $19/1000 Gold.eve online isk, EVE ISK, Buy eve online isk, Cheap eve online isk.Buy world of warcraft gold here.EVE Online ISK, EVE ISK, Buy EVE ISK, Cheap EVE ISK. We provide cheap EVE ISK to reliable customer. Lineage 2 Adena ( L2 Adena) is the most valuable form of currency in Lineage 2(L2 Adena). we supply cheap eq2 plat,eq2 platinum and eq2 gold,everquest 2 plat,so you buy cheap eq2 gold,eq2 accounts.

CommentsWrite a comment

:

:

:

Blogtastic RSS FEED

Linktastic


TysonC's Profile Page