-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new maya camera controller module (wip)
- Loading branch information
Showing
6 changed files
with
128 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 2.6.2) | ||
project(mayaCameraControllerQmlPlugin) | ||
|
||
# Install settings | ||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins/qml | ||
FILES_MATCHING PATTERN "*.qml" | ||
PATTERN "qmldir") |
104 changes: 104 additions & 0 deletions
104
plugins/qml/qt3d/MayaCameraController/MayaCameraController.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import Qt3D.Core 2.0 | ||
import Qt3D.Render 2.0 | ||
import Qt3D.Input 2.0 | ||
import Qt3D.Extras 2.0 | ||
import Qt3D.Logic 2.0 | ||
import QtQml 2.2 | ||
|
||
Entity { | ||
|
||
id: root | ||
property Camera camera | ||
property real translateSpeed: 100.0 | ||
property real tiltSpeed: -500.0 | ||
property real panSpeed: 500.0 | ||
|
||
KeyboardDevice { id: keyboardSourceDevice } | ||
MouseDevice { id: mouseSourceDevice; sensitivity: 0.1 } | ||
|
||
LogicalDevice { | ||
id: cameraControlDevice | ||
actions: [ | ||
Action { | ||
id: actionLMB | ||
inputs: [ | ||
ActionInput { | ||
sourceDevice: mouseSourceDevice | ||
buttons: [MouseEvent.LeftButton] | ||
} | ||
] | ||
}, | ||
Action { | ||
id: actionRMB | ||
inputs: [ | ||
ActionInput { | ||
sourceDevice: mouseSourceDevice | ||
buttons: [MouseEvent.RightButton] | ||
} | ||
] | ||
}, | ||
Action { | ||
id: actionMMB | ||
inputs: [ | ||
ActionInput { | ||
sourceDevice: mouseSourceDevice | ||
buttons: [MouseEvent.MiddleButton] | ||
} | ||
] | ||
}, | ||
Action { | ||
id: actionAlt | ||
inputs: [ | ||
ActionInput { | ||
sourceDevice: keyboardSourceDevice | ||
buttons: [Qt.Key_Alt] | ||
} | ||
] | ||
} | ||
] | ||
axes: [ | ||
Axis { | ||
id: axisMX | ||
inputs: [ | ||
AnalogAxisInput { | ||
sourceDevice: mouseSourceDevice | ||
axis: MouseDevice.X | ||
} | ||
] | ||
}, | ||
Axis { | ||
id: axisMY | ||
inputs: [ | ||
AnalogAxisInput { | ||
sourceDevice: mouseSourceDevice | ||
axis: MouseDevice.Y | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
||
components: [ | ||
FrameAction { | ||
onTriggered: { | ||
if(!actionAlt.active) | ||
return; | ||
if(actionLMB.active) { // rotate | ||
var rx = -axisMX.value; | ||
var ry = axisMY.value; | ||
root.camera.panAboutViewCenter(root.panSpeed * rx * dt) | ||
root.camera.tiltAboutViewCenter(root.tiltSpeed * ry * dt) | ||
} | ||
if(actionMMB.active) { // translate | ||
var tx = axisMX.value * root.translateSpeed; | ||
var ty = axisMY.value * root.translateSpeed; | ||
root.camera.translate(Qt.vector3d(-tx, -ty, 0).times(dt)) | ||
} | ||
if(actionRMB.active) { // zoom | ||
var tz = axisMX.value * root.translateSpeed; | ||
root.camera.translate(Qt.vector3d(0, 0, tz).times(dt)) | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module MayaCameraController | ||
|
||
MayaCameraController 1.0 MayaCameraController.qml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters