Doxy
vis2.h
1 
12 #pragma once
13 
14 //#include "..\\..\\..\\Cinder\include\cinder\Cinder.h"
15 //essential
16 #include "cinder/app/App.h"
17 #include "cinder/app/RendererGl.h"
18 #include "cinder/gl/gl.h"
19 
20 #include "cinder/gl/gl.h"
21 
22 
23 
24 #include "cinder/Camera.h"
25 #include "cinder/GeomIo.h"
26 #include "cinder/ImageIo.h"
27 #include "cinder/CameraUi.h"
28 
29 
30 #include "cinder/gl/Batch.h"
31 #include "cinder/gl/Context.h"
32 #include "cinder/gl/GlslProg.h"
33 #include "cinder/gl/Texture.h"
34 #include "cinder/gl/VboMesh.h"
35 #include "cinder/params/Params.h"
36 #include "cinder/Log.h"
37 #include "cinder/Json.h"
38 
39 //predefined obj loader
40 //
41 #include "cinder/ObjLoader.h"
42 
43 #include <vector>
44 #include <algorithm> // contains search functions for vector classes
45 #include <iostream>
46 #include <iostream>
47 #include <boost/filesystem.hpp>
48 
49 #include "vis2enums.h"
50 
51 
52 
53 using namespace boost::filesystem;
54 using namespace ci;
55 using namespace ci::app;
56 using namespace std;
57 
58 namespace vis2 {
59 
60  //explicit App to make clear where App came from (cinder, not Windows RT SDK)
61  class Vis2App : public ci::app::App {
62 
63  public:
64  Vis2App();
65 
66  void setup() override;
67  void setupUI();
68  void setupLabelList();
69  void setupGLSL();
70 
71  void resize() override;
72  void update() override;
73  void draw() override;
74 
75 
76  void mouseDown(MouseEvent event) override;
77  void mouseUp(MouseEvent event) override;
78 
79  void mouseDrag(MouseEvent event) override;
80  void mouseWheel(MouseEvent event) override;
81  void keyDown(KeyEvent event) override;
82  void mouseMove(MouseEvent event) override;
83 
84  void resetCam();
85  void moveCameraPosLinear(CameraPersp newCam);
86 
87 
88  void loadObj(const DataSourceRef& dataSource);
89  void loadObj(const DataSourceRef &dataSourceObj, const DataSourceRef &dataSourceMtl);
90 
91  void createCut();
92  void loadCut();
93 
94  void updateViewInterface() const;
95 
96  void createGridLoop();
97  void createGrid();
98 
99  void selectObjFileDialog();
100  void loadModel();
101 
102  bool performPicking(vec3 *pickedPoint, vec3 *pickedNormal) const;
103 
104  void enableSelect();
105  void buttonLoadModel();
106 
107  protected:
108  vec3 mCameraTarget, mCameraLerpTarget, mCameraViewDirection;
109 
110  //for multiple meshes/objects to render
111  vector<gl::BatchRef> mVecBatchRef;
112  vector<gl::VertBatchRef> mVecVertBatchRef;
113 
114  gl::VertBatchRef mObjectVertBatch;
115  gl::BatchRef mObjectBatch;
116 
117  CameraPersp mCamera;
118  CameraUi mCamUi;
119 
120  gl::BatchRef mPrimitive;
121  gl::BatchRef mPrimitiveWire;
122  gl::BatchRef mPrimitiveWireframe;
123  gl::BatchRef mPrimitiveNormalLines, mPrimitiveTangentLines;
124 
125  gl::GlslProgRef mPhongShader;
126  gl::GlslProgRef mWireShader;
127  gl::GlslProgRef mWireframeShader;
128  gl::GlslProgRef *mCurrentShader;
129  gl::GlslProgRef mFlatShader;
130 
131  enum shaderSetting
132  {
133  PHONG, FLAT, WIRE
134  };
135 
136  struct sCut
137  {
138  //std::string label = "DEFUALTLABELCHANGETHIS";
139  CameraPersp camera;
140  float u = 0.0;
141  float v = 0.0;
142  float w = 0.0;
143 
144  float x = 0.0;
145  float y = 0.0;
146  float z = 0.0;
147 
148  float alpha = 0.0;
149  cutType type;
150 
151  bool enabled = true;
152  } ;
153 
154 
155  string mCutLabel;
156 
157  int mCutSelection;
158  bool mCutEnabled = true;
159 
160  vector<string> cutsLabelList;
161  vector<sCut> cutsList;
162 
163 
164 
165 
166  //UI Windows
167  params::InterfaceGlRef mOptions;
168  params::InterfaceGlRef mCameraSettings;
169  params::InterfaceGlRef mCutSettings;
170  params::InterfaceGlRef mViewSettings;
171 
172  params::InterfaceGlRef mRigs;
173 
174 
175  shaderSetting mShaderSetting;
176 
177  int mNumGridCells;
178 
179  TriMeshRef mCurrentTriMesh;
180 
181  cinder::gl::VboMeshRef mCurrentVboMesh;
182 
183  //parameters for UI Settings
184  bool mEnablePlaneCut;
185 
186  //simple test cut methods:
187  vec4 mPlaneCutParams;
188 
189  vec3 mPickedPoint;
190  vec3 mPickedNormal;
191 
192  vec3 mMouseDrawPoint;
193  vec3 mMouseDrawPickedNormal;
194 
195 
196  float mSpaceParamU;
197  float mSpaceParamV;
198  float mSpaceParamW;
199 
200  float mSpaceX;
201  float mSpaceY;
202  float mSpaceZ;
203 
204  vec4 mSpacePos;
205 
206  float mCutAlpha;
207 
208  bool mEnableSelect;
209  vec2 mMousePos;
210 
211  string mCurrentModelPath;
212 
213  Color mBackgroundColor;
214 
215  bool mEnableFaceCulling;
216  bool mShowGrid;
217 
218  std::string mModelFile;
219  std::string mModelMtl;
220  std::string mJsonFile;
221 
222 
223  JsonTree mJsonTree;
224 
225  gl::VertBatchRef mGridLoop;
226  gl::VertBatchRef mGrid;
227 
228 
229  TexType mTextureType;
230  cutType mCutType;
231 
232 
233 
234 
235  bool mMouseDown;
236  Font mFont;
237 
238  std::string mFps;
239 
240  vec2 mMouseStartPoint;
241  vec2 mMouseEndPoint;
242 
243  TriMesh mCutWire;
244  gl::BatchRef mCutWireBatch;
245 
246  AxisAlignedBox mObjectBounds;
247  /*
248 
249  void saveCurrentCutAndView();
250  bool testPlaneCut(gl::BatchRef batchRef);
251  void saveToJson();
252  void loadJson();
253 
254  */
255 
256  };
257 }
258 
Definition: vis2.h:61
Definition: Vis2File.cpp:13
Definition: vis2.h:136