]> git.jsancho.org Git - lugaru.git/blob - Source/Objects/Object.hpp
d1a86a8198c1575ffb3595fd4d501e017c4891c7
[lugaru.git] / Source / Objects / Object.hpp
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
4
5 This file is part of Lugaru.
6
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 Lugaru 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 Lugaru.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _OBJECTS_HPP_
22 #define _OBJECTS_HPP_
23
24 #include "Environment/Lights.hpp"
25 #include "Environment/Terrain.hpp"
26 #include "Graphic/gamegl.hpp"
27 #include "Graphic/Models.hpp"
28 #include "Graphic/Sprite.hpp"
29 #include "Graphic/Texture.hpp"
30 #include "Math/Frustum.hpp"
31 #include "Math/XYZ.hpp"
32 #include "Utils/ImageIO.hpp"
33
34 #include <memory>
35 #include <vector>
36 //
37 // Model Structures
38 //
39
40 #define max_objects 300
41
42 enum object_type {
43     boxtype = 0,
44     weirdtype = 1,
45     spiketype = 2,
46     treetrunktype = 3,
47     treeleavestype = 4,
48     bushtype = 5,
49     rocktype = 6,
50     walltype = 7,
51     chimneytype = 8,
52     platformtype = 9,
53     tunneltype = 11,
54     cooltype = 12,
55     firetype = 13
56 };
57
58
59 class Object
60 {
61 public:
62     static std::vector<std::unique_ptr<Object>> objects;
63     static XYZ center;
64     static float radius;
65     static Texture boxtextureptr;
66     static Texture treetextureptr;
67     static Texture bushtextureptr;
68     static Texture rocktextureptr;
69
70     XYZ position;
71     object_type type;
72     float yaw;
73     float pitch;
74     float rotx;
75     float rotxvel;
76     float roty;
77     float rotyvel;
78     bool possible;
79     Model model;
80     Model displaymodel;
81     float friction;
82     float scale;
83     float messedwith;
84     float checked;
85     float shadowed;
86     float occluded;
87     bool onfire;
88     float flamedelay;
89
90     Object();
91     Object(object_type _type, XYZ _position, float _yaw, float _pitch, float _scale);
92
93     static void ComputeCenter();
94     static void ComputeRadius();
95     static void AddObjectsToTerrain();
96     static void LoadObjectsFromFile(FILE* tfile, bool skip);
97     static void SphereCheckPossible(XYZ *p1, float radius);
98     static void DeleteObject(int which);
99     static void MakeObject(int atype, XYZ where, float ayaw, float apitch, float ascale);
100     static void Draw();
101     static void DoShadows();
102     static void DoStuff();
103     static int checkcollide(XYZ startpoint, XYZ endpoint);
104     static int checkcollide(XYZ startpoint, XYZ endpoint, int what);
105
106 private:
107     void handleFire();
108     void handleRot(int divide);
109     void doShadows(XYZ lightloc);
110     void draw();
111     void drawSecondPass();
112     void addToTerrain(unsigned id);
113     static int checkcollide(XYZ startpoint, XYZ endpoint, int what, float minx, float miny, float minz, float maxx, float maxy, float maxz);
114 };
115
116 #endif
117