Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Julio

copying array structure to dynamic array

This topic is 6196 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, for this compiled vertex array class I'm doing I delete the pointer to the indicies, re-allocate memory for it based on the vertex count * 3 (x,y,z). My rendering code worked fine before I added a feature to copy data from my Face data structure to my vertex array pointer. here's what the code looks like: basic stuff
    
const short unsigned int x = 0;
const short unsigned int y = 1;
const short unsigned int z = 2;

typedef struct 
{
	float fU, fV;
}Vector2D;

typedef struct 
{
	float fX, fY, fZ;
	float fU, fV;
}Vector3D;

struct Face
{
	Vector3D Triangle[3];
	//Vector2D TexCoord;

	Vector3D Normal;
	unsigned int iTexID;
};    
for testing purposes. all values are getting set correctly.
  
        Face Tri[1];

	Tri[0].Triangle[0].fX=-1.0f; //-1,0,0

	Tri[0].Triangle[0].fY=0.0f;
	Tri[0].Triangle[0].fZ=0.0f;
	Tri[0].Triangle[1].fX=1.0f; //1,0,0

	Tri[0].Triangle[1].fY=0.0f;
	Tri[0].Triangle[1].fZ=0.0f;
	Tri[0].Triangle[2].fX=0.5f; //0.5,1,0

	Tri[0].Triangle[2].fY=1.0f;
	Tri[0].Triangle[2].fZ=0.0f;
    
Delete the array
  
	if (pIndicies)
	{
		delete [] pIndicies;
		pIndicies=0;
	}
    
Re-allocate memory
      
	pIndicies = new float[iVertexCount*3];
    
and finally copy it. I'd think this would be pretty easy but the values don't seem to be getting set.
      
	unsigned int v=0;
	for (unsigned int i=0; i<iVertexCount; i++)
	{
		/*for (int v=0; v<3; v++)
		{
			if (v==0)
				pIndicies[i+v]=pFaces[i].Triangle[x].fX;
			if (v==1)
				pIndicies[i+v]=pFaces[i].Triangle[y].fY;
			if (v==2)
				pIndicies[i+v]=pFaces[i].Triangle[z].fZ;
		}*/
		pIndicies[v+0]=pFaces[i].Triangle[x].fX;
		pIndicies[v+1]=pFaces[i].Triangle[y].fY;
		pIndicies[v+2]=pFaces[i].Triangle[z].fZ;

		v+=3;
	}
    
thanks in advance to any who reply, Joe How many Microsoft employees does it take to screw in a light bulb? None, they just declare drakness as a new standard. Edited by - Julio on August 3, 2001 11:05:03 PM

Share this post


Link to post
Share on other sites
Advertisement
Face *pFaces;



How many Microsoft employees does it take to screw in a light bulb?
None, they just declare drakness as a new standard.

Share this post


Link to post
Share on other sites
nevermind.



How many Microsoft employees does it take to screw in a light bulb?
None, they just declare drakness as a new standard.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!