Skip to content

Commit

Permalink
GRAPHICS: Add Model::forceTransparent()
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Feb 11, 2014
1 parent eee82c2 commit 94ddd36
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/graphics/aurora/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,33 @@ void Model::showBoundingBox(bool show) {
}
}

void Model::forceTransparent() {
Renderable::forceTransparent();
}

void Model::forceTransparent(const Common::UString &node) {
forceTransparent(getNode(node));
}

void Model::forceTransparent(Ogre::SceneNode *node) {
if (!node)
return;

for (uint i = 0; i < node->numAttachedObjects(); i++) {
Ogre::MovableObject *object = node->getAttachedObject(i);

Ogre::Entity *entity = dynamic_cast<Ogre::Entity *>(object);
if (!entity)
continue;

for (uint j = 0; j < entity->getNumSubEntities(); j++) {
Ogre::SubEntity *subEntity = entity->getSubEntity(j);

MaterialMan.setTransparent(subEntity->getMaterial(), true);
}
}
}

void Model::makeDynamic() {
_materials.clear();

Expand Down
7 changes: 7 additions & 0 deletions src/graphics/aurora/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ class Model : public Renderable {
/** Show/Hide the bouding box(es) of this model. */
void showBoundingBox(bool show);

/** Force the handling of the whole model as a transparent object. */
void forceTransparent();
/** Force the handling of this model node as a transparent object. */
void forceTransparent(const Common::UString &node);
/** Force the handling of this model node as a transparent object. */
void forceTransparent(Ogre::SceneNode *node);

/** Convert all materials used by the model into dynamic materials. */
void makeDynamic();

Expand Down

0 comments on commit 94ddd36

Please sign in to comment.