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
1 parent
38df914
commit 22a1a15
Showing
3 changed files
with
71 additions
and
67 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 |
---|---|---|
@@ -1,22 +1,76 @@ | ||
#pragma once | ||
|
||
#include "Pivot2World.h" | ||
#include "pivot.h" | ||
|
||
struct Pivot2World | ||
namespace selection | ||
{ | ||
Matrix4 _worldSpace; | ||
Matrix4 _viewpointSpace; | ||
Matrix4 _viewplaneSpace; | ||
Vector3 _axisScreen; | ||
|
||
void update(const Matrix4& pivot2world, const Matrix4& modelview, const Matrix4& projection, const Matrix4& viewport) | ||
{ | ||
Pivot2World_worldSpace(_worldSpace, pivot2world, modelview, projection, viewport); | ||
Pivot2World_viewpointSpace(_viewpointSpace, _axisScreen, pivot2world, modelview, projection, viewport); | ||
Pivot2World_viewplaneSpace(_viewplaneSpace, pivot2world, modelview, projection, viewport); | ||
} | ||
}; | ||
|
||
class Pivot2World | ||
{ | ||
public: | ||
Matrix4 _worldSpace; | ||
Matrix4 _viewpointSpace; | ||
Matrix4 _viewplaneSpace; | ||
Vector3 _axisScreen; | ||
|
||
void update(const Matrix4& pivot2world, const Matrix4& modelview, const Matrix4& projection, const Matrix4& viewport) | ||
{ | ||
calculcateWorldSpace(pivot2world, modelview, projection, viewport); | ||
calculateViewpointSpace(pivot2world, modelview, projection, viewport); | ||
calculateViewplaneSpace(pivot2world, modelview, projection, viewport); | ||
} | ||
|
||
private: | ||
void calculcateWorldSpace(const Matrix4& pivot2world, const Matrix4& modelview, const Matrix4& projection, const Matrix4& viewport) | ||
{ | ||
_worldSpace = pivot2world; | ||
|
||
Matrix4 pivot2screen; | ||
ConstructObject2Screen(pivot2screen, pivot2world, modelview, projection, viewport); | ||
|
||
Matrix4 scale; | ||
pivot_scale(scale, pivot2screen); | ||
_worldSpace.multiplyBy(scale); | ||
pivot_perspective(scale, pivot2screen); | ||
_worldSpace.multiplyBy(scale); | ||
} | ||
|
||
void calculateViewpointSpace(const Matrix4& pivot2world, const Matrix4& modelview, const Matrix4& projection, const Matrix4& viewport) | ||
{ | ||
_viewpointSpace = pivot2world; | ||
|
||
Matrix4 pivot2screen; | ||
ConstructObject2Screen(pivot2screen, pivot2world, modelview, projection, viewport); | ||
|
||
Matrix4 scale; | ||
pivot_scale(scale, pivot2screen); | ||
_viewpointSpace.multiplyBy(scale); | ||
|
||
billboard_viewpointOriented(scale, pivot2screen); | ||
_axisScreen = scale.z().getVector3(); | ||
_viewpointSpace.multiplyBy(scale); | ||
|
||
pivot_perspective(scale, pivot2screen); | ||
_viewpointSpace.multiplyBy(scale); | ||
} | ||
|
||
void calculateViewplaneSpace(const Matrix4& pivot2world, const Matrix4& modelview, const Matrix4& projection, const Matrix4& viewport) | ||
{ | ||
_viewplaneSpace = pivot2world; | ||
|
||
Matrix4 pivot2screen; | ||
ConstructObject2Screen(pivot2screen, pivot2world, modelview, projection, viewport); | ||
|
||
Matrix4 scale; | ||
pivot_scale(scale, pivot2screen); | ||
_viewplaneSpace.multiplyBy(scale); | ||
|
||
billboard_viewplaneOriented(scale, pivot2screen); | ||
_viewplaneSpace.multiplyBy(scale); | ||
|
||
pivot_perspective(scale, pivot2screen); | ||
_viewplaneSpace.multiplyBy(scale); | ||
} | ||
}; | ||
|
||
} |
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