2013-07-07 17:18:30 -07:00
|
|
|
/* ResidualVM - A 3D game interpreter
|
|
|
|
*
|
|
|
|
* ResidualVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-04-05 18:18:42 +02:00
|
|
|
*
|
2013-07-07 17:18:30 -07:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-04-05 18:18:42 +02:00
|
|
|
*
|
2013-07-07 17:18:30 -07:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/endian.h"
|
|
|
|
|
|
|
|
#include "engines/grim/sprite.h"
|
|
|
|
#include "engines/grim/resource.h"
|
|
|
|
#include "engines/grim/gfx_base.h"
|
2013-07-07 17:23:27 -07:00
|
|
|
#include "engines/grim/emi/costumeemi.h"
|
2013-07-07 17:18:30 -07:00
|
|
|
|
|
|
|
|
|
|
|
namespace Grim {
|
|
|
|
|
2013-10-26 13:57:55 -07:00
|
|
|
Sprite::Sprite() :
|
|
|
|
_width(0), _height(0), _visible(false), _material(NULL), _next(NULL) {
|
2013-07-07 17:18:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Sprite::draw() const {
|
|
|
|
if (!_visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_material->select();
|
|
|
|
g_driver->drawSprite(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Sprite::loadGrim(const Common::String &name, const char *comma, CMap *cmap) {
|
|
|
|
int width, height, x, y, z;
|
|
|
|
sscanf(comma, ",%d,%d,%d,%d,%d", &width, &height, &x, &y, &z);
|
|
|
|
_material = g_resourceloader->loadMaterial(name, cmap);
|
|
|
|
_width = (float)width / 100.0f;
|
|
|
|
_height = (float)height / 100.0f;
|
|
|
|
_pos.set((float)x / 100.0f, (float)y / 100.0f, (float)z / 100.0f);
|
|
|
|
}
|
|
|
|
|
2013-07-07 17:23:27 -07:00
|
|
|
void Sprite::loadBinary(Common::SeekableReadStream *stream, EMICostume *costume) {
|
2013-07-07 17:18:30 -07:00
|
|
|
if (!stream)
|
|
|
|
return;
|
|
|
|
|
|
|
|
uint32 namelength = stream->readUint32LE();
|
|
|
|
stream->skip(namelength);
|
|
|
|
|
|
|
|
stream->seek(40, SEEK_CUR);
|
|
|
|
uint32 texnamelength = stream->readUint32LE();
|
|
|
|
char *texname = new char[texnamelength];
|
|
|
|
stream->read(texname, texnamelength);
|
|
|
|
/* unknown = */ stream->readUint32LE();
|
|
|
|
float width, height;
|
|
|
|
float offX, offY;
|
|
|
|
char data[16];
|
|
|
|
stream->read(data, sizeof(data));
|
|
|
|
width = get_float(data);
|
|
|
|
height = get_float(data + 4);
|
|
|
|
offX = get_float(data + 8);
|
|
|
|
offY = get_float(data + 12);
|
|
|
|
|
2013-12-22 21:29:58 +01:00
|
|
|
_material = costume->loadMaterial(texname);
|
2013-07-07 17:18:30 -07:00
|
|
|
_width = width;
|
|
|
|
_height = height;
|
|
|
|
_next = NULL;
|
|
|
|
_visible = true;
|
2013-11-30 16:42:57 -08:00
|
|
|
_pos.set(offX, offY, 0);
|
2013-07-07 17:18:30 -07:00
|
|
|
|
|
|
|
delete[] texname;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end of namespace Grim
|