ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

emimesh_component.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "common/foreach.h"
00024 
00025 #include "engines/grim/emi/costume/emimesh_component.h"
00026 #include "engines/grim/emi/modelemi.h"
00027 #include "engines/grim/resource.h"
00028 #include "engines/grim/costume.h"
00029 
00030 namespace Grim {
00031 
00032 EMIMeshComponent::EMIMeshComponent(Component *p, int parentID, const char *filename, Component *prevComponent, tag32 t, EMICostume *costume) :
00033         Component(p, parentID, filename, t), _costume(costume), _obj(nullptr), _parentModel(nullptr), _hasComplained(false) {
00034     _hierShared = false;
00035 }
00036 
00037 EMIMeshComponent::~EMIMeshComponent() {
00038     if (_hierShared) {
00039         _obj = nullptr; // Keep ~ModelComp from deleting it
00040         //_animation = NULL;
00041     } else {
00042         delete _obj;
00043     }
00044 
00045     foreach (EMIMeshComponent *child, _children) {
00046         child->_obj = nullptr;
00047         //child->_hier = NULL;
00048         child->_parentModel = nullptr;
00049     }
00050 
00051     if (_parentModel) {
00052         _parentModel->_children.remove(this);
00053     }
00054 }
00055 
00056 void EMIMeshComponent::init() {
00057     _visible = true;
00058     _obj = g_resourceloader->loadModelEMI(_name, _costume);
00059 }
00060 
00061 int EMIMeshComponent::update(uint time) {
00062     return 0;
00063 }
00064 
00065 void EMIMeshComponent::reset() {
00066     _visible = true;
00067 }
00068 
00069 void EMIMeshComponent::draw() {
00070     // If the object was drawn by being a component
00071     // of it's parent then don't draw it
00072     if (_parent && _parent->isVisible())
00073         return;
00074     if (!_obj) {
00075         if (!_hasComplained) {
00076             warning("Tried to draw component we have no file for %s", _name.c_str());
00077             _hasComplained = true;
00078         }
00079         return;
00080     }
00081     // Need to translate object to be in accordance
00082     // with the setup of the parent
00083     //translateObject(false);
00084 
00085     _obj->draw();
00086 
00087     // Need to un-translate when done
00088     //translateObject(true);
00089 }
00090 
00091 void EMIMeshComponent::getBoundingBox(int *x1, int *y1, int *x2, int *y2) const {
00092     // If the object was drawn by being a component
00093     // of it's parent then don't draw it
00094 
00095     if (_parent && _parent->isVisible())
00096         return;
00097 
00098     if (_obj)
00099         _obj->getBoundingBox(x1, y1, x2, y2);
00100 }
00101 
00102 } // end of namespace Grim


Generated on Sat Mar 16 2019 05:01:30 for ResidualVM by doxygen 1.7.1
curved edge   curved edge