python: fix review findings.

pull/2284/head
Kim Kulling 2018-12-23 14:28:40 +01:00
parent 7eee959d55
commit b3c2fdc11d
2 changed files with 22 additions and 29 deletions

View File

@ -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()

View File

@ -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)