-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from ABRG-Models/dev/panning_camera
Adds a method to rotate the scene about an axis
- Loading branch information
Showing
3 changed files
with
79 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
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,65 @@ | ||
/* | ||
* Visualize a Rod | ||
*/ | ||
#include <morph/Visual.h> | ||
#include <morph/ColourMap.h> | ||
#include <morph/RodVisual.h> | ||
#include <morph/vec.h> | ||
#include <iostream> | ||
#include <fstream> | ||
#include <cmath> | ||
#include <array> | ||
#include <stdexcept> | ||
#include <string> | ||
|
||
int main() | ||
{ | ||
int rtn = -1; | ||
|
||
// Demonstrates use of offset (left at 0,0,0), lengths (3,2,1) and the 'thickness' | ||
// scaling factor (0.5) for the coordinate arrows | ||
morph::Visual v(1024, 768, "Visualization", {0,0}, {.5,.5,.5}, 1.0f, 0.05f); | ||
v.zNear = 0.001; | ||
v.showCoordArrows = true; | ||
v.coordArrowsInScene = true; | ||
// For a white background: | ||
v.backgroundWhite(); | ||
// Switch on a mix of diffuse/ambient lighting | ||
v.lightingEffects(true); | ||
|
||
try { | ||
morph::vec<float, 3> offset = { 0.0, 0.0, 0.0 }; | ||
|
||
morph::vec<float, 3> start = { 0, 0, 0 }; | ||
morph::vec<float, 3> end = { 0.25, 0, 0 }; | ||
|
||
morph::vec<float, 3> colour1 = { 1.0, 0.0, 0.0 }; | ||
morph::vec<float, 3> colour2 = { 0.0, 0.9, 0.4 }; | ||
|
||
std::unique_ptr<morph::VisualModel<>> rvm = std::make_unique<morph::RodVisual<>> (offset, start, end, 0.1f, colour1, colour2); | ||
v.bindmodel (rvm); | ||
rvm->finalize(); | ||
v.addVisualModel (rvm); | ||
|
||
morph::vec<float, 3> start2 = { -0.1, 0.2, 0.6 }; | ||
morph::vec<float, 3> end2 = { 0.2, 0.4, 0.6 }; | ||
// You can reuse the unique_ptr rvm, once you've transferred ownership with v.addVisualModel (rvm) | ||
rvm = std::make_unique<morph::RodVisual<>>(offset, start2, end2, 0.05f, colour2); | ||
v.bindmodel (rvm); | ||
rvm->finalize(); | ||
v.addVisualModel (rvm); | ||
|
||
morph::vec<float> axis = {0,1,0}; // y | ||
while (v.readyToFinish == false) { | ||
v.waitevents (0.001); | ||
v.rotate_scene (axis, morph::mathconst<float>::two_pi / (9*360)); | ||
v.render(); | ||
} | ||
|
||
} catch (const std::exception& e) { | ||
std::cerr << "Caught exception: " << e.what() << std::endl; | ||
rtn = -1; | ||
} | ||
|
||
return rtn; | ||
} |
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