ISAAC
Overview :: Library Doc :: Server Doc :: JSON Commands

In Situ Animation of Accelerated Computations

isaac_controllers.hpp
Go to the documentation of this file.
1 /* This file is part of ISAAC.
2  *
3  * ISAAC is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * ISAAC is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with ISAAC. If not, see <www.gnu.org/licenses/>. */
15 
16 #pragma once
17 
18 namespace isaac
19 {
20 
22 {
23  static const int pass_count = 1;
26  inline bool updateProjection( IceTDouble * const projection, const isaac_size2 & framebuffer_size, json_t * const message, const bool first = false)
27  {
28  if (first)
29  setPerspective( projection, 45.0f, (isaac_float)framebuffer_size.x/(isaac_float)framebuffer_size.y,ISAAC_Z_NEAR, ISAAC_Z_FAR);
30  return false;
31  }
32  inline void sendFeedback( json_t * const json_root, bool force = false ) {}
33 };
34 
36 {
37  static const int pass_count = 2;
39  eye_distance(0.06f),
40  send_stereo(true)
41  {}
43  inline bool updateProjection( IceTDouble * const projection, const isaac_size2 & framebuffer_size, json_t * const message, const bool first = false)
44  {
45  if ( json_t* js = json_object_get(message, "eye distance") )
46  {
47  send_stereo = true;
48  eye_distance = json_number_value( js );
49  json_object_del( message, "eye distance" );
50  }
51  if (first || send_stereo)
52  {
53  spSetPerspectiveStereoscopic( &(projection[ 0]), 45.0f, (isaac_float)framebuffer_size.x/(isaac_float)framebuffer_size.y,ISAAC_Z_NEAR, ISAAC_Z_FAR, 5.0f, eye_distance);
54  spSetPerspectiveStereoscopic( &(projection[16]), 45.0f, (isaac_float)framebuffer_size.x/(isaac_float)framebuffer_size.y,ISAAC_Z_NEAR, ISAAC_Z_FAR, 5.0f, -eye_distance);
55  }
56  return send_stereo;
57  }
58  inline void sendFeedback( json_t * const json_root, bool force = false )
59  {
60  if (send_stereo || force)
61  {
62  json_object_set_new( json_root, "eye distance", json_real( eye_distance ) );
63  send_stereo = false;
64  }
65  }
66  float eye_distance;
68 };
69 
70 } //namespace isaac;
float isaac_float
Definition: isaac_types.hpp:25
void spSetPerspectiveStereoscopic(IceTDouble *const projection, const isaac_float fovyInDegrees, const isaac_float aspectRatio, const isaac_float znear, const isaac_float zfar, const isaac_float z0, const isaac_float distance)
void setPerspective(IceTDouble *const projection, const isaac_float fovyInDegrees, const isaac_float aspectRatio, const isaac_float znear, const isaac_float zfar)
Definition: isaac.hpp:60
bool updateProjection(IceTDouble *const projection, const isaac_size2 &framebuffer_size, json_t *const message, const bool first=false)
bool updateProjection(IceTDouble *const projection, const isaac_size2 &framebuffer_size, json_t *const message, const bool first=false)
void sendFeedback(json_t *const json_root, bool force=false)
#define ISAAC_Z_NEAR
#define ISAAC_Z_FAR
void sendFeedback(json_t *const json_root, bool force=false)