1 /* ResidualVM - A 3D game interpreter 2 * 3 * ResidualVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 /* 24 * This file is based on WME. 25 * http://dead-code.org/redir.php?target=wme 26 * Copyright (c) 2003-2013 Jan Nedoma and contributors 27 */ 28 29 #ifndef WINTERMUTE_AD_SCENE_GEOMETRY_H 30 #define WINTERMUTE_AD_SCENE_GEOMETRY_H 31 32 #include "engines/wintermute/base/base_object.h" 33 #include "engines/wintermute/math/rect32.h" 34 #include "math/matrix4.h" 35 #include "math/vector3d.h" 36 37 namespace Wintermute { 38 39 class BaseSprite; 40 class Camera3D; 41 class Light3D; 42 class Block3D; 43 class AdGeneric; 44 class AdBlock; 45 class AdWalkplane; 46 class AdPath3D; 47 class AdWaypointGroup3D; 48 class AdGeomExt; 49 class AdPathPoint3D; 50 51 class AdSceneGeometry : public BaseObject { 52 public: 53 bool _maxLightsWarning; 54 bool dropWaypoints(); 55 bool setLightColor(const char *lightName, uint32 color); 56 uint32 getLightColor(const char *lightName); 57 Math::Vector3d getLightPos(const char *lightName); 58 bool enableNode(const char *nodeName, bool enable = true); 59 bool isNodeEnabled(const char *nodeName); 60 bool enableLight(const char *lightName, bool enable = true); 61 bool isLightEnabled(const char *lightName); 62 DECLARE_PERSISTENT(AdSceneGeometry, BaseObject) 63 bool correctTargetPoint(const Math::Vector3d &source, Math::Vector3d *target); 64 65 bool _lastValuesInitialized; 66 Math::Matrix4 _lastWorldMat; 67 Math::Matrix4 _lastViewMat; 68 Math::Matrix4 _lastProjMat; 69 int _lastOffsetX; 70 int _lastOffsetY; 71 Rect32 _drawingViewport; 72 int _lastScrollX; 73 int _lastScrollY; 74 75 bool createLights(); 76 bool enableLights(Math::Vector3d Point, BaseArray<char *> &IgnoreLights); 77 78 bool initLoop(); 79 float getPointsDist(Math::Vector3d p1, Math::Vector3d p2); 80 void pathFinderStep(); 81 bool getPath(Math::Vector3d source, Math::Vector3d target, AdPath3D *path, bool rerun = false); 82 bool convert2Dto3D(int x, int y, Math::Vector3d *pos); 83 bool convert2Dto3DTolerant(int x, int y, Math::Vector3d *pos); 84 bool convert3Dto2D(Math::Vector3d *pos, int32 *x, int32 *y); 85 BaseSprite *_wptMarker; 86 float _waypointHeight; 87 bool directPathExists(Math::Vector3d *p1, Math::Vector3d *p2); 88 float getHeightAt(Math::Vector3d pos, float Ttlerance = 0.0f, bool *intFound = NULL); 89 90 bool storeDrawingParams(); 91 bool render(bool render); 92 bool renderShadowGeometry(); 93 94 Math::Matrix4 *getViewMatrix(); 95 Math::Matrix4 _viewMatrix; 96 bool setActiveCamera(const char *camera, float fov, float nearClipPlane, float farClipPlane); 97 bool setActiveCamera(int camera, float fow, float nearClipPlane, float farClipPlane); 98 //bool SetActiveCameraTwin(char* Camera); 99 //bool SetActiveCameraTwin(int Camera); 100 Camera3D *getActiveCamera(); 101 int32 _activeCamera; 102 103 bool setActiveLight(char *light); 104 bool setActiveLight(int light); 105 int32 _activeLight; 106 107 void cleanup(); 108 AdSceneGeometry(BaseGame *inGame); 109 virtual ~AdSceneGeometry(); 110 bool loadFile(const char *filename); 111 BaseArray<AdWalkplane *> _planes; 112 BaseArray<AdBlock *> _blocks; 113 BaseArray<AdGeneric *> _generics; 114 BaseArray<Camera3D *> _cameras; 115 BaseArray<Light3D *> _lights; 116 BaseArray<AdWaypointGroup3D *> _waypointGroups; 117 uint32 _PFMaxTime; 118 119 private: 120 AdGeomExt *getGeometryExtension(char *filename); 121 Math::Vector3d getBlockIntersection(Math::Vector3d *p1, Math::Vector3d *p2); 122 bool _PFReady; 123 Math::Vector3d _PFSource; 124 Math::Vector3d _PFTarget; 125 AdPath3D *_PFTargetPath; 126 Math::Vector3d _PFAlternateTarget; 127 float _PFAlternateDist; 128 bool _PFRerun; 129 BaseArray<AdPathPoint3D *> _PFPath; 130 }; 131 132 } // namespace Wintermute 133 134 #endif 135