Hya,
I'm having some really strange problems with vectors in VC++Express. Has something changed since VC++6.0?
Maybe I've got something else wrong somewhere but when I try to copy a D3DXVECTOR3 in to a vector<D3DXVECTOR3> I get this message:
c:\documents and settings\matts login\my documents\programming\c++ work\terrain\cboundingbox.cpp(27) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const D3DXVECTOR3' (or there is no acceptable conversion)
The class structure
class CBoundingBox
{
public:
CBoundingBox( const D3DXVECTOR3& v_1 = D3DXVECTOR3(),
const D3DXVECTOR3& v_2 = D3DXVECTOR3() )
{
blnFirst = true;
AddPoint( v_1 );
AddPoint( v_2 );
}
// gets
D3DXVECTOR3 GetV1() const { return v1; }
D3DXVECTOR3 GetV2() const { return v2; }
D3DXVECTOR3 GetCentre() const { return ( v1 + v2 ) / 2; }
std::vector<D3DXVECTOR3> GetCorners() const;
// functions
void AddPoint( const D3DXVECTOR3& v );
void Clear();
friend std::ostream& BOUNDINGBOX_Show( std::ostream& out,
const CBoundingBox& b );
private:
D3DXVECTOR3 v1, v2;
bool blnFirst;
};
The function
vector<D3DXVECTOR3> CBoundingBox::GetCorners()const
{
vector<D3DXVECTOR3> v[8];
v[0] = v1;
v[1] = D3DXVECTOR3( v2.x, v1.y, v1.z );
v[2] = D3DXVECTOR3( v1.x, v2.y, v1.z );
v[3] = D3DXVECTOR3( v2.x, v2.y, v1.z );
v[4] = D3DXVECTOR3( v1.x, v1.y, v2.z );
v[5] = D3DXVECTOR3( v2.x, v1.y, v2.z );
v[6] = D3DXVECTOR3( v1.x, v2.y, v2.z );
v[7] = v2;
return v;
}
At every point in the function where I try to set an element of 'v' I get the error message.
I'm having similar problems with the '<' and '>' signs in this code:
Functin decleration
int D3DMaths_SphereIntersectVolume( const std::vector<D3DXPLANE>& planes,
const D3DXVECTOR3& centre,
float radious );
Function
// does a sphere intersect a volume
int D3DMaths_SphereIntersectVolume( const vector<D3DXPLANE>& planes,
const D3DXVECTOR3& centre,
float radious )
{
bool intersect = false;
bool CentreInside = true;
vector<float> t[ planes.size() ];
for( vector<float>::size_type i = 0; i != planes.size(); ++i ) {
//get the dot product of the point with this plane
t = D3DXPlaneDotCoord( &planes, ¢re);
// if the point lies beyond the current plane
if( t > radious ) return D3DMaths_OUTSIDE;
// if the sphere intersects this plane
if( fabs( t ) < radious ) intersect = true;
if( t > 0 ) CentreInside = false;
}
if( intersect ) return D3DMaths_INTERSECT;
return D3DMaths_INSIDE;
}
The error message for that is:
c:\documents and settings\matts login\my documents\programming\c++ work\terrain\d3dmaths.cpp(102) : error C2784: 'bool std::operator >(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'int'
c:\program files\microsoft visual studio 8\vc\include\vector(1285) : see declaration of 'std::operator >'
Any help would be greatly appreciated
Thanks
Matt