-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 67c1661
Showing
9 changed files
with
455 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target | ||
Cargo.lock | ||
**/*.swp |
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,15 @@ | ||
language: rust | ||
env: FEATURES="" | ||
matrix: | ||
include: | ||
- rust: stable | ||
- rust: stable | ||
env: FEATURES="cc" | ||
- rust: beta | ||
- rust: beta | ||
env: FEATURES="cc" | ||
- rust: nightly | ||
- rust: nightly | ||
env: FEATURES="cc" | ||
script: | ||
- cargo test --verbose --no-default-features --features "$FEATURES" |
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,38 @@ | ||
[package] | ||
name = "kiss3d-trackball" | ||
version = "0.1.0" | ||
authors = ["Rouven Spreckels <rs@qu1x.dev>"] | ||
edition = "2018" | ||
description = "Virtual Trackball Camera Mode for Kiss3D" | ||
documentation = "https://doc.qu1x.dev/kiss3d-trackball" | ||
repository = "https://github.com/qu1x/kiss3d-trackball" | ||
readme = "README.md" | ||
license = "BSD-3-Clause" | ||
keywords = [ | ||
"virtual-trackball", | ||
"exponential-map", | ||
"quaternion", | ||
"arcball", | ||
"camera", | ||
] | ||
categories = [ | ||
"graphics", | ||
] | ||
include = [ | ||
"src/**/*.rs", | ||
"Cargo.toml", | ||
"README.md", | ||
"RELEASES.md", | ||
"LICENSE.md", | ||
] | ||
|
||
[badges] | ||
travis-ci = { repository = "qu1x/kiss3d-trackball" } | ||
|
||
[dependencies] | ||
kiss3d = "0.30" | ||
nalgebra = "0.25" | ||
trackball = "0.2" | ||
|
||
[features] | ||
cc = ["trackball/cc"] |
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,11 @@ | ||
Copyright © 2021 Rouven Spreckels <rs@qu1x.dev> | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,35 @@ | ||
# kiss3d-trackball | ||
|
||
Virtual Trackball Camera Mode for Kiss3D | ||
|
||
[![Build Status][]](https://travis-ci.org/qu1x/kiss3d-trackball) | ||
[![Downloads][]](https://crates.io/crates/kiss3d-trackball) | ||
[![Rust][]](https://www.rust-lang.org) | ||
[![Version][]](https://crates.io/crates/kiss3d-trackball) | ||
[![Documentation][]](https://doc.qu1x.dev/kiss3d-trackball) | ||
[![License][]](https://opensource.org/licenses/BSD-3-Clause) | ||
|
||
[Build Status]: https://travis-ci.org/qu1x/kiss3d-trackball.svg | ||
[Downloads]: https://img.shields.io/crates/d/kiss3d-trackball.svg | ||
[Rust]: https://img.shields.io/badge/rust-stable-brightgreen.svg | ||
[Version]: https://img.shields.io/crates/v/kiss3d-trackball.svg | ||
[Documentation]: https://docs.rs/kiss3d-trackball/badge.svg | ||
[License]: https://img.shields.io/crates/l/kiss3d-trackball.svg | ||
|
||
Complements common [trackball operation handlers] with [`kiss3d`] specific [`Input`] resulting | ||
in a compound [`Trackball`] [`Camera`] mode implementation for the [`kiss3d`] graphics library. | ||
|
||
[trackball operation handlers]: https://doc.qu1x.dev/kiss3d-trackball/trackball/index.html#structs | ||
[`kiss3d`]: https://doc.qu1x.dev/kiss3d-trackball/kiss3d/index.html | ||
[`Input`]: https://doc.qu1x.dev/kiss3d-trackball/kiss3d_trackball/struct.Input.html | ||
[`Trackball`]: https://doc.qu1x.dev/kiss3d-trackball/kiss3d_trackball/struct.Trackball.html | ||
[`Camera`]: https://doc.qu1x.dev/kiss3d-trackball/kiss3d/camera/trait.Camera.html | ||
|
||
## License | ||
|
||
[BSD-3-Clause](LICENSE.md) | ||
|
||
## Contribution | ||
|
||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion | ||
in the works by you shall be licensed as above, without any additional terms or conditions. |
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 @@ | ||
# Version 0.1.0 (2021-04-03) | ||
|
||
* Add trackball implementation. |
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 @@ | ||
hard_tabs = true | ||
format_code_in_doc_comments = true | ||
max_width = 100 |
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,98 @@ | ||
use kiss3d::event::{Key, Modifiers, MouseButton}; | ||
use nalgebra::RealField; | ||
use std::marker::PhantomData; | ||
|
||
/// Input keys/buttons and their modifiers. | ||
#[derive(Debug, Clone)] | ||
pub struct Input<N: RealField> { | ||
phantom_data: PhantomData<N>, | ||
ortho_key: Option<Key>, | ||
reset_key: Option<Key>, | ||
orbit_button: Option<MouseButton>, | ||
orbit_modifiers: Option<Modifiers>, | ||
slide_button: Option<MouseButton>, | ||
slide_modifiers: Option<Modifiers>, | ||
} | ||
|
||
impl<N: RealField> Default for Input<N> { | ||
fn default() -> Self { | ||
Self { | ||
phantom_data: PhantomData, | ||
ortho_key: Some(Key::O), | ||
reset_key: Some(Key::Return), | ||
orbit_button: Some(MouseButton::Button1), | ||
orbit_modifiers: None, | ||
slide_button: Some(MouseButton::Button2), | ||
slide_modifiers: None, | ||
} | ||
} | ||
} | ||
|
||
impl<N: RealField> Input<N> { | ||
/// Key used to switch between orthographic and perspective projection. | ||
pub fn ortho_key(&self) -> Option<Key> { | ||
self.ortho_key | ||
} | ||
/// Sets key used to switch between orthographic and perspective projection. | ||
/// | ||
/// Use `None` to disable switch. | ||
pub fn rebind_ortho_key(&mut self, key: Option<Key>) { | ||
self.ortho_key = key; | ||
} | ||
/// Key used to reset camera. | ||
pub fn reset_key(&self) -> Option<Key> { | ||
self.reset_key | ||
} | ||
/// Sets key used to reset camera. | ||
/// | ||
/// Use `None` to disable reset. | ||
pub fn rebind_reset_key(&mut self, key: Option<Key>) { | ||
self.reset_key = key; | ||
} | ||
/// Button used to orbit camera. | ||
pub fn orbit_button(&self) -> Option<MouseButton> { | ||
self.orbit_button | ||
} | ||
/// Sets button used to orbit camera. | ||
/// | ||
/// Use `None` to disable rotation. | ||
pub fn rebind_orbit_button(&mut self, button: Option<MouseButton>) { | ||
self.orbit_button = button; | ||
} | ||
/// Modifiers that must be pressed for orbit to occur. | ||
pub fn orbit_modifiers(&self) -> Option<Modifiers> { | ||
self.orbit_modifiers | ||
} | ||
/// Sets modifiers that must be pressed for orbit to occur. | ||
/// | ||
/// * If set to `None`, then pressing any modifier will not prevent orbit. | ||
/// * If different from `None`, orbit will occur only if the exact specified set of modifiers | ||
/// is pressed. In particular, if set to `Some(Modifiers::empty())`, orbit will occur only | ||
/// if no modifier is pressed. | ||
pub fn set_orbit_modifiers(&mut self, modifiers: Option<Modifiers>) { | ||
self.orbit_modifiers = modifiers | ||
} | ||
/// Button used to slide camera. | ||
pub fn slide_button(&self) -> Option<MouseButton> { | ||
self.slide_button | ||
} | ||
/// Sets button used to slide camera. | ||
/// | ||
/// Use `None` to disable slide. | ||
pub fn rebind_slide_button(&mut self, button: Option<MouseButton>) { | ||
self.slide_button = button; | ||
} | ||
/// Modifiers that must be pressed for slide to occur. | ||
pub fn slide_modifiers(&self) -> Option<Modifiers> { | ||
self.slide_modifiers | ||
} | ||
/// Sets modifiers that must be pressed for slide to occur. | ||
/// | ||
/// * If set to `None`, then pressing any modifier will not prevent slide. | ||
/// * If different from `None`, slide will occur only if the exact specified set of modifiers | ||
/// is pressed. In particular, if set to `Some(Modifiers::empty())`, slide will occur only | ||
/// if no modifier is pressed. | ||
pub fn set_slide_modifiers(&mut self, modifiers: Option<Modifiers>) { | ||
self.slide_modifiers = modifiers | ||
} | ||
} |
Oops, something went wrong.