]> git.jsancho.org Git - lugaru.git/blob - Source/Objects/Object.hpp
Moved checkcollide methods in Object
[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/Quaternions.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 #define boxtype 0
43 #define weirdtype 1
44 #define spiketype 2
45 #define treetrunktype 3
46 #define treeleavestype 4
47 #define bushtype 5
48 #define rocktype 6
49 #define walltype 7
50 #define chimneytype 8
51 #define platformtype 9
52 #define tunneltype 11
53 #define cooltype 12
54 #define firetype 13
55
56
57 class Object
58 {
59 public:
60     static std::vector<std::unique_ptr<Object>> objects;
61     static XYZ center;
62     static float radius;
63     static Texture boxtextureptr;
64     static Texture treetextureptr;
65     static Texture bushtextureptr;
66     static Texture rocktextureptr;
67
68     XYZ position;
69     int type;
70     float yaw;
71     float pitch;
72     float rotx;
73     float rotxvel;
74     float roty;
75     float rotyvel;
76     bool possible;
77     Model model;
78     Model displaymodel;
79     float friction;
80     float scale;
81     float messedwith;
82     float checked;
83     float shadowed;
84     float occluded;
85     bool onfire;
86     float flamedelay;
87
88     Object();
89     Object(int _type, XYZ _position, float _yaw, float _pitch, float _scale);
90
91     static void ComputeCenter();
92     static void ComputeRadius();
93     static void AddObjectsToTerrain();
94     static void LoadObjectsFromFile(FILE* tfile, bool skip);
95     static void SphereCheckPossible(XYZ *p1, float radius);
96     static void DeleteObject(int which);
97     static void MakeObject(int atype, XYZ where, float ayaw, float apitch, float ascale);
98     static void Draw();
99     static void DoShadows();
100     static void DoStuff();
101     static int checkcollide(XYZ startpoint, XYZ endpoint);
102     static int checkcollide(XYZ startpoint, XYZ endpoint, int what);
103
104 private:
105     void handleFire();
106     void doShadows(XYZ lightloc);
107     void draw();
108     void drawSecondPass();
109     void addToTerrain(unsigned id);
110     static int checkcollide(XYZ startpoint, XYZ endpoint, int what, float minx, float miny, float minz, float maxx, float maxy, float maxz);
111 };
112
113 #endif
114