Jump to content


drawing lines that represent the vertexbuffer points


  • You cannot reply to this topic
6 replies to this topic

#1 Anddos

    Valued Member

  • Members
  • PipPipPip
  • 161 posts

Posted 19 October 2008 - 04:13 AM

basically my code loads a mesh , i then create a thread locking index and vertex buffer , i then test which format and get 3*x,y,x of 1 indice
now in the vertexbuffer for drawing the LINELIST i have the x,y,z of the first of 3 indices , the problem is the line is way of the mark that represents to vertex point

here is a pic and video
i thought locking in a new thread would be alot quicker

http://img266.images...apotlockrx6.jpg


DWORD LockThread(LPDWORD lpdwParam) 

{ 

Start:


	BYTE* lpbVb;

	BYTE *lpIB; //8 bits

	//short *lpIB; //16 bits


	//get the vertex buffer

	static HRESULT cHresult;

	if(FishMesh)

	{

	cHresult = meshTeapot->LockVertexBuffer( D3DLOCK_READONLY, (VOID**)&lpbVb );

	}

	

	if(cHresult == D3D_OK)

	{

		sprintf(data , "%s \n" , "locked vertex buffer success");

	    WriteConsole(Console , data , strlen(data) , &written , NULL);

	}


	Sleep(2000);


	if(meshTeapot)

	{

	cHresult = meshTeapot->LockIndexBuffer ( D3DLOCK_READONLY, (VOID**)&lpIB); 

	}


	

	


	

	if(cHresult == D3D_OK)

	{

		sprintf(data , "%s \n" , "locked index buffer success");

	    WriteConsole(Console , data , strlen(data) , &written , NULL);

	}


	Sleep(500);


	cHresult = meshTeapot->GetIndexBuffer( &lpIndexBuffer );

	

	if(cHresult == D3D_OK)

	{

		sprintf(data , "%s \n" , "got desc success");

	    WriteConsole(Console , data , strlen(data) , &written , NULL);

	}


	Sleep(500);


	cHresult = lpIndexBuffer->GetDesc( &ibdesc );

	

	if(cHresult == D3D_OK)

	{

		//MessageBox(NULL,"GetDesc Success","",0);

	}


	if(ibdesc.Format == D3DFMT_INDEX32)

	{

		//MessageBox(NULL,"ibdesc.Format 32","",0);

		numIndices = ibdesc.Size / sizeof(DWORD);

	}

	else

	{

		//MessageBox(NULL,"ibdesc.Format 16","",0);

		numIndices = ibdesc.Size / sizeof(WORD);


	}


	Sleep(500);


	sprintf(data , "%s %d \n" , "numIndices" , numIndices);

	WriteConsole(Console , data , strlen(data) , &written , NULL);

	


	numBytesPerVertex = meshTeapot->GetNumBytesPerVertex();


	//Sleep(500);


	sprintf(data , "%s %d \n" , "numBytesPerVertex" , numBytesPerVertex);

	WriteConsole(Console , data , strlen(data) , &written , NULL);


	Sleep(100);


    //sprintf(data , "%s %d \n" , "numIndices" , numIndices);

	//WriteConsole(Console , data , strlen(data) , &written , NULL);


	for(int i=0; i<numIndices; i += 3 )

	{


		sprintf(data , "%s %d \n" , "i" , i);

	    WriteConsole(Console , data , strlen(data) , &written , NULL);


		//Sleep(5);


		if (ibdesc.Format == D3DFMT_INDEX32  ) 

	    {

				idxVbVert0 = ((DWORD*)lpIB)[ i ];

				idxVbVert1 = ((DWORD*)lpIB)[ i+1 ];

				idxVbVert2 = ((DWORD*)lpIB)[ i+2 ];


				//sprintf(data , "%s \n" , "format is 32");

	            //WriteConsole(Console , data , strlen(data) , &written , NULL);

	    }

		else

		{

				//sprintf(data , "%s \n" , "format is 16");

	            //WriteConsole(Console , data , strlen(data) , &written , NULL);


			    idxVbVert0 = ((WORD*)lpIB)[ i ];

				idxVbVert1 = ((WORD*)lpIB)[ i+1 ];

				idxVbVert2 = ((WORD*)lpIB)[ i+2 ];


				

		}

	  

                v0 = *(D3DXVECTOR3*) &lpbVb[ idxVbVert0 * numBytesPerVertex ];

	   v1 = *(D3DXVECTOR3*) &lpbVb[ idxVbVert1 * numBytesPerVertex ];

                v2 = *(D3DXVECTOR3*) &lpbVb[ idxVbVert2 * numBytesPerVertex ];

		

             D3DXVec3TransformCoord( &worldBounds[0], &v0, &matMove );

	D3DXVec3TransformCoord( &worldBounds[1], &v1, &matMove );

	D3DXVec3TransformCoord( &worldBounds[2], &v2, &matMove );



	sprintf(data , "%s %f \n" , "worldBounds[0].x" , worldBounds[0].x);

	WriteConsole(Console , data , strlen(data) , &written , NULL);


    sprintf(data , "%s %f \n" , "worldBounds[0].y" , worldBounds[0].y);

	WriteConsole(Console , data , strlen(data) , &written , NULL);


    sprintf(data , "%s %f \n" , "worldBounds[0].z" , worldBounds[0].z);

	WriteConsole(Console , data , strlen(data) , &written , NULL);

	


	}


	//Unlock()

	meshTeapot->UnlockVertexBuffer();

	meshTeapot->UnlockIndexBuffer();


	sprintf(data , "%s\n" , "unlocked");

	WriteConsole(Console , data , strlen(data) , &written , NULL);


	Sleep(5000);


	goto Start;



    return 0; 

} 



#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4967 posts
  • LocationBellevue, WA

Posted 19 October 2008 - 04:43 AM

I don't understand what the problem is. Can you try and explain it more thoroughly?
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 Anddos

    Valued Member

  • Members
  • PipPipPip
  • 161 posts

Posted 19 October 2008 - 05:00 AM


i cant get the lines to touch the vertexpoints of the mesh , it shows the lines way above the points

#4 Anddos

    Valued Member

  • Members
  • PipPipPip
  • 161 posts

Posted 19 October 2008 - 07:42 AM

nevermind i have it sorted now

Posted Image

what i am trying to figure out out is if the fish moves the vertices postions do not change , so i do i need to convert vertices of a mesh like you do with bounding boxes to world space matrix?
i just want to convert the fish's mouth so the postion updates if it moves
i know in the indexbuffer which number is around the fish mouth area

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 4967 posts
  • LocationBellevue, WA

Posted 19 October 2008 - 09:09 PM

Yes, each time you draw a mesh all the vertices are transformed by the current world matrix. So if you want to find out the world space location of a vertex you'll need to multiply the vertex position with the same world matrix you use when you draw the mesh.
reedbeta.com - developer blog, OpenGL demos, and other projects

#6 Anddos

    Valued Member

  • Members
  • PipPipPip
  • 161 posts

Posted 20 October 2008 - 05:10 AM

so object space is not changed when you translate the mesh

#7 Reedbeta

    DevMaster Staff

  • Administrators
  • 4967 posts
  • LocationBellevue, WA

Posted 20 October 2008 - 05:24 AM

Correct.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users