-
Notifications
You must be signed in to change notification settings - Fork 1
/
Terrain.py
72 lines (56 loc) · 2.1 KB
/
Terrain.py
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
from Obj3D import *
class Ground(Obj3D):
def __init__(self, gameObj, model, renderParent=None, pos=None, hpr=None):
super().__init__(model, renderParent, pos, hpr)
self.gameObj = gameObj
if model == "ground":
self.setScale(scaleX=0.1, scaleY=0.02)
self.move(dz=self.dimZ/2)
args = {
"padding": (0, 0, 0.01)
}
self.initSurroundingCollisionObj("floor", args=args, show=False)
colNode = self.getCollisionNode("floor")
colNode.node().setIntoCollideMask(self.gameObj.colBitMask["floor"])
colNode.node().setFromCollideMask(self.gameObj.colBitMask["off"])
# Make bottom extra big
padZ = 10
'''
colBox = CollisionBox(
# center is padZ below the floor
(self.relOffsetX, self.relOffsetY, self.relOffsetZ - padZ),
# dx, dy, dz
self.relDimX/2, self.relDimY/2, self.relDimZ/2 + padZ
)
colPlane = CollisionPlane(
Plane(Vec3(0, 0, 1), Point3(self.relativeOffset))
)
colNode = self.createIsolatedCollisionObj(
"floor", colPlane,
fromBitmask=self.gameObj.colBitMask["off"], intoBitmask=self.gameObj.colBitMask["floor"],
show = True
)
'''
class Terrain():
def __init__(self, gameObj):
self.gameObj = gameObj
racetrack = self.gameObj.racetrack
# Load infinitely extending floor
'''
planeSolid = CollisionPlane(
Plane(Vec3(0, 0, 1), Point3(0, 0, 0))
)
floorPlane = Obj3D.createIsolatedCollisionObj(
"floor", planeSolid, intoBitmask=self.gameObj.colBitMask["floor"]
)
'''
# Load ground
#self.ground = Ground(self.gameObj, "ground")
#self.ground.setScale(scaleX=1.5, scaleY=1.5)
_, angles = racetrack.leftTrackPoints[0]
pos = racetrack.points[0]
self.startLine = Ground(self.gameObj, "cornfield", pos=pos)
self.startLine.rotate(
dh=angles[0], dp=angles[1])
# Sky
#self.sky = Obj3D("FarmSky")