2003-08-15 18:00:22 +00:00
|
|
|
// Residual - Virtual machine to run LucasArts' 3D adventure games
|
|
|
|
// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2003-08-15 19:41:26 +00:00
|
|
|
#ifndef SCENE_H
|
|
|
|
#define SCENE_H
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2003-08-15 19:41:26 +00:00
|
|
|
#include "vector3d.h"
|
|
|
|
#include "bitmap.h"
|
|
|
|
#include "color.h"
|
2003-08-18 14:13:09 +00:00
|
|
|
#include "debug.h"
|
2003-08-15 18:00:22 +00:00
|
|
|
#include <SDL.h>
|
|
|
|
#include <SDL_opengl.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class Colormap;
|
|
|
|
class TextSplitter;
|
|
|
|
|
|
|
|
// The Lua code calls this a "set".
|
|
|
|
|
|
|
|
class Scene {
|
|
|
|
public:
|
|
|
|
Scene(const char *name, const char *buf, int len);
|
|
|
|
~Scene();
|
|
|
|
|
|
|
|
void drawBackground() const {
|
2003-08-18 14:13:09 +00:00
|
|
|
if (currSetup_->bkgnd_zbm_ == NULL) {
|
|
|
|
error("Null background for setup %s in %s", currSetup_->name_.c_str(), name_.c_str());
|
|
|
|
return;
|
|
|
|
}
|
2003-08-15 18:00:22 +00:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthMask(GL_FALSE);
|
2003-08-18 14:13:09 +00:00
|
|
|
currSetup_->bkgnd_zbm_->draw();
|
2003-08-15 18:00:22 +00:00
|
|
|
glDepthMask(GL_TRUE);
|
|
|
|
}
|
|
|
|
void setupCamera() {
|
|
|
|
currSetup_->setupCamera();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *name() const { return name_.c_str(); }
|
|
|
|
|
|
|
|
void setSetup(int num) { currSetup_ = setups_ + num; }
|
|
|
|
int setup() const { return currSetup_ - setups_; }
|
|
|
|
|
2003-08-16 06:41:37 +00:00
|
|
|
// Sector access functions
|
2003-08-17 08:30:18 +00:00
|
|
|
#define validSector(id) ((numSectors_ >= 0) && (id < numSectors_))
|
2003-08-16 06:41:37 +00:00
|
|
|
int getSectorCount() { return numSectors_; }
|
2003-08-17 08:11:59 +00:00
|
|
|
const char *getSectorName(int id) const {
|
2003-08-17 08:30:18 +00:00
|
|
|
if (validSector(id)) return sectors_[id].name_.c_str(); else return NULL;
|
2003-08-17 08:11:59 +00:00
|
|
|
}
|
2003-08-17 08:30:18 +00:00
|
|
|
int getSectorType(int id) { if (validSector(id)) return sectors_[id].type_; else return -1; }
|
|
|
|
int getSectorID(int id) { if (validSector(id)) return sectors_[id].id_; else return -1; }
|
2003-08-16 06:41:37 +00:00
|
|
|
bool isPointInSector(int id, Vector3d point) { return false; } // FIXME: Need pointInPoly func
|
|
|
|
|
2003-08-15 18:00:22 +00:00
|
|
|
private:
|
|
|
|
struct Setup { // Camera setup data
|
|
|
|
void load(TextSplitter &ts);
|
|
|
|
void setupCamera() const;
|
|
|
|
std::string name_;
|
|
|
|
ResPtr<Bitmap> bkgnd_bm_, bkgnd_zbm_;
|
|
|
|
Vector3d pos_, interest_;
|
|
|
|
float roll_, fov_, nclip_, fclip_;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Light { // Scene lighting data
|
|
|
|
void load(TextSplitter &ts);
|
|
|
|
std::string name_;
|
|
|
|
std::string type_;
|
|
|
|
Vector3d pos_, dir_;
|
|
|
|
Color color_;
|
|
|
|
float intensity_, umbraangle_, penumbraangle_;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sector { // Walkarea 'sectors'
|
|
|
|
void load(TextSplitter &ts);
|
|
|
|
void load0(TextSplitter &ts, char *name, int id);
|
|
|
|
int numVertices_, id_;
|
|
|
|
std::string name_;
|
2003-08-16 06:41:37 +00:00
|
|
|
int type_;
|
2003-08-15 18:00:22 +00:00
|
|
|
std::string visibility_;
|
|
|
|
Vector3d *vertices_;
|
|
|
|
float height_;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string name_;
|
|
|
|
int numCmaps_;
|
|
|
|
ResPtr<Colormap> *cmaps_;
|
|
|
|
int numSetups_, numLights_, numSectors_;
|
|
|
|
Sector *sectors_;
|
|
|
|
Light *lights_;
|
|
|
|
Setup *setups_;
|
|
|
|
Setup *currSetup_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|