1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
|
|
|
4
|
1 |
|
from il2fb.commons.spatial import Point3D |
5
|
1 |
|
from il2fb.commons.structures import BaseStructure |
6
|
|
|
|
7
|
1 |
|
from ..converters import to_belligerent |
8
|
1 |
|
from . import CollectingParser |
9
|
|
|
|
10
|
|
|
|
11
|
1 |
|
class StaticCamera(BaseStructure): |
12
|
1 |
|
__slots__ = ['belligerent', 'pos', ] |
13
|
|
|
|
14
|
1 |
|
def __init__(self, belligerent, pos): |
15
|
1 |
|
self.belligerent = belligerent |
16
|
1 |
|
self.pos = pos |
17
|
|
|
|
18
|
1 |
|
def __repr__(self): |
19
|
1 |
|
return ( |
20
|
|
|
"<StaticCamera '{0};{1};{2}'>" |
21
|
|
|
.format(self.pos.x, self.pos.y, self.pos.z) |
22
|
|
|
) |
23
|
|
|
|
24
|
|
|
|
25
|
1 |
|
class StaticCameraParser(CollectingParser): |
26
|
|
|
""" |
27
|
|
|
Parses ``StaticCamera`` section. |
28
|
|
|
View :ref:`detailed description <static-camera-section>`. |
29
|
|
|
""" |
30
|
|
|
|
31
|
1 |
|
def check_section_name(self, section_name): |
32
|
1 |
|
return section_name == "StaticCamera" |
33
|
|
|
|
34
|
1 |
|
def parse_line(self, line): |
35
|
1 |
|
pos_x, pos_y, pos_z, belligerent = line.split() |
36
|
1 |
|
self.data.append(StaticCamera( |
37
|
|
|
belligerent=to_belligerent(belligerent), |
38
|
|
|
pos=Point3D(pos_x, pos_y, pos_z), |
39
|
|
|
)) |
40
|
|
|
|
41
|
1 |
|
def clean(self): |
42
|
|
|
return {'cameras': self.data, } |
43
|
|
|
|