Added some vector operations which take just one scalar as argument.
Optimized isBetweenPoints for vector2d Added some virtual qualifiers for better readability Added some terrain interface methods which are not properly working, yet git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1513 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
a7d24e4b8a
commit
57485235b9
|
@ -26,7 +26,7 @@ namespace scene
|
|||
}
|
||||
|
||||
//! destructor
|
||||
~CDynamicMeshBuffer()
|
||||
virtual ~CDynamicMeshBuffer()
|
||||
{
|
||||
if (VertexBuffer)
|
||||
VertexBuffer->drop();
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace scene
|
|||
setType(IndexType);
|
||||
}
|
||||
|
||||
~CIndexBuffer()
|
||||
virtual ~CIndexBuffer()
|
||||
{
|
||||
delete Indices;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace scene
|
|||
{
|
||||
public:
|
||||
//! Default constructor for empty meshbuffer
|
||||
CMeshBuffer():ChangedID_Vertex(1),ChangedID_Index(1),MappingHint(EHM_NEVER) // everything's default constructed
|
||||
CMeshBuffer() : ChangedID_Vertex(1), ChangedID_Index(1), MappingHint(EHM_NEVER)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("SMeshBuffer");
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace scene
|
|||
|
||||
class CVertexBuffer : public IVertexBuffer
|
||||
{
|
||||
|
||||
class IVertexList
|
||||
{
|
||||
public:
|
||||
|
@ -75,7 +74,7 @@ namespace scene
|
|||
setType(vertexType);
|
||||
}
|
||||
|
||||
~CVertexBuffer()
|
||||
virtual ~CVertexBuffer()
|
||||
{
|
||||
delete Vertices;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
|
||||
namespace irr
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
class IReadFile;
|
||||
} // end namespace io
|
||||
namespace scene
|
||||
{
|
||||
class IMesh;
|
||||
|
@ -70,12 +74,12 @@ namespace scene
|
|||
|
||||
//! Get pointer to the mesh
|
||||
/** \return Pointer to the mesh. */
|
||||
virtual IMesh* getMesh() = 0;
|
||||
|
||||
|
||||
//! Returns a pointer to the buffer used by the terrain (most users will not need this)
|
||||
virtual IMeshBuffer* getRenderBuffer() = 0;
|
||||
|
||||
virtual IMesh* getMesh() = 0;
|
||||
|
||||
|
||||
//! Returns a pointer to the buffer used by the terrain (most users will not need this)
|
||||
virtual IMeshBuffer* getRenderBuffer() = 0;
|
||||
|
||||
|
||||
//! Gets the meshbuffer data based on a specified level of detail.
|
||||
/** \param mb A reference to an SMeshBuffer object
|
||||
|
@ -146,6 +150,15 @@ namespace scene
|
|||
first set. If this is another value than zero, it will scale
|
||||
the second texture coordinate set by this value. */
|
||||
virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0;
|
||||
|
||||
//! Initializes the terrain data. Loads the vertices from the heightMapFile.
|
||||
virtual bool loadHeightMap(io::IReadFile* file,
|
||||
video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ) =0;
|
||||
|
||||
//! Initializes the terrain data. Loads the vertices from the heightMapFile.
|
||||
virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16,
|
||||
video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ) =0;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
|
@ -18,9 +18,13 @@ template <class T>
|
|||
class vector2d
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor (null vector)
|
||||
vector2d() : X(0), Y(0) {}
|
||||
//! Constructor with two different values
|
||||
vector2d(T nx, T ny) : X(nx), Y(ny) {}
|
||||
//! Constructor with the same value for both members
|
||||
explicit vector2d(T n) : X(n), Y(n) {}
|
||||
//! Copy constructor
|
||||
vector2d(const vector2d<T>& other) : X(other.X), Y(other.Y) {}
|
||||
|
||||
// operators
|
||||
|
@ -217,9 +221,16 @@ public:
|
|||
\return True if this vector is between begin and end, false if not. */
|
||||
bool isBetweenPoints(const vector2d<T>& begin, const vector2d<T>& end) const
|
||||
{
|
||||
const T f = (end - begin).getLengthSQ();
|
||||
return getDistanceFromSQ(begin) <= f &&
|
||||
getDistanceFromSQ(end) <= f;
|
||||
if (begin.X != end.X)
|
||||
{
|
||||
return ((begin.X <= X && X <= end.X) ||
|
||||
(begin.X >= X && X >= end.X));
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((begin.Y <= Y && Y <= end.Y) ||
|
||||
(begin.Y >= Y && Y >= end.Y));
|
||||
}
|
||||
}
|
||||
|
||||
//! Get the interpolated vector
|
||||
|
|
|
@ -19,7 +19,11 @@ namespace core
|
|||
public:
|
||||
//! Default constructor (null vector).
|
||||
vector3d() : X(0), Y(0), Z(0) {}
|
||||
//! Constructor with three different values
|
||||
vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {}
|
||||
//! Constructor with the same value for all elements
|
||||
explicit vector3d(T n) : X(n), Y(n), Z(n) {}
|
||||
//! Copy constructor
|
||||
vector3d(const vector3d<T>& other) : X(other.X), Y(other.Y), Z(other.Z) {}
|
||||
|
||||
// operators
|
||||
|
@ -30,9 +34,13 @@ namespace core
|
|||
|
||||
vector3d<T> operator+(const vector3d<T>& other) const { return vector3d<T>(X + other.X, Y + other.Y, Z + other.Z); }
|
||||
vector3d<T>& operator+=(const vector3d<T>& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; }
|
||||
vector3d<T> operator+(const T val) const { return vector3d<T>(X + val, Y + val, Z + val); }
|
||||
vector3d<T>& operator+=(const T val) { X+=val; Y+=val; Z+=val; return *this; }
|
||||
|
||||
vector3d<T> operator-(const vector3d<T>& other) const { return vector3d<T>(X - other.X, Y - other.Y, Z - other.Z); }
|
||||
vector3d<T>& operator-=(const vector3d<T>& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; }
|
||||
vector3d<T> operator-(const T val) const { return vector3d<T>(X - val, Y - val, Z - val); }
|
||||
vector3d<T>& operator-=(const T val) { X-=val; Y-=val; Z-=val; return *this; }
|
||||
|
||||
vector3d<T> operator*(const vector3d<T>& other) const { return vector3d<T>(X * other.X, Y * other.Y, Z * other.Z); }
|
||||
vector3d<T>& operator*=(const vector3d<T>& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; }
|
||||
|
|
Loading…
Reference in New Issue