forked from eu07/maszyna
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGeom.cpp
127 lines (107 loc) · 3.79 KB
/
Geom.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "system.hpp"
#include "classes.hpp"
#include <gl/gl.h>
#include <gl/glu.h>
#include "opengl/glut.h"
#pragma hdrstop
#include "Texture.h"
#include "usefull.h"
#include "Globals.h"
#include "Geom.h"
__fastcall TGeometry::TGeometry()
{
}
__fastcall TGeometry::~TGeometry()
{
}
bool TGeometry::Init()
{
}
vector3 TGeometry::Load(TQueryParserComp *Parser)
{
str = Parser->GetNextSymbol().LowerCase();
tmp->TextureID = TTexturesManager::GetTextureID(str.c_str());
i = 0;
do
{
tf = Parser->GetNextSymbol().ToDouble();
TempVerts[i].Point.x = tf;
tf = Parser->GetNextSymbol().ToDouble();
TempVerts[i].Point.y = tf;
tf = Parser->GetNextSymbol().ToDouble();
TempVerts[i].Point.z = tf;
tf = Parser->GetNextSymbol().ToDouble();
TempVerts[i].Normal.x = tf;
tf = Parser->GetNextSymbol().ToDouble();
TempVerts[i].Normal.y = tf;
tf = Parser->GetNextSymbol().ToDouble();
TempVerts[i].Normal.z = tf;
str = Parser->GetNextSymbol().LowerCase();
if (str == "x")
TempVerts[i].tu = (TempVerts[i].Point.x + Parser->GetNextSymbol().ToDouble()) /
Parser->GetNextSymbol().ToDouble();
else if (str == "y")
TempVerts[i].tu = (TempVerts[i].Point.y + Parser->GetNextSymbol().ToDouble()) /
Parser->GetNextSymbol().ToDouble();
else if (str == "z")
TempVerts[i].tu = (TempVerts[i].Point.z + Parser->GetNextSymbol().ToDouble()) /
Parser->GetNextSymbol().ToDouble();
else
TempVerts[i].tu = str.ToDouble();
;
str = Parser->GetNextSymbol().LowerCase();
if (str == "x")
TempVerts[i].tv = (TempVerts[i].Point.x + Parser->GetNextSymbol().ToDouble()) /
Parser->GetNextSymbol().ToDouble();
else if (str == "y")
TempVerts[i].tv = (TempVerts[i].Point.y + Parser->GetNextSymbol().ToDouble()) /
Parser->GetNextSymbol().ToDouble();
else if (str == "z")
TempVerts[i].tv = (TempVerts[i].Point.z + Parser->GetNextSymbol().ToDouble()) /
Parser->GetNextSymbol().ToDouble();
else
TempVerts[i].tv = str.ToDouble();
;
// tf= Parser->GetNextSymbol().ToDouble();
// TempVerts[i].tu= tf;
// tf= Parser->GetNextSymbol().ToDouble();
// TempVerts[i].tv= tf;
TempVerts[i].Point.RotateZ(aRotate.z / 180 * M_PI);
TempVerts[i].Point.RotateX(aRotate.x / 180 * M_PI);
TempVerts[i].Point.RotateY(aRotate.y / 180 * M_PI);
TempVerts[i].Normal.RotateZ(aRotate.z / 180 * M_PI);
TempVerts[i].Normal.RotateX(aRotate.x / 180 * M_PI);
TempVerts[i].Normal.RotateY(aRotate.y / 180 * M_PI);
TempVerts[i].Point += pOrigin;
tmp->pCenter += TempVerts[i].Point;
i++;
// }
} while (Parser->GetNextSymbol().LowerCase() != "endtri");
nv = i;
tmp->Init(nv);
tmp->pCenter /= (nv > 0 ? nv : 1);
// memcpy(tmp->Vertices,TempVerts,nv*sizeof(TGroundVertex));
r = 0;
for (int i = 0; i < nv; i++)
{
tmp->Vertices[i] = TempVerts[i];
tf = SquareMagnitude(tmp->Vertices[i].Point - tmp->pCenter);
if (tf > r)
r = tf;
}
// tmp->fSquareRadius= 2000*2000+r;
tmp->fSquareRadius += r;
}
bool TGeometry::Render()
{
}
//---------------------------------------------------------------------------
#pragma package(smart_init)