1 /* bzflag
2  * Copyright (c) 1993-2021 Tim Riker
3  *
4  * This package is free software;  you can redistribute it and/or
5  * modify it under the terms of the license found in the file
6  * named COPYING that should have accompanied this file.
7  *
8  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
9  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
10  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11  */
12 
13 /* BoxBuilding:
14  *  Encapsulates a box in the game environment.
15  */
16 
17 #ifndef BZF_BOX_BUILDING_H
18 #define BZF_BOX_BUILDING_H
19 
20 #include "common.h"
21 #include <string>
22 #include "Obstacle.h"
23 
24 class BoxBuilding : public Obstacle
25 {
26 public:
27     BoxBuilding();
28     BoxBuilding(const float* pos, float rotation,
29                 float width, float breadth, float height,
30                 bool drive = false, bool shoot = false,
31                 bool ricochet = false, bool invisible = false);
32     ~BoxBuilding();
33 
34     Obstacle*       copyWithTransform(const MeshTransform&) const;
35 
36     const char*     getType() const;
37     static const char*  getClassName(); // const
38 
39     bool        isFlatTop() const;
40 
41     float       intersect(const Ray&) const;
42     void        getNormal(const float* p, float* n) const;
43     void        get3DNormal(const float* p, float* n) const;
44     inline bool  isInvisible() const;
45 
46     bool        inCylinder(const float* p, float radius, float height) const;
47     bool        inBox(const float* p, float angle,
48                       float halfWidth, float halfBreadth, float height) const;
49     bool        inMovingBox(const float* oldP, float oldAngle,
50                             const float *newP, float newAngle,
51                             float halfWidth, float halfBreadth, float height) const;
52     bool        isCrossing(const float* p, float angle,
53                            float halfWidth, float halfBreadth, float height,
54                            float* plane) const;
55 
56     bool        getHitNormal(
57         const float* pos1, float azimuth1,
58         const float* pos2, float azimuth2,
59         float halfWidth, float halfBreadth,
60         float height,
61         float* normal) const;
62 
63     void        getCorner(int index, float* pos) const;
64 
65     int packSize() const;
66     void *pack(void*) const;
67     const void *unpack(const void*);
68 
69     void print(std::ostream& out, const std::string& indent) const;
70     void printOBJ(std::ostream& out, const std::string& indent) const;
71 
72     std::string userTextures[2];
73 
74 private:
75     void finalize();
76 
77 private:
78     static const char*   typeName;
79     bool noNodes;
80 };
81 
82 
83 //
84 // BoxBuilding
85 //
86 
isInvisible()87 bool BoxBuilding::isInvisible() const
88 {
89     return noNodes;
90 }
91 
92 
93 #endif // BZF_BOX_BUILDING_H
94 
95 // Local Variables: ***
96 // mode: C++ ***
97 // tab-width: 4 ***
98 // c-basic-offset: 4 ***
99 // indent-tabs-mode: nil ***
100 // End: ***
101 // ex: shiftwidth=4 tabstop=4
102