Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Tools

Archive::Tools Archive area for Tools's posts that were moved here after an inactivity period of 90 days.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #14  
Old 08-13-2004, 03:02 PM
sandy
Hill Giant
 
Join Date: Oct 2002
Posts: 212
Default

to render it seems close to opengl except I have to create a vertex buffer for each texture group of polygons instead of creating a model

here's the code :

Code:
	// build the vertex buffers corresponding to each mesh

	ppVBs = new LPDIRECT3DVERTEXBUFFER9 * [meshes.GetSize()];

	for ( i=0; i<meshes.GetSize(); i++ )
	{
		Data36* mesh = meshes.GetAt(i);

		// precalculate the scale of the mesh
		float scale = (float)(1<<mesh->Scale);

		// builds the vertex buffers

		ppVBs[i] = new LPDIRECT3DVERTEXBUFFER9 [ mesh->PolygonTexCount ];

		int polygoncount = 0;

		for ( j=0; j<mesh->PolygonTexCount; j++ )
		{
			int nbvertex = mesh->PolygonTexEntries[j][0] * 3;

			if( FAILED ( pd3dDevice->CreateVertexBuffer( 
							nbvertex * sizeof ( MODELVERTEX ), 
							D3DUSAGE_WRITEONLY, D3DFVF_MODELVERTEX,
							D3DPOOL_DEFAULT, &ppVBs[i][j] , NULL ) ) )
				return E_FAIL;

			MODELVERTEX * pVertex;
			ppVBs[i][j]->Lock( 0, 0, ( void * * ) & pVertex , 0 );

			for ( k=0; k<mesh->PolygonTexEntries[j][0]; k++ )
			{
				for ( int numvertex=1; numvertex<=3; numvertex++ )
				{
				
					int vertexindex = mesh->PolygonEntries[polygoncount][numvertex];

					// get the unajusted vertices
					float x = mesh->CenterX + mesh->VertexEntries[vertexindex][0]/scale;
					float y = mesh->CenterY + mesh->VertexEntries[vertexindex][1]/scale;
					float z = mesh->CenterZ + mesh->VertexEntries[vertexindex][2]/scale;

					// get the index of the piece that contains this vertex
					int pieceindex = GetPieceIndex( mesh, vertexindex );

					// rotate the unajusted vertices
					RotateX( pieces[pieceindex].XAng, x, y, z );
					RotateY( pieces[pieceindex].YAng, x, y, z );
					RotateZ( pieces[pieceindex].ZAng, x, y, z );


					// add the position of the piece
					pVertex->x = x + pieces[pieceindex].XOfs;
					pVertex->y = y + pieces[pieceindex].YOfs;
					pVertex->z = z + pieces[pieceindex].ZOfs;

					pVertex->nx = mesh->VertexNormalEntries[vertexindex][0]/127.0f;
					pVertex->ny = mesh->VertexNormalEntries[vertexindex][0]/127.0f;
					pVertex->nz = mesh->VertexNormalEntries[vertexindex][0]/127.0f;
					pVertex->color = 0xffffffff;
					pVertex->u1 = mesh->TextureCoordEntries_w[vertexindex][0]/256.0f;
					pVertex->v1 = mesh->TextureCoordEntries_w[vertexindex][1]/256.0f;

					pVertex ++;

				}

				polygoncount++;

			}

			ppVBs[i][j]->Unlock();

		}

	}
I followed exactly what you have done in dzoneconverter =)
__________________
Sandy
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 12:07 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3