Advertisement

copying array structure to dynamic array

Started by August 03, 2001 10:01 PM
2 comments, last by Julio 23 years, 6 months ago
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.Triangle[x].fX;
			if (v==1)
				pIndicies[i+v]=pFaces.Triangle[y].fY;
			if (v==2)
				pIndicies[i+v]=pFaces.Triangle[z].fZ;
		}*/</font>
		pIndicies[<font color="purple">v+0</font>]=pFaces[<font color="purple">i</font>].Triangle[<font color="purple">x</font>].fX;
		pIndicies[<font color="purple">v+1</font>]=pFaces[<font color="purple">i</font>].Triangle[<font color="purple">y</font>].fY;
		pIndicies[<font color="purple">v+2</font>]=pFaces[<font color="purple">i</font>].Triangle[<font color="purple">z</font>].fZ;

		v+=3;
	}
    </pre></font></td></tr></table></center><!–ENDSCRIPT–>
thanks in advance to any who reply,
Joe    

<a href="http://shamansoftware.8m.com"><img src="http://shamansoftware.8m.com\sstitle2.jpg"/img></a>

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    
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
What is the declaration for pFaces?
VK
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.
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
nevermind.



How many Microsoft employees does it take to screw in a light bulb?
None, they just declare drakness as a new standard.
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911

This topic is closed to new replies.

Advertisement