ogre-python 14.5.0__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Ogre/Bites.py +14 -0
- Ogre/Bullet.py +14 -0
- Ogre/Codec_Assimp.dll +0 -0
- Ogre/Codec_STBI.dll +0 -0
- Ogre/HighPy.py +389 -0
- Ogre/ImGui.py +12 -0
- Ogre/Numpy.py +80 -0
- Ogre/Ogre.py +12 -0
- Ogre/OgreBites.dll +0 -0
- Ogre/OgreBullet.dll +0 -0
- Ogre/OgreMain.dll +0 -0
- Ogre/OgreOverlay.dll +0 -0
- Ogre/OgrePaging.dll +0 -0
- Ogre/OgreRTShaderSystem.dll +0 -0
- Ogre/OgreTerrain.dll +0 -0
- Ogre/Overlay.py +14 -0
- Ogre/Plugin_DotScene.dll +0 -0
- Ogre/Plugin_GLSLangProgramManager.dll +0 -0
- Ogre/Plugin_OctreeSceneManager.dll +0 -0
- Ogre/Plugin_ParticleFX.dll +0 -0
- Ogre/RTShader.py +14 -0
- Ogre/RenderSystem_Direct3D11.dll +0 -0
- Ogre/RenderSystem_GL.dll +0 -0
- Ogre/RenderSystem_GL3Plus.dll +0 -0
- Ogre/RenderSystem_GLES2.dll +0 -0
- Ogre/RenderSystem_Tiny.dll +0 -0
- Ogre/RenderSystem_Vulkan.dll +0 -0
- Ogre/SDL2.dll +0 -0
- Ogre/Terrain.py +14 -0
- Ogre/_Bites.pyd +0 -0
- Ogre/_Bullet.pyd +0 -0
- Ogre/_ImGui.pyd +0 -0
- Ogre/_Ogre.pyd +0 -0
- Ogre/_Overlay.pyd +0 -0
- Ogre/_RTShader.pyd +0 -0
- Ogre/_Terrain.pyd +0 -0
- Ogre/__init__.py +2 -0
- Ogre/zlib.dll +0 -0
- ogre_python-14.5.0.data/data/Media/Main/DefaultShaders.metal +38 -0
- ogre_python-14.5.0.data/data/Media/Main/GLSL_GL3Support.glsl +110 -0
- ogre_python-14.5.0.data/data/Media/Main/HLSL_SM4Support.hlsl +124 -0
- ogre_python-14.5.0.data/data/Media/Main/OgreUnifiedShader.h +201 -0
- ogre_python-14.5.0.data/data/Media/Main/Shadow.material +85 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowBlend.frag +11 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowBlend.vert +12 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowExtrudeDirLight.vert +18 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowExtrudeDirLightFinite.vert +22 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowExtrudePointLight.vert +19 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowExtrudePointLightFinite.vert +22 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowVolumeExtude.program +41 -0
- ogre_python-14.5.0.data/data/Media/Main/spot_shadow_fade.dds +0 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/FFPLib_AlphaTest.glsl +45 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/FFPLib_Fog.glsl +92 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/FFPLib_Texturing.glsl +150 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/FFPLib_Transform.glsl +100 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSLib_Colour.glsl +16 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSLib_IBL.glsl +90 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSLib_LTC.glsl +114 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSLib_Lighting.glsl +18 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSSamplers.material +18 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_CookTorrance.glsl +238 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_DualQuaternion.glsl +172 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_IntegratedPSSM.glsl +198 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_LayeredBlending.glsl +825 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_NormalMap.glsl +125 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_PerPixelLighting.glsl +183 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_TriplanarTexturing.glsl +47 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_WBOIT.glsl +19 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/dfgLUTmultiscatter.dds +0 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/ltc_1.dds +0 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/ltc_2.dds +0 -0
- ogre_python-14.5.0.data/data/Media/Terrain/TerrainSurface.glsl +91 -0
- ogre_python-14.5.0.data/data/Media/Terrain/TerrainTransforms.glsl +36 -0
- ogre_python-14.5.0.data/data/Media/packs/SdkTrays.zip +0 -0
- ogre_python-14.5.0.data/data/Media/packs/profiler.zip +0 -0
- ogre_python-14.5.0.data/data/bin/plugins.cfg +27 -0
- ogre_python-14.5.0.data/data/bin/resources.cfg +12 -0
- ogre_python-14.5.0.dist-info/METADATA +148 -0
- ogre_python-14.5.0.dist-info/RECORD +83 -0
- ogre_python-14.5.0.dist-info/WHEEL +5 -0
- ogre_python-14.5.0.dist-info/licenses/AUTHORS +313 -0
- ogre_python-14.5.0.dist-info/licenses/LICENSE +21 -0
- ogre_python-14.5.0.dist-info/top_level.txt +1 -0
Ogre/Bites.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
|
2
|
+
# Version 4.4.1
|
|
3
|
+
#
|
|
4
|
+
# Do not make changes to this file unless you know what you are doing - modify
|
|
5
|
+
# the SWIG interface file instead.
|
|
6
|
+
|
|
7
|
+
from sys import version_info as _swig_python_version_info
|
|
8
|
+
import Ogre.Ogre
|
|
9
|
+
|
|
10
|
+
# Pull in all the attributes from the low-level C/C++ module
|
|
11
|
+
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
|
|
12
|
+
from ._Bites import *
|
|
13
|
+
else:
|
|
14
|
+
from _Bites import *
|
Ogre/Bullet.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
|
2
|
+
# Version 4.4.1
|
|
3
|
+
#
|
|
4
|
+
# Do not make changes to this file unless you know what you are doing - modify
|
|
5
|
+
# the SWIG interface file instead.
|
|
6
|
+
|
|
7
|
+
from sys import version_info as _swig_python_version_info
|
|
8
|
+
import Ogre.Ogre
|
|
9
|
+
|
|
10
|
+
# Pull in all the attributes from the low-level C/C++ module
|
|
11
|
+
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
|
|
12
|
+
from ._Bullet import *
|
|
13
|
+
else:
|
|
14
|
+
from _Bullet import *
|
Ogre/Codec_Assimp.dll
ADDED
|
Binary file
|
Ogre/Codec_STBI.dll
ADDED
|
Binary file
|
Ogre/HighPy.py
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# This file is part of the OGRE project.
|
|
2
|
+
# It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
+
# of this distribution and at https://www.ogre3d.org/licensing.
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import math
|
|
8
|
+
|
|
9
|
+
import Ogre
|
|
10
|
+
import Ogre.Bites
|
|
11
|
+
import Ogre.RTShader
|
|
12
|
+
import Ogre.Overlay
|
|
13
|
+
|
|
14
|
+
## \cond PRIVATE
|
|
15
|
+
|
|
16
|
+
class _InputListener(Ogre.Bites.InputListener):
|
|
17
|
+
def __init__(self, window_data):
|
|
18
|
+
Ogre.Bites.InputListener.__init__(self)
|
|
19
|
+
self.window_data = window_data
|
|
20
|
+
|
|
21
|
+
def keyPressed(self, evt):
|
|
22
|
+
self.window_data.last_key = evt.keysym.sym
|
|
23
|
+
return True
|
|
24
|
+
|
|
25
|
+
class _ImGuiDispatcher(Ogre.RenderTargetListener):
|
|
26
|
+
def __init__(self, callback):
|
|
27
|
+
Ogre.RenderTargetListener.__init__(self)
|
|
28
|
+
self.callback = callback
|
|
29
|
+
|
|
30
|
+
def preRenderTargetUpdate(self, _):
|
|
31
|
+
Ogre.Overlay.ImGuiOverlay.NewFrame()
|
|
32
|
+
self.callback()
|
|
33
|
+
|
|
34
|
+
class _WindowData:
|
|
35
|
+
def __init__(self, window):
|
|
36
|
+
self.window = window.render
|
|
37
|
+
self.camera = None
|
|
38
|
+
self.scn_mgr = None
|
|
39
|
+
self.background = None
|
|
40
|
+
self.last_key = 0
|
|
41
|
+
|
|
42
|
+
self._input_listener = None
|
|
43
|
+
self._native = window.native
|
|
44
|
+
|
|
45
|
+
def listen_to_input(self):
|
|
46
|
+
assert self._input_listener is None
|
|
47
|
+
self._input_listener = _InputListener(self)
|
|
48
|
+
_ctx.addInputListener(self._native, self._input_listener)
|
|
49
|
+
|
|
50
|
+
class _Application(Ogre.Bites.ApplicationContext):
|
|
51
|
+
def __init__(self):
|
|
52
|
+
# warnings and errors only
|
|
53
|
+
if not os.environ.get("OGRE_MIN_LOGLEVEL"):
|
|
54
|
+
os.environ["OGRE_MIN_LOGLEVEL"] = "3"
|
|
55
|
+
|
|
56
|
+
Ogre.Bites.ApplicationContext.__init__(self, "OgreHighPy")
|
|
57
|
+
|
|
58
|
+
self.name = None
|
|
59
|
+
self.imsize = None
|
|
60
|
+
self.imgui_dispatcher = None
|
|
61
|
+
|
|
62
|
+
self.windows = {}
|
|
63
|
+
|
|
64
|
+
self.createRoot()
|
|
65
|
+
|
|
66
|
+
def createWindow(self, name, w, h, *_args):
|
|
67
|
+
if not self.windows:
|
|
68
|
+
name = self.name
|
|
69
|
+
w, h = self.imsize
|
|
70
|
+
|
|
71
|
+
misc = Ogre.NameValueMap()
|
|
72
|
+
ret = Ogre.Bites.ApplicationContext.createWindow(self, name, w, h, misc)
|
|
73
|
+
self.windows[name] = _WindowData(ret)
|
|
74
|
+
return ret
|
|
75
|
+
|
|
76
|
+
def createRoot(self):
|
|
77
|
+
if self.getRoot():
|
|
78
|
+
return
|
|
79
|
+
Ogre.Bites.ApplicationContext.createRoot(self)
|
|
80
|
+
|
|
81
|
+
rgm = Ogre.ResourceGroupManager.getSingleton()
|
|
82
|
+
assert isinstance(user_resource_locations, set)
|
|
83
|
+
if not user_resource_locations:
|
|
84
|
+
rgm.addResourceLocation(".", "FileSystem", Ogre.RGN_DEFAULT, True)
|
|
85
|
+
|
|
86
|
+
for loc in user_resource_locations:
|
|
87
|
+
rgm.addResourceLocation(str(loc), "FileSystem", Ogre.RGN_DEFAULT)
|
|
88
|
+
|
|
89
|
+
def oneTimeConfig(self):
|
|
90
|
+
self.getRoot().restoreConfig()
|
|
91
|
+
rs = self.getRoot().getRenderSystemByName("OpenGL 3+ Rendering Subsystem")
|
|
92
|
+
self.getRoot().setRenderSystem(rs)
|
|
93
|
+
self.getRoot().saveConfig()
|
|
94
|
+
return True
|
|
95
|
+
|
|
96
|
+
def _create_image_background(scn_mgr, name):
|
|
97
|
+
tex = Ogre.TextureManager.getSingleton().create(name, Ogre.RGN_DEFAULT, True)
|
|
98
|
+
tex.setNumMipmaps(0)
|
|
99
|
+
|
|
100
|
+
mat = Ogre.MaterialManager.getSingleton().create(name, Ogre.RGN_DEFAULT)
|
|
101
|
+
mat.getTechnique(0).getPass(0).createTextureUnitState().setTexture(tex)
|
|
102
|
+
mat.getTechnique(0).getPass(0).setDepthWriteEnabled(False)
|
|
103
|
+
mat.getTechnique(0).getPass(0).setLightingEnabled(False)
|
|
104
|
+
|
|
105
|
+
rect = scn_mgr.createScreenSpaceRect(True)
|
|
106
|
+
rect.setMaterial(mat)
|
|
107
|
+
rect.setRenderQueueGroup(Ogre.RENDER_QUEUE_BACKGROUND)
|
|
108
|
+
scn_mgr.getRootSceneNode().attachObject(rect)
|
|
109
|
+
|
|
110
|
+
return tex
|
|
111
|
+
|
|
112
|
+
_ctx = None
|
|
113
|
+
|
|
114
|
+
def _init_ogre(window_name, imsize):
|
|
115
|
+
global _ctx
|
|
116
|
+
|
|
117
|
+
_ctx = _Application()
|
|
118
|
+
_ctx.name = window_name
|
|
119
|
+
_ctx.imsize = imsize
|
|
120
|
+
_ctx.initApp()
|
|
121
|
+
|
|
122
|
+
def _init_window(window_data, flags):
|
|
123
|
+
scn_mgr = _ctx.getRoot().createSceneManager()
|
|
124
|
+
window_data.scn_mgr = scn_mgr
|
|
125
|
+
Ogre.RTShader.ShaderGenerator.getSingleton().addSceneManager(scn_mgr)
|
|
126
|
+
|
|
127
|
+
window_data.camera = scn_mgr.createCamera("camera")
|
|
128
|
+
window_data.camera.setAutoAspectRatio(True)
|
|
129
|
+
|
|
130
|
+
camnode = scn_mgr.getRootSceneNode().createChildSceneNode()
|
|
131
|
+
camnode.attachObject(window_data.camera)
|
|
132
|
+
if flags & AXES_ZFORWARD_YDOWN:
|
|
133
|
+
# convert from AXES_ZBACKWARD_YUP (Ogre default)
|
|
134
|
+
camnode.setOrientation(Ogre.Quaternion(Ogre.Math.PI, (1, 0, 0)))
|
|
135
|
+
window_data.window.addViewport(window_data.camera)
|
|
136
|
+
|
|
137
|
+
window_data.listen_to_input()
|
|
138
|
+
|
|
139
|
+
## \endcond
|
|
140
|
+
|
|
141
|
+
## \addtogroup Optional
|
|
142
|
+
# @{
|
|
143
|
+
# \addtogroup Python
|
|
144
|
+
# @{
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
## %Ogre & OpenGL coordinate system
|
|
148
|
+
AXES_ZBACKWARD_YUP = 0
|
|
149
|
+
## OpenCV & colmap coordinate system
|
|
150
|
+
AXES_ZFORWARD_YDOWN = 1
|
|
151
|
+
|
|
152
|
+
## add paths here to override the default resource location @c "."
|
|
153
|
+
user_resource_locations = set()
|
|
154
|
+
|
|
155
|
+
def window_create(window_name: str, window_size, flags: int = AXES_ZBACKWARD_YUP):
|
|
156
|
+
"""!
|
|
157
|
+
create a window
|
|
158
|
+
@param window_name: name of the window
|
|
159
|
+
@param window_size: size of the window in pixels
|
|
160
|
+
@param flags: window create options
|
|
161
|
+
"""
|
|
162
|
+
if _ctx is None:
|
|
163
|
+
_init_ogre(window_name, window_size)
|
|
164
|
+
else:
|
|
165
|
+
_ctx.createWindow(window_name, *window_size)
|
|
166
|
+
|
|
167
|
+
_init_window(_ctx.windows[window_name], flags)
|
|
168
|
+
|
|
169
|
+
def window_draw(window_name: str) -> int:
|
|
170
|
+
"""!
|
|
171
|
+
draw the window
|
|
172
|
+
@param window_name: name of the window
|
|
173
|
+
@return last key pressed inside the window
|
|
174
|
+
"""
|
|
175
|
+
assert _ctx is not None, "call window_create first"
|
|
176
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
177
|
+
_ctx.pollEvents()
|
|
178
|
+
|
|
179
|
+
window_data = _ctx.windows[window_name]
|
|
180
|
+
window_data.window.update()
|
|
181
|
+
ret = window_data.last_key
|
|
182
|
+
window_data.last_key = 0
|
|
183
|
+
return ret
|
|
184
|
+
|
|
185
|
+
def window_use_imgui(window_name: str, callback):
|
|
186
|
+
"""!
|
|
187
|
+
enable imgui for the window
|
|
188
|
+
@param window_name: name of the window
|
|
189
|
+
@param callback: function to call for imgui rendering
|
|
190
|
+
"""
|
|
191
|
+
assert _ctx is not None, "call window_create first"
|
|
192
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
193
|
+
assert _ctx.imgui_dispatcher is None, "imgui already enabled. Only one window can have imgui enabled at a time."
|
|
194
|
+
|
|
195
|
+
_ctx.imgui_dispatcher = _ImGuiDispatcher(callback)
|
|
196
|
+
|
|
197
|
+
overlay = _ctx.initialiseImGui()
|
|
198
|
+
window_data = _ctx.windows[window_name]
|
|
199
|
+
window_data.scn_mgr.addRenderQueueListener(_ctx.getOverlaySystem())
|
|
200
|
+
window_data.window.addListener(_ctx.imgui_dispatcher)
|
|
201
|
+
overlay.show()
|
|
202
|
+
_ctx.addInputListener(_ctx.getImGuiInputListener())
|
|
203
|
+
|
|
204
|
+
def window_compositor(window_name: str, compositor_name: str):
|
|
205
|
+
"""!
|
|
206
|
+
set a compositor for the window
|
|
207
|
+
@param window_name: name of the window
|
|
208
|
+
@param compositor_name: name of the compositor
|
|
209
|
+
"""
|
|
210
|
+
assert _ctx is not None, "call window_create first"
|
|
211
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
212
|
+
|
|
213
|
+
window_data = _ctx.windows[window_name]
|
|
214
|
+
|
|
215
|
+
cm = Ogre.CompositorManager.getSingleton()
|
|
216
|
+
vp = window_data.window.getViewport(0)
|
|
217
|
+
|
|
218
|
+
cm.addCompositor(vp, compositor_name)
|
|
219
|
+
cm.setCompositorEnabled(vp, compositor_name, True)
|
|
220
|
+
|
|
221
|
+
def window_pixel_data(window_name: str, compositor_name: str | None = None, texture_name: str | None = None, mrt_index: int = 0):
|
|
222
|
+
"""!
|
|
223
|
+
get the pixel data from the window or the active compositor
|
|
224
|
+
@param window_name: name of the window
|
|
225
|
+
@param compositor_name: name of the compositor
|
|
226
|
+
@param texture_name: name of the texture
|
|
227
|
+
@param mrt_index: index of the MRT
|
|
228
|
+
@retval 0: bytearray holding the pixel data
|
|
229
|
+
@retval 1: tuple `(bytes per pixel, height, width, channels)`
|
|
230
|
+
"""
|
|
231
|
+
assert _ctx is not None, "call window_create first"
|
|
232
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
233
|
+
|
|
234
|
+
window_data = _ctx.windows[window_name]
|
|
235
|
+
rtarget = window_data.window
|
|
236
|
+
dst_type = Ogre.PF_BYTE_RGB
|
|
237
|
+
|
|
238
|
+
if compositor_name:
|
|
239
|
+
cm = Ogre.CompositorManager.getSingleton()
|
|
240
|
+
chain = cm.getCompositorChain(rtarget.getViewport(0))
|
|
241
|
+
assert chain, "no active compositors"
|
|
242
|
+
inst = chain.getCompositor(compositor_name)
|
|
243
|
+
assert inst, f"no compositor named: {compositor_name}"
|
|
244
|
+
tex = inst.getTextureInstance(texture_name, mrt_index)
|
|
245
|
+
assert tex, f"no texture named: {texture_name}"
|
|
246
|
+
|
|
247
|
+
dst_type = tex.getFormat()
|
|
248
|
+
rtarget = tex.getBuffer().getRenderTarget()
|
|
249
|
+
|
|
250
|
+
if dst_type == Ogre.PF_BYTE_RGB:
|
|
251
|
+
shape = (1, rtarget.getHeight(), rtarget.getWidth(), 3)
|
|
252
|
+
elif dst_type == Ogre.PF_BYTE_RGBA:
|
|
253
|
+
shape = (1, rtarget.getHeight(), rtarget.getWidth(), 4)
|
|
254
|
+
elif dst_type == Ogre.PF_L16 or dst_type == Ogre.PF_DEPTH16:
|
|
255
|
+
shape = (2, rtarget.getHeight(), rtarget.getWidth(), 1)
|
|
256
|
+
elif dst_type == Ogre.PF_FLOAT32_R or dst_type == Ogre.PF_DEPTH32F:
|
|
257
|
+
shape = (4, rtarget.getHeight(), rtarget.getWidth(), 1)
|
|
258
|
+
else:
|
|
259
|
+
raise ValueError(f"unsupported format: {Ogre.PixelUtil.getFormatName(dst_type)}")
|
|
260
|
+
|
|
261
|
+
ret = bytearray(math.prod(shape))
|
|
262
|
+
pb = Ogre.PixelBox(shape[2], shape[1], 1, dst_type, ret)
|
|
263
|
+
rtarget.copyContentsToMemory(pb, pb)
|
|
264
|
+
|
|
265
|
+
return ret, shape
|
|
266
|
+
|
|
267
|
+
def imshow(window_name: str, img_path: str | os.PathLike):
|
|
268
|
+
"""!
|
|
269
|
+
show an image in the window
|
|
270
|
+
@param window_name: name of the window
|
|
271
|
+
@param img_path: path to the image file
|
|
272
|
+
"""
|
|
273
|
+
assert _ctx is not None, "call window_create first"
|
|
274
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
275
|
+
|
|
276
|
+
window_data = _ctx.windows[window_name]
|
|
277
|
+
if window_data.background is None:
|
|
278
|
+
window_data.background = _create_image_background(_ctx.windows[window_name].scn_mgr, window_name)
|
|
279
|
+
|
|
280
|
+
img = Ogre.Image()
|
|
281
|
+
img.load(str(img_path), Ogre.RGN_DEFAULT)
|
|
282
|
+
|
|
283
|
+
window_data.background.loadImage(img)
|
|
284
|
+
|
|
285
|
+
def camera_intrinsics(window_name: str, K, imsize):
|
|
286
|
+
"""!
|
|
287
|
+
set camera intrinsics
|
|
288
|
+
@param window_name: name of the window
|
|
289
|
+
@param K: 3x3 camera matrix
|
|
290
|
+
@param imsize: image size in pixels
|
|
291
|
+
"""
|
|
292
|
+
assert _ctx is not None, "call window_create first"
|
|
293
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
294
|
+
|
|
295
|
+
cam = _ctx.windows[window_name].camera
|
|
296
|
+
cam.setAspectRatio(imsize[0]/imsize[1])
|
|
297
|
+
|
|
298
|
+
zNear = cam.getNearClipDistance()
|
|
299
|
+
top = zNear * K[1][2] / K[1][1]
|
|
300
|
+
left = -zNear * K[0][2] / K[0][0]
|
|
301
|
+
right = zNear * (imsize[0] - K[0][2]) / K[0][0]
|
|
302
|
+
bottom = -zNear * (imsize[1] - K[1][2]) / K[1][1]
|
|
303
|
+
|
|
304
|
+
cam.setFrustumExtents(left, right, top, bottom)
|
|
305
|
+
|
|
306
|
+
fovy = math.atan2(K[1][2], K[1][1]) + math.atan2(imsize[1] - K[1][2], K[1][1])
|
|
307
|
+
cam.setFOVy(fovy)
|
|
308
|
+
|
|
309
|
+
def mesh_show(window_name: str, mesh_path: str | os.PathLike, rot_mat = None, position = (0, 0, 0), material_name: str | None = None, entity_name: str | None = None):
|
|
310
|
+
"""!
|
|
311
|
+
show a mesh in the window
|
|
312
|
+
@param window_name: name of the window
|
|
313
|
+
@param mesh_path: path to the mesh file
|
|
314
|
+
@param rot_mat: 3x3 rotation matrix
|
|
315
|
+
@param position: 3x1 translation vector
|
|
316
|
+
@param material_name: optional material name to use instead of the default
|
|
317
|
+
@param entity_name: optional entity name to allow multiple instances of the same mesh
|
|
318
|
+
"""
|
|
319
|
+
assert _ctx is not None, "call window_create first"
|
|
320
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
321
|
+
|
|
322
|
+
mesh_path = str(mesh_path)
|
|
323
|
+
scn_mgr = _ctx.windows[window_name].scn_mgr
|
|
324
|
+
|
|
325
|
+
if entity_name is None:
|
|
326
|
+
entity_name = mesh_path
|
|
327
|
+
|
|
328
|
+
if scn_mgr.hasEntity(entity_name):
|
|
329
|
+
ent = scn_mgr.getEntity(entity_name)
|
|
330
|
+
else:
|
|
331
|
+
ent = scn_mgr.createEntity(entity_name, mesh_path, Ogre.RGN_DEFAULT)
|
|
332
|
+
scn_mgr.getRootSceneNode().createChildSceneNode().attachObject(ent)
|
|
333
|
+
|
|
334
|
+
if material_name:
|
|
335
|
+
ent.setMaterialName(material_name, Ogre.RGN_DEFAULT)
|
|
336
|
+
|
|
337
|
+
scn_node = ent.getParentSceneNode()
|
|
338
|
+
ent.setVisible(True)
|
|
339
|
+
|
|
340
|
+
scn_node._update(True, False)
|
|
341
|
+
diam = scn_node._getWorldAABB().getSize().length()
|
|
342
|
+
|
|
343
|
+
cam = _ctx.windows[window_name].camera
|
|
344
|
+
cam.setNearClipDistance(min(cam.getNearClipDistance(), diam*0.01))
|
|
345
|
+
|
|
346
|
+
if rot_mat is not None:
|
|
347
|
+
flat = [v for row in rot_mat for v in row]
|
|
348
|
+
rot_mat = Ogre.Matrix3(*flat)
|
|
349
|
+
scn_node.setOrientation(Ogre.Quaternion(rot_mat))
|
|
350
|
+
|
|
351
|
+
scn_node.setPosition(position)
|
|
352
|
+
|
|
353
|
+
def mesh_hide(window_name: str, mesh_path: str | os.PathLike):
|
|
354
|
+
"""!
|
|
355
|
+
hide a mesh in the window
|
|
356
|
+
@param window_name: name of the window
|
|
357
|
+
@param mesh_path: path to the mesh file
|
|
358
|
+
"""
|
|
359
|
+
assert _ctx is not None, "call window_create first"
|
|
360
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
361
|
+
|
|
362
|
+
scn_mgr = _ctx.windows[window_name].scn_mgr
|
|
363
|
+
mesh_path = str(mesh_path)
|
|
364
|
+
# hiding non-existent mesh has no effect
|
|
365
|
+
if scn_mgr.hasEntity(mesh_path):
|
|
366
|
+
ent = scn_mgr.getEntity(mesh_path)
|
|
367
|
+
ent.setVisible(False)
|
|
368
|
+
|
|
369
|
+
def point_light(window_name: str, position = (0, 0, 0)):
|
|
370
|
+
"""!
|
|
371
|
+
create a point light in the window
|
|
372
|
+
@param window_name: name of the window
|
|
373
|
+
@param position: position of the light in world coordinates
|
|
374
|
+
"""
|
|
375
|
+
assert _ctx is not None, "call window_create first"
|
|
376
|
+
assert window_name in _ctx.windows, f"no window named: {window_name}"
|
|
377
|
+
|
|
378
|
+
scn_mgr = _ctx.windows[window_name].scn_mgr
|
|
379
|
+
if scn_mgr.hasLight("point_light"):
|
|
380
|
+
light_node = _ctx.scn_mgr.getLight("point_light").getParentSceneNode()
|
|
381
|
+
else:
|
|
382
|
+
light = scn_mgr.createLight("point_light", Ogre.Light.LT_POINT)
|
|
383
|
+
light_node = scn_mgr.getRootSceneNode().createChildSceneNode()
|
|
384
|
+
light_node.attachObject(light)
|
|
385
|
+
|
|
386
|
+
light_node.setPosition(*position)
|
|
387
|
+
|
|
388
|
+
## @}
|
|
389
|
+
## @}
|
Ogre/ImGui.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
|
2
|
+
# Version 4.4.1
|
|
3
|
+
#
|
|
4
|
+
# Do not make changes to this file unless you know what you are doing - modify
|
|
5
|
+
# the SWIG interface file instead.
|
|
6
|
+
|
|
7
|
+
from sys import version_info as _swig_python_version_info
|
|
8
|
+
# Pull in all the attributes from the low-level C/C++ module
|
|
9
|
+
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
|
|
10
|
+
from ._ImGui import *
|
|
11
|
+
else:
|
|
12
|
+
from _ImGui import *
|
Ogre/Numpy.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# This file is part of the OGRE project.
|
|
2
|
+
# It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
3
|
+
# of this distribution and at https://www.ogre3d.org/licensing.
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
6
|
+
import Ogre
|
|
7
|
+
|
|
8
|
+
import ctypes
|
|
9
|
+
import numpy.ctypeslib as npc
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
## \addtogroup Optional
|
|
13
|
+
# @{
|
|
14
|
+
# \defgroup Python Python
|
|
15
|
+
# Convenience functions for python
|
|
16
|
+
# @{
|
|
17
|
+
|
|
18
|
+
def AsDataStream(arr):
|
|
19
|
+
"""!
|
|
20
|
+
copy numpy array to Ogre.MemoryDataStream that can be used in Ogre
|
|
21
|
+
@param arr: some numpy array
|
|
22
|
+
"""
|
|
23
|
+
size = int(np.prod(arr.shape) * arr.dtype.itemsize)
|
|
24
|
+
ret = Ogre.MemoryDataStream(size)
|
|
25
|
+
tp = ctypes.POINTER(ctypes.c_ubyte)
|
|
26
|
+
np_view = npc.as_array(ctypes.cast(int(ret.getPtr()), tp), (size, ))
|
|
27
|
+
np_view[:] = arr.ravel().view(np.ubyte)
|
|
28
|
+
|
|
29
|
+
return ret
|
|
30
|
+
|
|
31
|
+
def view(o):
|
|
32
|
+
"""!
|
|
33
|
+
writable numpy view to the ogre data types
|
|
34
|
+
|
|
35
|
+
take care that the ogre type does not get released while the view is used.
|
|
36
|
+
e.g. this is invalid
|
|
37
|
+
|
|
38
|
+
```py
|
|
39
|
+
v = Ogre.Vector3()
|
|
40
|
+
return Ogre.Numpy.view(v)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
instead do
|
|
44
|
+
```py
|
|
45
|
+
return Ogre.Numpy.view(v).copy()
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
to pass numpy arrays into Ogre use AsDataStream()
|
|
49
|
+
"""
|
|
50
|
+
tp = ctypes.POINTER(ctypes.c_float)
|
|
51
|
+
|
|
52
|
+
if isinstance(o, Ogre.Vector2):
|
|
53
|
+
shape = (2,)
|
|
54
|
+
ptr = o.this
|
|
55
|
+
elif isinstance(o, Ogre.Vector3):
|
|
56
|
+
shape = (3,)
|
|
57
|
+
ptr = o.this
|
|
58
|
+
elif isinstance(o, Ogre.Vector4):
|
|
59
|
+
shape = (4,)
|
|
60
|
+
ptr = o.this
|
|
61
|
+
elif isinstance(o, Ogre.Matrix3):
|
|
62
|
+
shape = (3, 3)
|
|
63
|
+
ptr = o.this
|
|
64
|
+
elif isinstance(o, Ogre.Affine3):
|
|
65
|
+
shape = (3, 4)
|
|
66
|
+
ptr = o.this
|
|
67
|
+
elif isinstance(o, Ogre.Matrix4):
|
|
68
|
+
shape = (4, 4)
|
|
69
|
+
ptr = o.this
|
|
70
|
+
elif isinstance(o, Ogre.PixelBox):
|
|
71
|
+
tp = ctypes.POINTER(ctypes.c_uint8)
|
|
72
|
+
shape = (o.getHeight(), o.getWidth(), Ogre.PixelUtil.getNumElemBytes(o.format))
|
|
73
|
+
ptr = o.data
|
|
74
|
+
else:
|
|
75
|
+
raise TypeError("do not know how to map '{}'".format(type(o).__name__))
|
|
76
|
+
|
|
77
|
+
return npc.as_array(ctypes.cast(int(ptr), tp), shape)
|
|
78
|
+
|
|
79
|
+
## @}
|
|
80
|
+
## @}
|
Ogre/Ogre.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
|
2
|
+
# Version 4.4.1
|
|
3
|
+
#
|
|
4
|
+
# Do not make changes to this file unless you know what you are doing - modify
|
|
5
|
+
# the SWIG interface file instead.
|
|
6
|
+
|
|
7
|
+
from sys import version_info as _swig_python_version_info
|
|
8
|
+
# Pull in all the attributes from the low-level C/C++ module
|
|
9
|
+
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
|
|
10
|
+
from ._Ogre import *
|
|
11
|
+
else:
|
|
12
|
+
from _Ogre import *
|
Ogre/OgreBites.dll
ADDED
|
Binary file
|
Ogre/OgreBullet.dll
ADDED
|
Binary file
|
Ogre/OgreMain.dll
ADDED
|
Binary file
|
Ogre/OgreOverlay.dll
ADDED
|
Binary file
|
Ogre/OgrePaging.dll
ADDED
|
Binary file
|
|
Binary file
|
Ogre/OgreTerrain.dll
ADDED
|
Binary file
|
Ogre/Overlay.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
|
2
|
+
# Version 4.4.1
|
|
3
|
+
#
|
|
4
|
+
# Do not make changes to this file unless you know what you are doing - modify
|
|
5
|
+
# the SWIG interface file instead.
|
|
6
|
+
|
|
7
|
+
from sys import version_info as _swig_python_version_info
|
|
8
|
+
import Ogre.Ogre
|
|
9
|
+
|
|
10
|
+
# Pull in all the attributes from the low-level C/C++ module
|
|
11
|
+
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
|
|
12
|
+
from ._Overlay import *
|
|
13
|
+
else:
|
|
14
|
+
from _Overlay import *
|
Ogre/Plugin_DotScene.dll
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
Ogre/RTShader.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
|
2
|
+
# Version 4.4.1
|
|
3
|
+
#
|
|
4
|
+
# Do not make changes to this file unless you know what you are doing - modify
|
|
5
|
+
# the SWIG interface file instead.
|
|
6
|
+
|
|
7
|
+
from sys import version_info as _swig_python_version_info
|
|
8
|
+
import Ogre.Ogre
|
|
9
|
+
|
|
10
|
+
# Pull in all the attributes from the low-level C/C++ module
|
|
11
|
+
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
|
|
12
|
+
from ._RTShader import *
|
|
13
|
+
else:
|
|
14
|
+
from _RTShader import *
|
|
Binary file
|
Ogre/RenderSystem_GL.dll
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
Ogre/SDL2.dll
ADDED
|
Binary file
|
Ogre/Terrain.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
|
2
|
+
# Version 4.4.1
|
|
3
|
+
#
|
|
4
|
+
# Do not make changes to this file unless you know what you are doing - modify
|
|
5
|
+
# the SWIG interface file instead.
|
|
6
|
+
|
|
7
|
+
from sys import version_info as _swig_python_version_info
|
|
8
|
+
import Ogre.Ogre
|
|
9
|
+
|
|
10
|
+
# Pull in all the attributes from the low-level C/C++ module
|
|
11
|
+
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
|
|
12
|
+
from ._Terrain import *
|
|
13
|
+
else:
|
|
14
|
+
from _Terrain import *
|
Ogre/_Bites.pyd
ADDED
|
Binary file
|
Ogre/_Bullet.pyd
ADDED
|
Binary file
|
Ogre/_ImGui.pyd
ADDED
|
Binary file
|
Ogre/_Ogre.pyd
ADDED
|
Binary file
|
Ogre/_Overlay.pyd
ADDED
|
Binary file
|
Ogre/_RTShader.pyd
ADDED
|
Binary file
|
Ogre/_Terrain.pyd
ADDED
|
Binary file
|
Ogre/__init__.py
ADDED
Ogre/zlib.dll
ADDED
|
Binary file
|