compas-dev / compas_view2

Standalone viewer for COMPAS
https://compas.dev/compas_view2/
MIT License
7 stars 9 forks source link

Camera #110

Closed Licini closed 2 years ago

Licini commented 2 years ago

This is an alternative approach to treat the camera transformation more in line with other general objects in the scene. In this case the viewworld is calculated directly from the inverted transformation matrix of the "camera object". In this way users can more intuitively interact with the camera with it's position, rotation and target. See the example v120_camera.py. I also made position a generated property so that when user changes it, the rotation will be automatically updated to look at the target.

Licini commented 2 years ago

@brgcode OK I think now it's ready. I made position/target/rotation a special class inherited from Vector, so that they can have proper setters on both object and attributes level, to support easy user interactions, preventing overwriting the instances, at same time supporting multiple dynamic updates behind the scene. For instance:

camera.position.x += 1
# or 
camera.position += [1, 0, 0]
# or 
camera.position = [1, 0, 0]
# will all trigger rotation updates to keep the camera pointing at the target.

# while
camera.rotation.z += 0.1
# or 
camera.rotation += [1, 0, 0]
# or 
camera.rotation = [1.1, 0, 0]
# will update position automatically to create the effect of pivoting around target

# while
camera.target.x += 1
# or 
camera.target += [1, 0, 0]
# or 
camera.target = [1, 0, 0]
# will update position also together with the shifting of target location
tomvanmele commented 2 years ago

cool!

Licini commented 2 years ago

cool!

I can merge now?