python: fix review findings.
parent
7eee959d55
commit
b3c2fdc11d
|
@ -29,7 +29,6 @@ from . import structs
|
|||
from . import helper
|
||||
from . import postprocess
|
||||
from .errors import AssimpError
|
||||
from .formats import available_formats
|
||||
|
||||
class AssimpLib(object):
|
||||
"""
|
||||
|
@ -300,14 +299,12 @@ def load(filename,
|
|||
'''
|
||||
|
||||
if hasattr(filename, 'read'):
|
||||
'''
|
||||
This is the case where a file object has been passed to load.
|
||||
It is calling the following function:
|
||||
const aiScene* aiImportFileFromMemory(const char* pBuffer,
|
||||
unsigned int pLength,
|
||||
unsigned int pFlags,
|
||||
const char* pHint)
|
||||
'''
|
||||
# This is the case where a file object has been passed to load.
|
||||
# It is calling the following function:
|
||||
# const aiScene* aiImportFileFromMemory(const char* pBuffer,
|
||||
# unsigned int pLength,
|
||||
# unsigned int pFlags,
|
||||
# const char* pHint)
|
||||
if file_type == None:
|
||||
raise AssimpError('File type must be specified when passing file objects!')
|
||||
data = filename.read()
|
||||
|
|
|
@ -1177,6 +1177,22 @@ class PyAssimp3DViewer:
|
|||
return True
|
||||
|
||||
def controls_3d(self, dx, dy, zooming_one_shot=False):
|
||||
""" Orbiting the camera is implemented the following way:
|
||||
|
||||
- the rotation is split into a rotation around the *world* Z axis
|
||||
(controlled by the horizontal mouse motion along X) and a
|
||||
rotation around the *X* axis of the camera (pitch) *shifted to
|
||||
the focal origin* (the world origin for now). This is controlled
|
||||
by the vertical motion of the mouse (Y axis).
|
||||
- as a result, the resulting transformation of the camera in the
|
||||
world frame C' is:
|
||||
C' = (T · Rx · T⁻¹ · (Rz · C)⁻¹)⁻¹
|
||||
where:
|
||||
- C is the original camera transformation in the world frame,
|
||||
- Rz is the rotation along the Z axis (in the world frame)
|
||||
- T is the translation camera -> world (ie, the inverse of the
|
||||
translation part of C
|
||||
- Rx is the rotation around X in the (translated) camera frame """
|
||||
|
||||
CAMERA_TRANSLATION_FACTOR = 0.01
|
||||
CAMERA_ROTATION_FACTOR = 0.01
|
||||
|
@ -1188,26 +1204,6 @@ class PyAssimp3DViewer:
|
|||
distance = numpy.linalg.norm(self.focal_point - current_pos)
|
||||
|
||||
if self.is_rotating:
|
||||
""" Orbiting the camera is implemented the following way:
|
||||
|
||||
- the rotation is split into a rotation around the *world* Z axis
|
||||
(controlled by the horizontal mouse motion along X) and a
|
||||
rotation around the *X* axis of the camera (pitch) *shifted to
|
||||
the focal origin* (the world origin for now). This is controlled
|
||||
by the vertical motion of the mouse (Y axis).
|
||||
|
||||
- as a result, the resulting transformation of the camera in the
|
||||
world frame C' is:
|
||||
C' = (T · Rx · T⁻¹ · (Rz · C)⁻¹)⁻¹
|
||||
|
||||
where:
|
||||
- C is the original camera transformation in the world frame,
|
||||
- Rz is the rotation along the Z axis (in the world frame)
|
||||
- T is the translation camera -> world (ie, the inverse of the
|
||||
translation part of C
|
||||
- Rx is the rotation around X in the (translated) camera frame
|
||||
"""
|
||||
|
||||
rotation_camera_x = dy * CAMERA_ROTATION_FACTOR
|
||||
rotation_world_z = dx * CAMERA_ROTATION_FACTOR
|
||||
world_z_rotation = transformations.euler_matrix(0, 0, rotation_world_z)
|
||||
|
|
Loading…
Reference in New Issue