Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -38,20 +38,18 @@ public:
|
||||
sf<float> ds;
|
||||
sf<float> focal;
|
||||
public:
|
||||
virtual const std::vector<field_desc>& node_fields() const {
|
||||
virtual const desc_fields& node_desc_fields() const {
|
||||
TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::base_camera)
|
||||
static std::vector<field_desc> s_v;
|
||||
if(s_v.empty()) {
|
||||
s_v = parent::node_fields();
|
||||
TOOLS_ADD_FIELD_DESC(znear)
|
||||
TOOLS_ADD_FIELD_DESC(zfar)
|
||||
TOOLS_ADD_FIELD_DESC(position)
|
||||
TOOLS_ADD_FIELD_DESC(orientation)
|
||||
TOOLS_ADD_FIELD_DESC(dx)
|
||||
TOOLS_ADD_FIELD_DESC(da)
|
||||
TOOLS_ADD_FIELD_DESC(ds)
|
||||
TOOLS_ADD_FIELD_DESC(focal)
|
||||
}
|
||||
static const desc_fields s_v(parent::node_desc_fields(),8, //WARNING : take care of count.
|
||||
TOOLS_ARG_FIELD_DESC(znear),
|
||||
TOOLS_ARG_FIELD_DESC(zfar),
|
||||
TOOLS_ARG_FIELD_DESC(position),
|
||||
TOOLS_ARG_FIELD_DESC(orientation),
|
||||
TOOLS_ARG_FIELD_DESC(dx),
|
||||
TOOLS_ARG_FIELD_DESC(da),
|
||||
TOOLS_ARG_FIELD_DESC(ds),
|
||||
TOOLS_ARG_FIELD_DESC(focal)
|
||||
);
|
||||
return s_v;
|
||||
}
|
||||
private:
|
||||
@@ -165,22 +163,43 @@ public:
|
||||
orientation.value().mul_vec(vec3f(0,0,-1),a_dir);
|
||||
}
|
||||
|
||||
void rotate_around_direction(float a_delta) { //used in exlib/examples/iOS/sg.
|
||||
vec3f dir;
|
||||
orientation.value().mul_vec(vec3f(0,0,-1),dir);
|
||||
//_MSC_VER : does not compile : orientation = rotf(dir,a_delta) * orientation;
|
||||
orientation.value(rotf(dir,a_delta) * orientation.value());
|
||||
void rotate_around_direction(float a_delta) {
|
||||
//vec3f dir;
|
||||
//orientation.value().mul_vec(vec3f(0,0,-1),dir);
|
||||
//orientation.value(rotf(dir,a_delta) * orientation.value());
|
||||
orientation.value(rotf(vec3f(0,0,-1),a_delta) * orientation.value());
|
||||
}
|
||||
|
||||
void rotate_around_z(float a_delta) {
|
||||
//vec3f z;
|
||||
//orientation.value().mul_vec(vec3f(0,0,1),z);
|
||||
//orientation.value(rotf(z,a_delta) * orientation.value());
|
||||
orientation.value(rotf(vec3f(0,0,1),a_delta) * orientation.value());
|
||||
}
|
||||
|
||||
void rotate_around_up(float a_delta){
|
||||
vec3f up;
|
||||
orientation.value().mul_vec(vec3f(0,1,0),up);
|
||||
//orientation.value(rotf(up,a_delta) * orientation.value());
|
||||
// must be the below so that rot-cam works for exlib/cbk/[pyrfits,astro,cfitsio] astro setup.
|
||||
// must be the below so that rot-cam works for exlib/cbk/[astro,cfitsio] astro setup.
|
||||
// (astro setup change camera orientation).
|
||||
orientation.value(orientation.value() * rotf(up,a_delta));
|
||||
}
|
||||
|
||||
void rotate_around_x(float a_delta){
|
||||
orientation.value(rotf(vec3f(1,0,0),a_delta) * orientation.value());
|
||||
}
|
||||
|
||||
void rotate_around_x_at_focal(float a_delta){
|
||||
//from coin SoGuiExaminerViewerP::rotXWheelMotion.
|
||||
vec3f dir;
|
||||
orientation.value().mul_vec(vec3f(0,0,-1),dir);
|
||||
vec3f focalpoint = position.value() + focal * dir;
|
||||
orientation.value(rotf(vec3f(1,0,0),a_delta) * orientation.value());
|
||||
orientation.value().mul_vec(vec3f(0,0,-1),dir);
|
||||
position = focalpoint - focal * dir;
|
||||
}
|
||||
|
||||
void rotate_around_y_at_focal(float a_delta){
|
||||
//from coin SoGuiExaminerViewerP::rotYWheelMotion.
|
||||
vec3f dir;
|
||||
@@ -191,12 +210,12 @@ public:
|
||||
position = focalpoint - focal * dir;
|
||||
}
|
||||
|
||||
void rotate_around_x_at_focal(float a_delta){
|
||||
//from coin SoGuiExaminerViewerP::rotXWheelMotion.
|
||||
void rotate_around_z_at_focal(float a_delta){
|
||||
//from coin SoGuiExaminerViewerP::rotYWheelMotion.
|
||||
vec3f dir;
|
||||
orientation.value().mul_vec(vec3f(0,0,-1),dir);
|
||||
vec3f focalpoint = position.value() + focal * dir;
|
||||
orientation.value(rotf(vec3f(1,0,0),a_delta) * orientation.value());
|
||||
orientation.value(rotf(vec3f(0,0,1),a_delta) * orientation.value());
|
||||
orientation.value().mul_vec(vec3f(0,0,-1),dir);
|
||||
position = focalpoint - focal * dir;
|
||||
}
|
||||
@@ -323,6 +342,100 @@ public:
|
||||
da = 0.017f/100; //1/100 of a degree
|
||||
*/
|
||||
}
|
||||
|
||||
bool update_motion(int a_move) {
|
||||
float _dx = dx;
|
||||
float _da = da;
|
||||
float _ds = ds;
|
||||
|
||||
if(a_move==move_rotate_right) { //should match camera_yaw().
|
||||
rotate_around_up(_da);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_rotate_left) {
|
||||
rotate_around_up(-_da);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(a_move==move_rotate_up) { //should match camera_pitch().
|
||||
rotate_around_x(_da);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_rotate_down) {
|
||||
rotate_around_x(-_da);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(a_move==move_roll_plus) { //should match camera_roll().
|
||||
rotate_around_direction(-_da); //direction = -z, then the minus.
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_roll_minus) {
|
||||
rotate_around_direction(_da);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(a_move==move_translate_right) {
|
||||
translate_along_side(_dx);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_translate_left) {
|
||||
translate_along_side(-_dx);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(a_move==move_up) {
|
||||
translate_along_up(_dx);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_down) {
|
||||
translate_along_up(-_dx);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_forward) {
|
||||
translate_along_dir(_dx);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_backward) {
|
||||
translate_along_dir(-_dx);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_zoom_in) {
|
||||
zoom(_ds);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_zoom_out) {
|
||||
zoom(1.0f/_ds);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(a_move==move_rotate_around_focal_right) { //yaw around focal.
|
||||
rotate_around_y_at_focal(_da);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_rotate_around_focal_left) {
|
||||
rotate_around_y_at_focal(-_da);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_rotate_around_focal_up) { //pitch around focal.
|
||||
rotate_around_x_at_focal(_da);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_rotate_around_focal_down) {
|
||||
rotate_around_x_at_focal(-_da);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_roll_around_focal_plus) {
|
||||
rotate_around_z_at_focal(_da);
|
||||
return true;
|
||||
}
|
||||
if(a_move==move_roll_around_focal_minus) {
|
||||
rotate_around_z_at_focal(-_da);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
protected:
|
||||
void update_sg(std::ostream& a_out) {
|
||||
|
||||
@@ -346,7 +459,7 @@ protected:
|
||||
rinv.value(mtx);
|
||||
m_proj.mul_mtx(mtx,m_tmp);
|
||||
} else {
|
||||
a_out << "base_camera::update_sg :"
|
||||
a_out << "update_sg :"
|
||||
<< " get orientation inverse failed."
|
||||
<< std::endl;
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user