scummvm/scene.h

110 lines
2.9 KiB
C
Raw Normal View History

2003-08-15 18:00:22 +00:00
// Residual - Virtual machine to run LucasArts' 3D adventure games
// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
2003-08-15 18:00:22 +00:00
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef SCENE_H
#define SCENE_H
2003-08-15 18:00:22 +00:00
#include "vector3d.h"
#include "bitmap.h"
#include "color.h"
#include "debug.h"
#include "walkplane.h"
2004-03-22 11:23:37 +00:00
#include "objectstate.h"
2003-08-15 18:00:22 +00:00
#include <SDL.h>
#include <SDL_opengl.h>
#include <string>
class CMap;
2003-08-15 18:00:22 +00:00
class TextSplitter;
// The Lua code calls this a "set".
class Scene {
public:
Scene(const char *name, const char *buf, int len);
~Scene();
2003-08-15 18:00:22 +00:00
void drawBackground() const {
2004-12-10 07:26:03 +00:00
if (_currSetup->_bkgndZBm != NULL) // Some screens have no zbuffer mask (eg, Alley)
_currSetup->_bkgndZBm->draw();
2004-12-10 07:26:03 +00:00
if (_currSetup->_bkgndBm == NULL) {
2004-12-09 23:55:43 +00:00
error("Null background for setup %s in %s", _currSetup->_name.c_str(), _name.c_str());
return;
}
2004-12-10 07:26:03 +00:00
_currSetup->_bkgndBm->draw();
}
2004-03-22 11:23:37 +00:00
void drawBitmaps(ObjectState::Position stage);
void setupCamera() {
2004-12-09 23:55:43 +00:00
_currSetup->setupCamera();
}
2003-08-15 18:00:22 +00:00
2004-12-09 23:55:43 +00:00
const char *name() const { return _name.c_str(); }
2003-08-15 18:00:22 +00:00
void setSetup(int num);
2004-12-09 23:55:43 +00:00
int setup() const { return _currSetup - _setups; }
2003-08-15 18:00:22 +00:00
// Sector access functions
2004-12-09 23:55:43 +00:00
int getSectorCount() { return _numSectors; }
Sector *getSectorBase(int id) {
2004-12-09 23:55:43 +00:00
if ((_numSectors >= 0) && (id < _numSectors))
return &_sectors[id];
else
return NULL;
}
Sector *findPointSector(Vector3d p, int flags);
void findClosestSector(Vector3d p, Sector **sect, Vector3d *closestPt);
2004-03-22 11:23:37 +00:00
void addObjectState(ObjectState *s) {
2004-12-09 23:55:43 +00:00
_states.push_back(s);
2004-03-22 11:23:37 +00:00
}
ObjectState *findState(const char *filename);
2004-03-22 11:23:37 +00:00
2003-08-15 18:00:22 +00:00
private:
struct Setup { // Camera setup data
void load(TextSplitter &ts);
void setupCamera() const;
2004-12-09 23:55:43 +00:00
std::string _name;
2004-12-10 07:26:03 +00:00
ResPtr<Bitmap> _bkgndBm, _bkgndZBm;
2004-12-09 23:55:43 +00:00
Vector3d _pos, _interest;
float _roll, _fov, _nclip, _fclip;
};
2003-08-15 18:00:22 +00:00
struct Light { // Scene lighting data
void load(TextSplitter &ts);
2004-12-09 23:55:43 +00:00
std::string _name;
std::string _type;
Vector3d _pos, _dir;
Color _color;
float _intensity, _umbraangle, _penumbraangle;
};
2003-08-15 18:00:22 +00:00
2004-12-09 23:55:43 +00:00
std::string _name;
int _numCmaps;
ResPtr<CMap> *_cmaps;
int _numSetups, _numLights, _numSectors;
Sector *_sectors;
Light *_lights;
Setup *_setups;
Setup *_currSetup;
2004-03-22 11:23:37 +00:00
typedef std::list<ObjectState*> StateList;
2004-12-09 23:55:43 +00:00
StateList _states;
2003-08-15 18:00:22 +00:00
};
#endif