gam3b00bs / src / renderer / mres.h

#pragma once
//
// mres.h - mesh resource data layouts
//
//

#include "shared/types.h"
#include "shared/offptr.h"

namespace mres
{
	enum
	{
		MF_SKINNED = 1,

		MESH_NAME_LEN = 64,
	};

	/////////////////////////////////////////////////////////////////////////////
	// Vertex formats:
	// Instead of going with a completely customizable vertex declaration
	// we instead use a simpler layout mechanism. 

	enum{ 
		VT_UNUSED,  // tells that this vertex element is not used
		VT_FLOAT1,
		VT_FLOAT2, 
		VT_FLOAT3, 
		VT_FLOAT4, 
		VT_COLOR,

		VT__MAXCNT,
	};

	// describes a single vertex element
	struct vxelement_desc
	{
		uint8 offset;  // vertex element offset
		uint8 type;    // vertex element type, one of VT_xxx
	};

	const vxelement_desc VXELEMENT_UNUSED = {0,0};

	// describes vertex structure
	struct vlayout_desc
	{
		vxelement_desc position;
		vxelement_desc normal;
		vxelement_desc tex0;
		vxelement_desc tex1;
		vxelement_desc color;
	};

	// directory entries:
	const char* const FNM_MESH = "mhead";
	const char* const FNM_BLOB = "mblob";
	
	typedef uint16 ib_index_t;

	struct subset
	{
		uint32        base_vertex_index;
		uint32        start_vertex;
		uint32        num_verts;
		uint32        start_index;
		uint32        num_primitives;
		uint32        matid;
		uint32        used_bones;  // not used
		uint32        padding[1];
	};

	struct mesh_header
	{
		uint32             byte_size;
		uint32             flags;      // a combination of MF_xxxx flags
		uint32             nsubsets;
		uint32             vb_size;
		uint32             ib_size;
		uint32             vdecl_size;
		uint32             stride; // * (see below)
		char               dbgname[ MESH_NAME_LEN ];
		off_ptr< subset >  subsets;
	};
	// (*) - vertex stride for skinned meshes is given as sizeof( hw_vertex ), rather than sizeof( skin_vertex ),
	//       because this stride is passed into device->SetStreamSource(), so beware
	//      

	struct mesh_blob
	{
		uint32                    byte_size;
		off_ptr< char >           vb;
		off_ptr< char >           ib;
		off_ptr< vlayout_desc >   vl;
	};

}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.