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

nodecube.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 AUTHORS
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 "engines/myst3/nodecube.h"
00024 #include "engines/myst3/directorysubentry.h"
00025 #include "engines/myst3/myst3.h"
00026 
00027 #include "common/debug.h"
00028 
00029 namespace Myst3 {
00030 
00031 NodeCube::NodeCube(Myst3Engine *vm, uint16 id) :
00032         Node(vm, id) {
00033     _is3D = true;
00034 
00035     for (int i = 0; i < 6; i++) {
00036         const DirectorySubEntry *jpegDesc = _vm->getFileDescription("", id, i + 1, DirectorySubEntry::kCubeFace);
00037 
00038         if (!jpegDesc)
00039             error("Face %d does not exist", id);
00040 
00041         _faces[i] = new Face(_vm);
00042         _faces[i]->setTextureFromJPEG(jpegDesc);
00043     }
00044 }
00045 
00046 NodeCube::~NodeCube() {
00047 }
00048 
00049 void NodeCube::draw() {
00050     // Update the OpenGL textures if needed
00051     for (uint i = 0; i < 6; i++) {
00052         if (_faces[i]->isTextureDirty() && isFaceVisible(i)) {
00053             _faces[i]->uploadTexture();
00054         }
00055     }
00056 
00057     Texture *textures[6];
00058     for (uint i = 0; i < 6; i++) {
00059         textures[i] = _faces[i]->_texture;
00060     }
00061 
00062     _vm->_gfx->drawCube(textures);
00063 }
00064 
00065 bool NodeCube::isFaceVisible(uint faceId) {
00066     return _vm->_gfx->isCubeFaceVisible(faceId);
00067 }
00068 
00069 } // End of namespace Myst3


Generated on Sat May 18 2019 05:01:10 for ResidualVM by doxygen 1.7.1
curved edge   curved edge