home · software · code · tutorials · site map

3578
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
3532
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!
1266
'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.
819
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.
3098
Once You Look, You Can't Look Away (Pic)



Feb
2

GM6 D3D from the Ground Up - Chapter 9

2007 @ 09:34 PM

We're experienced with D3D now. We have a lot of drawing functions at our disposal. Yet it's tedious and practically impossible to draw anything complex by hand with the functions. So we're going to learn the ability to import a 3D model from the 3D suite Anim8or

Create Your Model

We're going to use Anim8or as the medium for getting our 3D content into our games. To do this, you must download my Game Maker 6.1 Export Plugin. After you download it, put it into your Scripts directory for Anim8or. If you don't have any scripts, set the script directory by opening Anim8or, going to the File menu, selecting "Configure", and clicking on the "..." button next to the "Scripts" field. Make sure the 'Preload Scripts' button is checked! From now on, put all scripts into the directory you selected and Anim8or will load them as it starts up.

Convert Your Model

To convert your model, simply go to the Object menu and select "Export" In the Save As dialog, select "Game Maker 6 Model:plug-in (*.d3d)" for the Save As Type. Navigate to your game's directory, type in a filename, and Save it.

Drawing Your Model

To draw your model in Game Maker, use this code.
Create Event:
car = d3d_model_create();
d3d_model_load(car,"car.d3d");
Draw Event:
d3d_model_draw(car,x,y,z,texture);


<< Previous Chapter      Next Chapter >>

Comments (6)
 Del.icio.us  Digg  Furl  Google  Reddit  Slashdot


Feb
2

GM6 D3D from the Ground Up - Chapter 8

2007 @ 06:49 PM

Chapter 8 - Models

Unfortunately, when you start drawing a lot of things in D3D every frame, things can slow down quite a bit. That's where Game Maker comes in with a bandwith saving feature - models.

How To Create a Model

A model is basically a precompiled list of primitives to draw. Rather than executing every drawing command every step, it draws this saved information. Not only that, but you can save the model to a file and load it for future use!
To create a new model, call d3d_model_create(). This function will create a new model resource and return a unique identifying ID. You should use this in conjunction with an assignment expression: gun = d3d_model_create(); for example. When you are done with your model(at the end of the game or any other time), you should free the memory it used by calling d3d_model_destroy(gun);
You can also save and load your model resource. Use d3d_model_load(ID,filename) to load a model. The filename can be anything. It doesn't matter what extension the file uses. As long as it is a saved Game Maker model, it will work. The same applies for the d3d_model_save(ID,filename) function, which saves the model to the specified file.

Composing and Drawing a Model

Every single drawing function we've used up until now also has a version that is made for models. The new function names always follow this naming convention: d3d_model_... where ... is the rest of the function name. All of the vertex and built-in shapes follow this convention and can be used to construct models. They all have one extra argument, too. The first argument is now the index of the model. All of the old arguments follow this one as normal.
To draw the model, call d3d_model_draw(ID,x,y,z,texid). This will draw the model relative to (x,y,z). If you do not want to use a texture, pass -1 as the argument for texid. All transformations discussed earlier will affect the whole model as normal.

<< Previous Chapter      Next Chapter >>

Comments (0)
 Del.icio.us  Digg  Furl  Google  Reddit  Slashdot


Feb
2

GM6 D3D from the Ground Up - Chapter 7

2007 @ 05:41 PM

Chapter 7 - Texture Mapping

What is a Texture?

A texture is simply any image. You apply it to a 3D polygon for a realistic rendering, much more so than basic lighting and colors can depict.

Loading Textures

The best way to organize textures in your Game Maker project is to create a Group under the Backgrounds resource tree named 'Textures.' From there, you can add each individual texture you will use in your game.
There are a few restrictions to the sizes of textures. The dimensions MUST be powers of 2. For example, 64x32, 128x64, etc.

Mapping Textures to Polygons

Now that you have your textures inside Game Maker, we must tell it how to apply the textures to our objects. We do this by specifying a texture coordinate for each vertex of the triangle. This texture coordinate, or texel is a value from 0.0 to 1.0. Texels are in two dimensions - x and y. The x texels go from 0 to 1 from left to right, while the y texels go from 0 to 1 from top to bottom.
texels
To allow a primitive to have a texture, we have to create it with that accessibility. So we now use d3d_primitive_begin_texture(kind, texture_id). kind is the same argument that was used in d3d_primitive_begin. texture_id is the ID of the texture you want to use for this primitive. To get this ID, you can use the function background_get_texture(back) where back is the name of the texture you want.
Now, when specifying a vertex for our textured primitive, we'll call d3d_vertex_texture(x,y,z,xtex,ytex) where xtex and ytex are the x and y texels of our texture map. Please note that you can also use d3d_vertex_normal_texture_color(x,y,z,nx,ny,nz,xtex,ytex,color,alpha) if you want to include all of those characteristics for that vertex.

Texture Filtering

When the texture is mapped onto the polygon, there is a loss of quality as it is stretched and shrunk to fit the vertices. To combat this, filtering is used. By default, Game Maker uses nearest pixel filtering. Nearest-pixel filtering is the simplest and fastest filtering method. However, when the texture is stretched to a large size, it is plagued by large, block pixels.
Linear filtering requires more processing power but it results in a large improvement in quality. Rather than taking a single pixel next to the texel, it averages the surrounding pixels. This results in a fuzzy look when stretched to large sizes. This fuzziness is a better looking artifact than the pixelated look of nearest-pixel filtering, however. You can set this filtering mode by calling texture_set_interpolation(true). You can go back to nearest-pixel filtering with a call to texture_set_interpolation(false).

Texturing Built-In Primitives

Each of the built in basic shapes has three arguments that I have yet to explain: texid, hrepeat, and vrepeat. texid is the ID of the texture, just as it was earlier explained. hrepeat is the amount of times the texture is repeated horizontally along each face. vrepeat is the amount of times the texture is repeated vertically along each face.

<< Previous Chapter      Next Chapter >>

Comments (0)
 Del.icio.us  Digg  Furl  Google  Reddit  Slashdot


<< First < Previous [1 / 4] Next > Last >>

Blogtastic RSS FEED

Linktastic


TysonC's Profile Page