157 lines
3.7 KiB
C++
157 lines
3.7 KiB
C++
#ifndef _PROTO_SIMPLEOBJECT_HPP_
|
|
#define _PROTO_SIMPLEOBJECT_HPP_
|
|
#ifndef _COMMON_SMARTPOINTER_HPP_
|
|
#include <common/pointer.hpp>
|
|
#endif
|
|
#ifndef _COMMON_BITMAP_HPP_
|
|
#include <common/bitmap.hpp>
|
|
#endif
|
|
#ifndef _ENGINE_VECTOR3D_HPP_
|
|
#include <engine/vector3d.hpp>
|
|
#endif
|
|
#ifndef _ENGINE_TEXTURE_HPP_
|
|
#include <engine/texture.hpp>
|
|
#endif
|
|
#ifndef _PROTO_PUREOBJECT_HPP_
|
|
#include <proto/pureobj.hpp>
|
|
#endif
|
|
|
|
class SimpleObject : public PureObject
|
|
{
|
|
public:
|
|
SimpleObject(void);
|
|
SimpleObject(const Vector3D &vector3D,UINT id=0);
|
|
virtual ~SimpleObject();
|
|
Point3D &operator[](unsigned short index);
|
|
void setVector(const Vector3D &vector3D);
|
|
const Vector3D &getInitVector(void)const;
|
|
void setTexture(SmartPointer<Bitmap> &textureBitmap,bool ownIt=false);
|
|
const SmartPointer<Bitmap> &getTexture(void)const;
|
|
virtual void rotate(const PureAngle &pureAngle,RotationMatrix::Orientation orientation);
|
|
virtual void translate(const Point &uvPoint,TranslationMatrix::Orientation orientation);
|
|
virtual void map(SmartPointer<DIB3D> &displayBitmap);
|
|
virtual void normalize(void);
|
|
virtual bool isInView(SmartPointer<DIB3D> &displayBitmap);
|
|
virtual const Vector3D &getVector(void)const;
|
|
private:
|
|
SimpleObject(const SimpleObject &someSimpleObject);
|
|
SimpleObject &operator=(const SimpleObject &someSimpleObject);
|
|
|
|
SmartPointer<Bitmap> mTextureBitmap;
|
|
Vector3D mVector3D;
|
|
Vector3D mInitVector3D;
|
|
};
|
|
|
|
inline
|
|
SimpleObject::SimpleObject(void)
|
|
{
|
|
}
|
|
|
|
inline
|
|
SimpleObject::SimpleObject(const Vector3D &vector3D,UINT id)
|
|
: PureObject(id), mVector3D(vector3D), mInitVector3D(vector3D)
|
|
{
|
|
}
|
|
|
|
inline
|
|
SimpleObject::SimpleObject(const SimpleObject &someSimpleObject)
|
|
{ // private implementation
|
|
*this=someSimpleObject;
|
|
}
|
|
|
|
inline
|
|
SimpleObject::~SimpleObject()
|
|
{
|
|
}
|
|
|
|
inline
|
|
Point3D &SimpleObject::operator[](unsigned short index)
|
|
{
|
|
return mVector3D[index];
|
|
}
|
|
|
|
inline
|
|
SimpleObject &SimpleObject::operator=(const SimpleObject &someSimpleObject)
|
|
{
|
|
mVector3D=someSimpleObject.mVector3D;
|
|
mTextureBitmap=someSimpleObject.mTextureBitmap;
|
|
setState(someSimpleObject.getState());
|
|
setID(someSimpleObject.getID());
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
void SimpleObject::setVector(const Vector3D &vector3D)
|
|
{
|
|
mVector3D=vector3D;
|
|
}
|
|
|
|
inline
|
|
const Vector3D &SimpleObject::getVector(void)const
|
|
{
|
|
return mVector3D;
|
|
}
|
|
|
|
inline
|
|
const Vector3D &SimpleObject::getInitVector(void)const
|
|
{
|
|
return mInitVector3D;
|
|
}
|
|
|
|
inline
|
|
void SimpleObject::setTexture(SmartPointer<Bitmap> &textureBitmap,bool ownIt)
|
|
{
|
|
mTextureBitmap=textureBitmap;
|
|
if(ownIt)mTextureBitmap.disposition(PointerDisposition::Delete);
|
|
}
|
|
|
|
inline
|
|
const SmartPointer<Bitmap> &SimpleObject::getTexture(void)const
|
|
{
|
|
return mTextureBitmap;
|
|
}
|
|
// virtuals
|
|
|
|
inline
|
|
void SimpleObject::map(SmartPointer<DIB3D> &displayBitmap)
|
|
{
|
|
Texture textureMapper(mVector3D,*mTextureBitmap,*displayBitmap);
|
|
textureMapper.mapTexture();
|
|
}
|
|
|
|
inline
|
|
void SimpleObject::rotate(const PureAngle &pureAngle,RotationMatrix::Orientation orientation)
|
|
{
|
|
RotationMatrix rotationMatrix;
|
|
rotationMatrix.orientation(orientation);
|
|
rotationMatrix.angle(pureAngle);
|
|
rotationMatrix.evaluate(mVector3D[0]);
|
|
rotationMatrix.evaluate(mVector3D[1]);
|
|
rotationMatrix.evaluate(mVector3D[2]);
|
|
rotationMatrix.evaluate(mVector3D[3]);
|
|
}
|
|
|
|
inline
|
|
void SimpleObject::translate(const Point &uvPoint,TranslationMatrix::Orientation orientation)
|
|
{
|
|
TranslationMatrix translationMatrix;
|
|
translationMatrix.orientation(orientation);
|
|
translationMatrix.uvPoint(uvPoint);
|
|
translationMatrix.evaluate(mVector3D[0]);
|
|
translationMatrix.evaluate(mVector3D[1]);
|
|
translationMatrix.evaluate(mVector3D[2]);
|
|
translationMatrix.evaluate(mVector3D[3]);
|
|
}
|
|
|
|
inline
|
|
void SimpleObject::normalize(void)
|
|
{
|
|
mVector3D.normalize();
|
|
}
|
|
|
|
inline
|
|
bool SimpleObject::isInView(SmartPointer<DIB3D> &displayBitmap)
|
|
{
|
|
return displayBitmap->isInView(mVector3D);
|
|
}
|
|
#endif |