#pragma once class FlexVertex { static unsigned int posByteOffset; static unsigned int normalByteOffset; static unsigned int diffuseByteOffset; static unsigned int specularByteOffset; static unsigned int texByteOffset[16]; static unsigned int nTex; public: static void setFormat(D3DVERTEXELEMENT9* decl); D3DXVECTOR3& pos() { return *(D3DXVECTOR3*)(((char*)this) + posByteOffset); } D3DXVECTOR3& normal() { return *(D3DXVECTOR3*)(((char*)this) + normalByteOffset); } D3DXVECTOR2& tex0() { return *(D3DXVECTOR2*)(((char*)this) + texByteOffset[0]); } D3DXVECTOR2& tex1() { return *(D3DXVECTOR2*)(((char*)this) + texByteOffset[1]); } D3DXVECTOR2& tex(unsigned int i) { return *(D3DXVECTOR2*)(((char*)this) + texByteOffset[i]); } D3DCOLOR& diffuse() { return *(D3DCOLOR*)(((char*)this) + diffuseByteOffset); } D3DCOLOR& specular() { return *(D3DCOLOR*)(((char*)this) + specularByteOffset); } void operator=(const FlexVertex& o) { bool kamu = false; // use FlexVertexArray.assign to copy data } }; class FlexVertexArray { unsigned int nBytesPerVertex; public: FlexVertex* arrayStart; FlexVertex& operator[](unsigned int index) { return *((FlexVertex*)((char*)arrayStart + nBytesPerVertex * index)); } void** getDataPointerReference() { return (void**)&arrayStart; } FlexVertexArray(unsigned int nBytesPerVertex) { this->nBytesPerVertex = nBytesPerVertex; } void assign(unsigned int index, FlexVertex& o) { memcpy( (void**)((char*)arrayStart + nBytesPerVertex * index), &o, nBytesPerVertex); } };