Dagger3d! engine

  • (8 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

116 Replies - 10548 Views - Last Post: 18 April 2011 - 03:20 PM

#1 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Dagger3d! engine

Posted 17 June 2008 - 03:31 PM

I've started a separate Sourceforge project for my game engine, Dagger3d! Got an email saying it was approved but I'm still waiting for the site to agree. :P

I've switched to using the BSD license for all future versions. I think it will allow more flexibility with people who want to use Dagger3d! for proprietary games. Making a game is a lot of work, and most games (multiplayer-only games excluded) are "play once and forget" kind of deals. An Open Source application can stick around for years, being improved upon by the original developers and even some of it's more technical users. That said, not many people play through single player games, write patches to improve them, and then immediately go back to play through them again. For that reason I feel that the technology behind games (namely the engine) should if possible be Open Source, but the games themself should not be. Open Source game development (again, excluding multiplayer) just does not seem to work out.

So far I've written every line of code in the engine (roughly 10,000 lines including comments), but I could use a little bit of help coming up with a good collision detection system. Get in touch with me if you're interested. :^:

Is This A Good Question/Topic? 1
  • +

Replies To: Dagger3d! engine

#2 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 23 June 2008 - 12:24 AM

I've started work on a mini game (a 3d clone of Asteroids) using Dagger3d. Dagger3d is far from being finished, but my reasoning is that if I try writing a game with it I will discover it's immediate limitations and fix them. So far I've already caught a couple of bugs, and I've added some things that (for some reason) didn't pop into my mind as useful before.

I'm adding a slightly reduced version of what I've got so far as a "test". Basically it involves loading a mesh, and allowing the "player" to fly it around at a constant speed (because I'm lazy) on the screen.

Here are some screenshots:

Note: That is a low polygon "ship" I made :), I made a texture for it as well but my skill at exporting UV texture coordinates in Blender isn't very high yet, so for now there is the crazy gradiant texture.

Posted Image
The "ship" flying towards from the camera.

Posted Image
The "ship" flying away the camera.

Posted Image
The "ship" with wireframe mode enabled.

Here is the source code for the test. Please note that this isn't necessarily the best way to do this, and the code certainly could be shortened. That said, it is late and I am tired: you do the thinking. :)

Also please note that this won't do you a whole lot of good without the Dagger3d library, which you can either checkout of the subversion server and compile yourself, or you can get from me (if you ask nicely).

/*
 * Copyright © 2008, Tom Arnold
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list 
 *     of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice, this 
 *     list of conditions and the following disclaimer in the documentation and/or other 
 *     materials provided with the distribution.
 * 3. Neither the name of the Dagger3d! Engine nor the names of its contributors 
 *     may be used to endorse or promote products derived from this software without 
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#include <stdlib.h>
#include <stdio.h>
#include <dagger.h>

game_ent_t* domo = NULL;
camera_t* c = NULL;

void update_scene(void)
{
	// Move the ship based upon it's speed & heading.
	phys_vel_update_pos(domo->phys_info.loc, domo->phys_info.dir, -domo->phys_info.speed, 0.001);
}

void keyboard_func(uchar* state)
{
	if (state[_KEY_ESC])
	{
		exit(0);
	}

	if (state[_KEY_W_LC])
	{
		// Toggle wireframe mode.
		wireframe_enabled = !wireframe_enabled;
	}

	if (state[_KEY_RIGHT])
	{
		matrix_t* rot = NULL;
		float yt;
		
		// Rotate the ship's heading.
		rot = matrix_vector_rotate(domo->phys_info.dir, -5.0f, _Y_AXIS);
		matrix_destr(domo->phys_info.dir);
		matrix_vector_normalize(rot);
		domo->phys_info.dir = rot;

		// Rotate the actual mesh.
		yt = point2d_get_rotation(matrix_get(domo->phys_info.dir, 0, 2), 
					  matrix_get(domo->phys_info.dir, 0, 0));
		matrix_set(domo->phys_info.rot, 0, 1, yt);
	}
	
	else if (state[_KEY_LEFT])
	{
		matrix_t* rot = NULL;
		float yt;
		
		// Rotate the ship's heading.
		rot = matrix_vector_rotate(domo->phys_info.dir, 5.0f, _Y_AXIS);
		matrix_destr(domo->phys_info.dir);
		matrix_vector_normalize(rot);
		domo->phys_info.dir = rot;

		// Rotate the actual mesh.
		yt = point2d_get_rotation(matrix_get(domo->phys_info.dir, 0, 2), 
					  matrix_get(domo->phys_info.dir, 0, 0));
		matrix_set(domo->phys_info.rot, 0, 1, yt);
	}

	else if (state[_KEY_UP])
	{
		matrix_t* rot = NULL;
		float xt;

		// Rotate the ship's heading.
		rot = matrix_vector_rotate(domo->phys_info.dir, -5.0f, _X_AXIS);
		matrix_destr(domo->phys_info.dir);
		matrix_vector_normalize(rot);
		domo->phys_info.dir = rot;

		// Rotate the actual mesh.
		xt = point2d_get_rotation(matrix_get(domo->phys_info.dir, 0, 1), 
					  matrix_get(domo->phys_info.dir, 0, 2));
		matrix_set(domo->phys_info.rot, 0, 0, xt);
	}

	else if (state[_KEY_DOWN])
	{
		matrix_t* rot = NULL;
		float xt;
		
		// Rotate the ship's heading.
		rot = matrix_vector_rotate(domo->phys_info.dir, 5.0f, _X_AXIS);
		matrix_destr(domo->phys_info.dir);
		matrix_vector_normalize(rot);
		domo->phys_info.dir = rot;

		// Rotate the actual mesh.
		xt = point2d_get_rotation(matrix_get(domo->phys_info.dir, 0, 1), 
					  matrix_get(domo->phys_info.dir, 0, 2));
		matrix_set(domo->phys_info.rot, 0, 0, xt);
	}
}

int main(int argc, char** argv)
{
	// This must be called right off the bat, for obvious reasons.
	game_engine_init(argc, argv);

	// Set up and add the mesh+entity to the scene.
	{
		dmf_mesh_t* m;
		
		// Load the entity from a file, and set some attributes.
		domo = game_entity_create("data/sabre.xml");
		domo->phys_info.speed = 10.0f;
		matrix_set(domo->phys_info.loc, 0, 2, -5.0f);
		matrix_set(domo->phys_info.loc, 0, 1, -0.25f);
		matrix_set(domo->phys_info.dir, 0, 0, 0.0f);
		matrix_set(domo->phys_info.dir, 0, 1, 0.0f);
		matrix_set(domo->phys_info.dir, 0, 2, 1.0f);
		
		// Load the mesh from a file.
		m = dmf_load_mesh("data/sabre_def.xml");

		// Add both to the world.
		dmf_queue_add(m);
		game_world_add_ent(domo);
	}
	
	// Set up and add the camera.
	{
		c = camera_create();
		camera_add(c );
		camera_set_active(0);

		matrix_set(c->dir, 0, 0, 90.0f);
		matrix_set(c->dir, 0, 1, 180.0f);
	}
	
	// Bind our keyboard and update functions.
	keyb_set_func(&keyboard_func);
	scene_set_update_func(&update_scene);

	// Start rendering.
	graphics_start();

	return EXIT_SUCCESS;
}



There are still a few little glitches to work out (rotating the ship "jumps" a bit at certain angles), but I think it's coming along nicely. :)
Was This Post Helpful? 0
  • +
  • -

#3 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 28 June 2008 - 08:08 PM

Dagger3d is approximately at 12,013 lines of code (as of this moment). That's a lot of code. :)
Was This Post Helpful? 0
  • +
  • -

#4 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 28 June 2008 - 10:25 PM

Another update, the Dagger Mesh Format that I came up with is an XML based format modeled off of ID's old MD2 format.

My XML parser is a little on the slow side, so I'm writing up a script to "compile" DMFs into a new (non-XML) format, dubbed Compiled Dagger Meshs (ie. cdm). :)

Loading times aren't noticeable on faster machines and with lowpoly meshes, but I would like to have this as a backup plan in case I can't speed up my XML parser easily.
Was This Post Helpful? 0
  • +
  • -

#5 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 450
  • Joined: 05-April 08

Re: Dagger3d! engine

Posted 28 June 2008 - 10:32 PM

Actually, I can probably help you out on the Parsing.
http://www.dreaminco...wtopic52533.htm

My benchmarking has giving me a ~16 MB/s transfer rate, on my crappy laptop

I have used it to parse 3D Model files, including .x, .obj (Wavefront object), and several custom models.

My setup:
1.7 GHz Pentium M
1 GB of 333 MHz RAM
Was This Post Helpful? 0
  • +
  • -

#6 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 28 June 2008 - 10:47 PM

View PostCerolobo, on 29 Jun, 2008 - 01:32 AM, said:

Actually, I can probably help you out on the Parsing.
http://www.dreaminco...wtopic52533.htm

My benchmarking has giving me a ~16 MB/s transfer rate, on my crappy laptop

I have used it to parse 3D Model files, including .x, .obj (Wavefront object), and several custom models.

My setup:
1.7 GHz Pentium M
1 GB of 333 MHz RAM

Thanks, I'll look into that. I'm a little hesitant of including 3rd party libraries in my engine though. I started off using libxml2 to parse xml files and man was that a disaster. One of the few benefits of writing everything myself is that everything is easily portable. :^:

What license is your parser under? Because if I were to include it in Dagger3d, it would be easiest if I could distribute a version of it with Dagger3d (dependency hunting is the pits).
Was This Post Helpful? 0
  • +
  • -

#7 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 450
  • Joined: 05-April 08

Re: Dagger3d! engine

Posted 28 June 2008 - 10:53 PM

The parser is portable. I test it on 7 compilers (with max warnings turned on, except for the MS compiler) on Windows, and 2 on Linux. It even runs in a 16bit environment. I haven't tried it on Max OS X, but since it is Unix based, it should work without a hitch.

It is written entirely in ANSI C. If the platform support stdio.h, stdlib.h, and string.h, it will work.

As for the license, personally, I don't really care. Basically, I don't care if it's used in commercial project or not. File that under what ever license you want.

This post has been edited by Cerolobo: 28 June 2008 - 10:58 PM

Was This Post Helpful? 0
  • +
  • -

#8 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 28 June 2008 - 11:10 PM

View PostCerolobo, on 29 Jun, 2008 - 01:53 AM, said:

The parser is portable. I test it on 7 compilers (with max warnings turned on, except for the MS compiler) on Windows, and 2 on Linux. It even runs in a 16bit environment. I haven't tried it on Max OS X, but since it is Unix based, it should work without a hitch.

It is written entirely in ANSI C. If the platform support stdio.h, stdlib.h, and string.h, it will work.

As for the license, personally, I don't really care. Basically, I don't care if it's used in commercial project or not. File that under what ever license you want.

Sounds good. Maybe I'll add it in as a backend, with preprocesser macros to switch it out with my (slow) parser.

If I do use it, I'll keep it isolated from the engine (dynamic linking ftw). If you wanted to write up a copyright file/terms of use/something like that, I would love to include it (I don't think I saw one when I was browsing your source).

Dagger3d is under a BSD license, which basically says that anyone can modify the source code and use it for whatever they want (without having to release the modifications) providing they leave the copyright information intact. :^:
Was This Post Helpful? 0
  • +
  • -

#9 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 450
  • Joined: 05-April 08

Re: Dagger3d! engine

Posted 28 June 2008 - 11:15 PM

Truthfully, I have no desire to write up any terms of use, or other legal document.

I wrote the whole thing, and that's good enough for me.

In any case, if you have a sample model file, I could probably write up a example on how to drive it.
Was This Post Helpful? 0
  • +
  • -

#10 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 28 June 2008 - 11:21 PM

My model format keeps data in 3 files.

Here is the format specification.
-----------------------------------
dmf - Dagger Mesh Format

by Tom Arnold
-----------------------------------

Overview:
	* Data is stored in an XML format.
	* Consists of three XML files and a texture.
	   1) Header file, contains references to the other files, and information
		   like the number of vertices, etc.
	   2) Mesh file, contains frames, vertices, normals, and texture coordinates.
	   3) Animation file, consists of frame indices.
	   4) Texture file, should be a binary uncompressed TGA image.
	* Frames are all stored in the same place, animations are only
	  divided up by start indices.
	* Number of triangles = number of vertices divided by three,
	   therefore it is very important to not have any stray vertices!
	* Number of vertices = number of normals.

Restrictions:
	* You can only load triangles (the dmf_mesh_t type in Dagger3d allows for other
	   formats like QUADS and TRIANGLE STRIPS).
	* No stray vertices (see above).
	* No untextured meshs.
	* Every mesh should have at least one animation. That animation
	  should be a one-frame static version of the mesh. If there are
	  multiple animations, it should be the first.
	* There are no obvious limits for how many frames you can have,
	   or how many vertices/animations (like with MD2 models), but
	   keep in mind that more "stuff" will use more memory, and more
	   cpu time to render.
	* Each mesh is limited to ONE texture (the dmf_mesh_t type in Dagger3d 
	   allows for a lightmap texture, but information regarding that is NOT stored 
	   in the dmf format).
	* Textures MUST be in the TGA format.
	* Each frame MUST have the same number of vertices.
	
Header:
	* Name of the mesh.
	* Mesh filename.
	* Texture filename.
	* Animation filename.
	* Version number.
	* Number of vertices (in a frame).
	* Number of frames.
	* Number of animations.

Other notes:
	* The G3D Blender export script provided with Dagger3d will automatically
	   include all 250 (or so) animation frames. This leads to unnecessarily large
	   filesizes. To avoid this, go to the ANIMATION window in Blender and change
	   "End" to equal however many frames your mesh has.


And here is a link to the documentation for the C data structure that holds mesh information.

Attached is a zipped example model of a tank.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#11 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 29 June 2008 - 12:42 AM

Another update, I've finished my DMF to CDM converter.

The size of JUST the mesh file (that means no definition or animation file) of an example DMF is 19305 bytes. The size of the entire mesh converted to the CDM format is 8531 bytes.

That combined with the bypass of my slow XML/string parser should speed up loading models plenty (it also means smaller model sizes on disk). :)
Was This Post Helpful? 0
  • +
  • -

#12 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 450
  • Joined: 05-April 08

Re: Dagger3d! engine

Posted 29 June 2008 - 05:19 AM

I was able to correctly load the sample files you gave me 1,000 times in
@1.7GHz: 3.3 seconds, 5.74 MB/s
@500MHz: 20 seconds, 0.95 MB/s

The code was compiled with cl *.c /O2

As a side note there are some serious optimizations you can do to your data structures.

I don't know why you choose to do so, but using your matrix_t for coordinates is extremely wasteful, and rather slow.

And another note. In the header section, you declared your version as a unsigned int, yet you have a float in your def file.

Attached File(s)


This post has been edited by Cerolobo: 29 June 2008 - 05:31 AM

Was This Post Helpful? 0
  • +
  • -

#13 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 29 June 2008 - 12:56 PM

View PostCerolobo, on 29 Jun, 2008 - 08:19 AM, said:

As a side note there are some serious optimizations you can do to your data structures.

I don't know why you choose to do so, but using your matrix_t for coordinates is extremely wasteful, and rather slow.

And another note. In the header section, you declared your version as a unsigned int, yet you have a float in your def file.

Nice catch, didn't notice that (the version as a uint). I can be pretty thick-headed sometimes. :^:

I use the matrix_t type mainly for safety. I know it's not the most efficient way of doing things, but it beats memory leaks. Any advice on slimming them down (other than not using them)?

Edit: Ahhh, the matrix_t type has a number of functions associated with it (for getting and setting values within the matrix, and for creating/deleting matrices), which is the main reason I use them. I don't think you used them in your implementation (whether that was intentional or not).

This post has been edited by Tom9729: 29 June 2008 - 01:03 PM

Was This Post Helpful? 0
  • +
  • -

#14 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Dagger3d! engine

Posted 29 June 2008 - 01:08 PM

Mesh Loaded
mesh->head->name   : |Tank|
mesh->head->mesh   : |data/mesh/tank_mesh.xml|
mesh->head->tex	: |data/mesh/white.tga|
mesh->head->anim   : |data/mesh/tank_anim.xml|
mesh->head->ver	: 1
mesh->head->nverts : 132
mesh->head->nframes: 1
mesh->head->nanims : 1

Verticies and Normals
<Type>:<Frame Number>:<Vert/Norm Number>: (<cooridinates>)
Vert:  0:  0: (   0.738,   -1.469,   -0.518)
Norm:		 (  -0.000,   -0.000,   -0.000)
Vert:  0:  1: (   0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:  2: (   1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:  3: (   1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:  4: (   0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:  5: (   0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:  6: (  -1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:  7: (  -0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:  8: (  -0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:  9: (  -0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 10: (  -1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 11: (  -0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 12: (   1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 13: (   0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 14: (   0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 15: (   1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 16: (   0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 17: (   1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 18: (  -1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 19: (  -1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 20: (  -0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 21: (  -1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 22: (  -0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 23: (  -0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 24: (  -0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 25: (  -0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 26: (  -1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 27: (   0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 28: (   1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 29: (   0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 30: (   0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 31: (   0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 32: (  -0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 33: (   0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 34: (  -0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 35: (  -0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 36: (  -0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 37: (  -1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 38: (  -0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 39: (   0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 40: (   0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 41: (   1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 42: (  -0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 43: (  -0.150,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 44: (  -0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 45: (   0.149,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 46: (   0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 47: (   0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 48: (  -0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 49: (  -0.151,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 50: (  -0.150,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 51: (  -0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 52: (  -0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 53: (  -0.151,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 54: (   0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 55: (   0.149,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 56: (   0.147,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 57: (   0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 58: (   0.147,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 59: (   0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 60: (  -0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 61: (   0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 62: (   0.147,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 63: (  -0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 64: (   0.147,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 65: (  -0.151,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 66: (   0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 67: (  -0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 68: (   0.149,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 69: (  -0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 70: (  -0.150,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 71: (   0.149,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 72: (   0.149,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 73: (  -0.150,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 74: (  -0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 75: (   0.149,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 76: (  -0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 77: (   0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 78: (   0.122,	1.897,	0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 79: (  -0.128,	1.897,	0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 80: (  -0.151,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 81: (   0.122,	1.897,	0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 82: (  -0.151,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 83: (   0.147,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 84: (  -0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 85: (  -0.128,	1.897,	0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 86: (   0.122,	1.897,	0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 87: (  -0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 88: (   0.122,	1.897,	0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 89: (   0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 90: (  -0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 91: (  -0.150,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 92: (  -0.151,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 93: (  -0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 94: (  -0.151,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 95: (  -0.128,	1.897,	0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 96: (   0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 97: (   0.122,	1.897,	0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 98: (   0.147,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0: 99: (   0.125,	1.836,	0.314)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:100: (   0.147,   -0.421,	0.477)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:101: (   0.149,   -0.457,	0.355)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:102: (   1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:103: (   1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:104: (   0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:105: (   1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:106: (   0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:107: (   0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:108: (  -1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:109: (  -0.500,   -1.592,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:110: (  -0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:111: (  -1.000,   -1.592,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:112: (  -0.500,   -0.151,	0.178)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:113: (  -1.000,   -0.151,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:114: (   0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:115: (   0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:116: (  -0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:117: (   0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:118: (  -0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:119: (  -0.736,	1.377,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:120: (   0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:121: (   0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:122: (  -0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:123: (   0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:124: (  -0.855,   -1.897,   -0.158)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:125: (  -0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:126: (   0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:127: (   0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:128: (  -0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:129: (   0.738,	0.949,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:130: (  -0.738,   -1.469,   -0.518)
Norm:		 (   0.000,	0.000,	0.000)
Vert:  0:131: (  -0.738,	0.949,   -0.518)
Norm:		 (  -0.738,	0.949,   -0.518)

Texture Coords
Texture Coords:  0: (   0.257,	0.565)
Texture Coords:  1: (   0.257,	0.381)
Texture Coords:  2: (   0.290,	0.575)
Texture Coords:  3: (   0.290,	0.575)
Texture Coords:  4: (   0.272,	0.598)
Texture Coords:  5: (   0.257,	0.565)
Texture Coords:  6: (   0.040,	0.575)
Texture Coords:  7: (   0.072,	0.381)
Texture Coords:  8: (   0.072,	0.565)
Texture Coords:  9: (   0.058,	0.598)
Texture Coords: 10: (   0.040,	0.575)
Texture Coords: 11: (   0.072,	0.565)
Texture Coords: 12: (   0.290,	0.465)
Texture Coords: 13: (   0.257,	0.381)
Texture Coords: 14: (   0.257,	0.348)
Texture Coords: 15: (   0.290,	0.575)
Texture Coords: 16: (   0.257,	0.381)
Texture Coords: 17: (   0.290,	0.465)
Texture Coords: 18: (   0.040,	0.575)
Texture Coords: 19: (   0.040,	0.465)
Texture Coords: 20: (   0.072,	0.381)
Texture Coords: 21: (   0.040,	0.465)
Texture Coords: 22: (   0.073,	0.348)
Texture Coords: 23: (   0.072,	0.381)
Texture Coords: 24: (   0.047,	0.750)
Texture Coords: 25: (   0.091,	0.770)
Texture Coords: 26: (   0.029,	0.770)
Texture Coords: 27: (   0.260,	0.750)
Texture Coords: 28: (   0.279,	0.770)
Texture Coords: 29: (   0.216,	0.770)
Texture Coords: 30: (   0.260,	0.750)
Texture Coords: 31: (   0.216,	0.770)
Texture Coords: 32: (   0.091,	0.770)
Texture Coords: 33: (   0.260,	0.750)
Texture Coords: 34: (   0.091,	0.770)
Texture Coords: 35: (   0.047,	0.750)
Texture Coords: 36: (   0.062,	0.966)
Texture Coords: 37: (   0.029,	0.865)
Texture Coords: 38: (   0.091,	0.865)
Texture Coords: 39: (   0.246,	0.966)
Texture Coords: 40: (   0.216,	0.865)
Texture Coords: 41: (   0.279,	0.865)
Texture Coords: 42: (   0.760,	0.925)
Texture Coords: 43: (   0.701,	0.960)
Texture Coords: 44: (   0.800,	0.858)
Texture Coords: 45: (   0.650,	0.960)
Texture Coords: 46: (   0.591,	0.925)
Texture Coords: 47: (   0.550,	0.858)
Texture Coords: 48: (   0.646,	0.286)
Texture Coords: 49: (   0.559,	0.345)
Texture Coords: 50: (   0.559,	0.321)
Texture Coords: 51: (   0.091,	0.865)
Texture Coords: 52: (   0.091,	0.770)
Texture Coords: 53: (   0.135,	0.847)
Texture Coords: 54: (   0.396,	0.286)
Texture Coords: 55: (   0.484,	0.321)
Texture Coords: 56: (   0.484,	0.345)
Texture Coords: 57: (   0.216,	0.865)
Texture Coords: 58: (   0.172,	0.847)
Texture Coords: 59: (   0.216,	0.770)
Texture Coords: 60: (   0.091,	0.770)
Texture Coords: 61: (   0.216,	0.770)
Texture Coords: 62: (   0.172,	0.847)
Texture Coords: 63: (   0.091,	0.770)
Texture Coords: 64: (   0.172,	0.847)
Texture Coords: 65: (   0.135,	0.847)
Texture Coords: 66: (   0.550,	0.858)
Texture Coords: 67: (   0.800,	0.858)
Texture Coords: 68: (   0.650,	0.960)
Texture Coords: 69: (   0.800,	0.858)
Texture Coords: 70: (   0.701,	0.960)
Texture Coords: 71: (   0.650,	0.960)
Texture Coords: 72: (   0.043,	0.242)
Texture Coords: 73: (   0.043,	0.031)
Texture Coords: 74: (   0.293,	0.056)
Texture Coords: 75: (   0.043,	0.242)
Texture Coords: 76: (   0.293,	0.056)
Texture Coords: 77: (   0.293,	0.233)
Texture Coords: 78: (   0.356,	0.965)
Texture Coords: 79: (   0.325,	0.965)
Texture Coords: 80: (   0.322,	0.812)
Texture Coords: 81: (   0.356,	0.965)
Texture Coords: 82: (   0.322,	0.812)
Texture Coords: 83: (   0.359,	0.812)
Texture Coords: 84: (   0.552,	0.313)
Texture Coords: 85: (   0.553,	0.353)
Texture Coords: 86: (   0.490,	0.353)
Texture Coords: 87: (   0.552,	0.313)
Texture Coords: 88: (   0.490,	0.353)
Texture Coords: 89: (   0.490,	0.313)
Texture Coords: 90: (   0.405,	0.437)
Texture Coords: 91: (   0.649,	0.445)
Texture Coords: 92: (   0.645,	0.469)
Texture Coords: 93: (   0.405,	0.437)
Texture Coords: 94: (   0.645,	0.469)
Texture Coords: 95: (   0.399,	0.478)
Texture Coords: 96: (   0.655,	0.570)
Texture Coords: 97: (   0.662,	0.611)
Texture Coords: 98: (   0.416,	0.603)
Texture Coords: 99: (   0.655,	0.570)
Texture Coords:100: (   0.416,	0.603)
Texture Coords:101: (   0.412,	0.579)
Texture Coords:102: (   0.279,	0.770)
Texture Coords:103: (   0.279,	0.865)
Texture Coords:104: (   0.216,	0.770)
Texture Coords:105: (   0.279,	0.865)
Texture Coords:106: (   0.216,	0.865)
Texture Coords:107: (   0.216,	0.770)
Texture Coords:108: (   0.029,	0.770)
Texture Coords:109: (   0.091,	0.770)
Texture Coords:110: (   0.091,	0.865)
Texture Coords:111: (   0.029,	0.770)
Texture Coords:112: (   0.091,	0.865)
Texture Coords:113: (   0.029,	0.865)
Texture Coords:114: (   0.257,	0.348)
Texture Coords:115: (   0.257,	0.381)
Texture Coords:116: (   0.073,	0.348)
Texture Coords:117: (   0.257,	0.381)
Texture Coords:118: (   0.072,	0.381)
Texture Coords:119: (   0.073,	0.348)
Texture Coords:120: (   0.257,	0.565)
Texture Coords:121: (   0.272,	0.598)
Texture Coords:122: (   0.058,	0.598)
Texture Coords:123: (   0.257,	0.565)
Texture Coords:124: (   0.058,	0.598)
Texture Coords:125: (   0.072,	0.565)
Texture Coords:126: (   0.257,	0.381)
Texture Coords:127: (   0.257,	0.565)
Texture Coords:128: (   0.072,	0.565)
Texture Coords:129: (   0.257,	0.381)
Texture Coords:130: (   0.072,	0.565)
Texture Coords:131: (   0.072,	0.381)

Animations
Ani:  0:  Start:   0  End:   0



Pretty slick! :^:
Was This Post Helpful? 0
  • +
  • -

#15 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 450
  • Joined: 05-April 08

Re: Dagger3d! engine

Posted 29 June 2008 - 01:31 PM

Personally, I can't help but recommend you avoid them. Just for some basic coordinates, the matrix_t uses 5 pointers. All of those can be reduced to just one. To me, it is far easier to deal with just one pointer. Plus, you will benefit from things like Locality of Reference, since all the memory will be next to each other (IE, far faster), and less function calls (malloc() and free()).

You can wrap all of your coords in a built in data type.

typedef float (*Coord)[3]; /* Pointer to a array of 3 floats */

Coord verts = (Coord)malloc(sizeof(Coord) * 100); /* 100 - Number of Verts */

verts[58][1] = 7.0f; /* Access the 59th vert, and set the y value to 7 */


The above only uses 1 pointer. So, to clean up the memory, you just call free(verts);

You can do the exact same thing for your texture and normal coords.

typedef float (*Coord)[3];			/*  Pointer to a array of 3 floats	  */
typedef float (*TextCoord)[2];		/* Pointer to a array of 2 floats	   */
typedef unsigned int (*AnimRange)[2]; /* Pointer to a array of 2 ints		 */

typedef struct
{
  Coord* verts;
  Coord* norms;
} dmf_frame_t;

typedef struct
{
  dmf_header_t  head;	   /* There really isn't a point to allocating this  */
  TextCoord	*tex_coords;
  dmf_frame_t  *frames;	 /* You really only need one pointer here		  */
  AnimRange	*anim_r;
  unsigned int  tex_id;
} dmf_mesh_t;


The reduction in derefrencing alone will provide a nice performance boost, plus I find that a lot easier to work with. Not to mention you can take advantage of some OpenGL optimizations (Part of OpenGL 1.1, which is supported by pretty much everything).

glVertexPointer() - Can read the Coord struct. IE, you only have to pass one pointer to OpenGL.

This is far faster then calling glVertex3f() or what ever variant. And yes, there are functions to pass in texture coords and normals as well.

Edit: Cleaned up the alignment.

This post has been edited by Cerolobo: 29 June 2008 - 01:40 PM

Was This Post Helpful? 1
  • +
  • -

  • (8 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »