00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "BillboardComponent.h"
00018 #include "../../core/GameManager.h"
00019
00020
00021
00022
00023 BillboardComponent::BillboardComponent(Entity *parent, const dimension2df &size,
00024 const SColor &colorTop, const SColor &colorBottom)
00025 : SceneComponent(parent, true)
00026 {
00027
00028 ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager();
00029
00030
00031 mBillboardSN = pSceneMgr->addBillboardSceneNode(0, size, parent->getPosition(), parent->getID(),
00032 colorTop, colorBottom);
00033 mSceneNode = mBillboardSN;
00034
00035
00036 mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardSN);
00037 mMetaSelector = pSceneMgr->createMetaTriangleSelector();
00038 }
00039
00040
00041 BillboardComponent::BillboardComponent(Entity *parent, bool isDerived)
00042 : SceneComponent(parent, true)
00043 {
00044 }
00045
00046
00047 BillboardComponent* BillboardComponent::refFactory(Entity *parent)
00048 {
00049 return new BillboardComponent(parent);
00050 }
00051
00052
00053 BillboardComponent* BillboardComponent::refFactory(Entity *parent, const dimension2df &size,
00054 const SColor &colorTop, const SColor &colorBottom)
00055 {
00056 return new BillboardComponent(parent, size, colorTop, colorBottom);
00057 }
00058
00059
00060 BillboardComponent::~BillboardComponent()
00061 {
00062 if(mBillboardSN != NULL)
00063 {
00064 mBillboardSN->remove();
00065 mSceneNode = NULL;
00066 }
00067 }
00068
00069
00070 IBillboardSceneNode* BillboardComponent::getBillboardSceneNode()
00071 {
00072 return mBillboardSN;
00073 }
00074
00075
00076 void BillboardComponent::getColor(SColor &topColor, SColor &bottomColor) const
00077 {
00078 mBillboardSN->getColor(topColor, bottomColor);
00079 }
00080
00081
00082 const dimension2df& BillboardComponent::getSize() const
00083 {
00084 return mBillboardSN->getSize();
00085 }
00086
00087
00088 void BillboardComponent::setColor(const SColor &overallColor)
00089 {
00090 mBillboardSN->setColor(overallColor);
00091 }
00092
00093
00094 void BillboardComponent::setColor(const SColor &topColor, const SColor &bottomColor)
00095 {
00096 mBillboardSN->setColor(topColor, bottomColor);
00097 }
00098
00099
00100 void BillboardComponent::setSize(const dimension2df &size)
00101 {
00102 mBillboardSN->setSize(size);
00103 }
00104
00105
00106
00107 void bindBillboardComponent(asIScriptEngine *engine)
00108 {
00109
00110 int r;
00111
00112
00113 r = engine->RegisterObjectType("BillboardComponent", sizeof(BillboardComponent), asOBJ_REF); assert(r >= 0);
00114
00115
00116 bindBillboardComponentBase<BillboardComponent>(engine, "BillboardComponent");
00117
00118
00119 r = engine->RegisterObjectBehaviour("BillboardComponent", asBEHAVE_FACTORY, "BillboardComponent@ f(Entity @)",
00120 asFUNCTIONPR(BillboardComponent::refFactory, (Entity*), BillboardComponent*),
00121 asCALL_CDECL); assert(r >= 0);
00122 r = engine->RegisterObjectBehaviour("BillboardComponent", asBEHAVE_FACTORY, "BillboardComponent@ f(Entity @, " \
00123 "const dimension2df &in, const SColor &in, const SColor &in)",
00124 asFUNCTIONPR(BillboardComponent::refFactory, (Entity*, const dimension2df&,
00125 const SColor&, const SColor&), BillboardComponent*),
00126 asCALL_CDECL); assert(r >= 0);
00127 }
00128
00129