• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: Example
4
5import flatbuffers
6from flatbuffers.compat import import_numpy
7np = import_numpy()
8
9class Vec3(object):
10    __slots__ = ['_tab']
11
12    # Vec3
13    def Init(self, buf, pos):
14        self._tab = flatbuffers.table.Table(buf, pos)
15
16    # Vec3
17    def X(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0))
18    # Vec3
19    def Y(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4))
20    # Vec3
21    def Z(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(8))
22    # Vec3
23    def Test1(self): return self._tab.Get(flatbuffers.number_types.Float64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(16))
24    # Vec3
25    def Test2(self): return self._tab.Get(flatbuffers.number_types.Uint8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(24))
26    # Vec3
27    def Test3(self, obj):
28        obj.Init(self._tab.Bytes, self._tab.Pos + 26)
29        return obj
30
31
32def CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b):
33    builder.Prep(8, 32)
34    builder.Pad(2)
35    builder.Prep(2, 4)
36    builder.Pad(1)
37    builder.PrependInt8(test3_b)
38    builder.PrependInt16(test3_a)
39    builder.Pad(1)
40    builder.PrependUint8(test2)
41    builder.PrependFloat64(test1)
42    builder.Pad(4)
43    builder.PrependFloat32(z)
44    builder.PrependFloat32(y)
45    builder.PrependFloat32(x)
46    return builder.Offset()
47
48import MyGame.Example.Test
49try:
50    from typing import Optional
51except:
52    pass
53
54class Vec3T(object):
55
56    # Vec3T
57    def __init__(self):
58        self.x = 0.0  # type: float
59        self.y = 0.0  # type: float
60        self.z = 0.0  # type: float
61        self.test1 = 0.0  # type: float
62        self.test2 = 0  # type: int
63        self.test3 = None  # type: Optional[MyGame.Example.Test.TestT]
64
65    @classmethod
66    def InitFromBuf(cls, buf, pos):
67        vec3 = Vec3()
68        vec3.Init(buf, pos)
69        return cls.InitFromObj(vec3)
70
71    @classmethod
72    def InitFromObj(cls, vec3):
73        x = Vec3T()
74        x._UnPack(vec3)
75        return x
76
77    # Vec3T
78    def _UnPack(self, vec3):
79        if vec3 is None:
80            return
81        self.x = vec3.X()
82        self.y = vec3.Y()
83        self.z = vec3.Z()
84        self.test1 = vec3.Test1()
85        self.test2 = vec3.Test2()
86        if vec3.Test3(MyGame.Example.Test.Test()) is not None:
87            self.test3 = MyGame.Example.Test.TestT.InitFromObj(vec3.Test3(MyGame.Example.Test.Test()))
88
89    # Vec3T
90    def Pack(self, builder):
91        return CreateVec3(builder, self.x, self.y, self.z, self.test1, self.test2, self.test3.a, self.test3.b)
92