1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Patrick Boenzli |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SPATIAL_SEPARATION |
---|
17 | |
---|
18 | #include "spatial_separation.h" |
---|
19 | #include "abstract_model.h" |
---|
20 | #include "quadtree.h" |
---|
21 | |
---|
22 | using namespace std; |
---|
23 | |
---|
24 | |
---|
25 | /** |
---|
26 | * standard constructor |
---|
27 | * @param model the model that is to be separated |
---|
28 | * @param overlapSize each box will overlap for a given size |
---|
29 | |
---|
30 | The boxes are overlaping because this makes collision detection a lot simpler |
---|
31 | |
---|
32 | */ |
---|
33 | SpatialSeparation::SpatialSeparation (AbstractModel* model, float overlapSize) |
---|
34 | { |
---|
35 | PRINTF(0)("Spatial Separation process kicked on\n"); |
---|
36 | this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation"); |
---|
37 | /* debug vice */ |
---|
38 | this->createQuadtree(model); |
---|
39 | } |
---|
40 | |
---|
41 | /** |
---|
42 | * standard constructor |
---|
43 | * @param model the model that is to be separated |
---|
44 | * @param overlapSize each box will overlap for a given size |
---|
45 | |
---|
46 | The boxes are overlaping because this makes collision detection a lot simpler |
---|
47 | |
---|
48 | */ |
---|
49 | SpatialSeparation::SpatialSeparation (AbstractModel* model, AbstractModel* playerModel) |
---|
50 | { |
---|
51 | this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation"); |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | /** |
---|
57 | * standard deconstructor |
---|
58 | |
---|
59 | */ |
---|
60 | SpatialSeparation::~SpatialSeparation () |
---|
61 | { |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | /** |
---|
66 | \brief creates a quadtree |
---|
67 | * @param model the model to do a quadtree on |
---|
68 | * @param minLength the minimal length of a quadtree node |
---|
69 | \return the new quadtree |
---|
70 | */ |
---|
71 | Quadtree* SpatialSeparation::createQuadtree(AbstractModel* model, float minLength) |
---|
72 | { |
---|
73 | this->minLength = minLength; |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | /** |
---|
79 | \brief creates a quadtree |
---|
80 | * @param model the model to do a quadtree on |
---|
81 | * @param minLength the minimal length of a quadtree node |
---|
82 | \return the new quadtree |
---|
83 | */ |
---|
84 | Quadtree* SpatialSeparation::createQuadtree(AbstractModel* model, int treeDepth) |
---|
85 | { |
---|
86 | this->treeDepth = treeDepth; |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | /** |
---|
91 | \brief creates a quadtree |
---|
92 | * @param model the model to do a quadtree on |
---|
93 | * @param minLength the minimal length of a quadtree node |
---|
94 | \return the new quadtree |
---|
95 | */ |
---|
96 | Quadtree* SpatialSeparation::createQuadtree(AbstractModel* model) |
---|
97 | { |
---|
98 | this->quadtree = new Quadtree(model->getModelInfo()); |
---|
99 | this->quadtree->separate(); |
---|
100 | |
---|
101 | return this->quadtree; |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | |
---|
111 | |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | |
---|