-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSensorAll_1.cpp
More file actions
266 lines (211 loc) · 7.4 KB
/
SensorAll_1.cpp
File metadata and controls
266 lines (211 loc) · 7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
// DVE_1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "DVE.h"
#include "ModelDeployer.h"
#include "Sensor.h"
#include "Geometry.h"
#include "Panel.h"
//vuAllocTracer tracer;
class myApp: public vpApp, public vsChannel::Subscriber
{
public:
static bool restart;
myApp()
{
pDve = NULL;
pSensor = NULL;
pGeometry = NULL;
}
~myApp()
{
if (pDve != NULL) {delete pDve;pDve = NULL;}
if (pSensor != NULL) {delete pSensor;pSensor = NULL;}
if (pGeometry != NULL) {delete pGeometry;pGeometry = NULL;}
}
virtual int configure(void)
{
int ret = vpApp::configure();
isLoaded = loadModel();
if (!isLoaded)
{
return ret;
}
else
{
classPanel::instance()->init("myWindow");
classShaderDeployer::instance()->init();
pDve = new classDve("ccdObserver",this);
pSensor = new classSensor("sensorObserver",this);
pGeometry = new classGeometry("sensorObserver",this);
}
return ret;
}
virtual int unconfigure(void)
{
classPanel::instance()->removeAllPanel(); //vpApp::unconfigure()会调用glstudio模块中的unconfigure, 所以要放在前面
int ret = vpApp::unconfigure();
removeModel();
classShaderDeployer::instance()->removeAllShader();
return ret;
}
virtual void onKeyInput(vrWindow::Key _key, int _mod)
{
switch(_key)
{
case vrWindow::KEY_ESCAPE:
restart = false;
breakFrameLoop();
break;
case vrWindow::KEY_s:
vpApp::onKeyInput(_key,_mod);
break;
case vrWindow::KEY_F12:
restart = true;
breakFrameLoop();
break;
default:
classBase::traversalKey(_key,_mod);
}
}
virtual void notify(vsChannel::Event, const vsChannel *,vsTraversalCull *) {}
virtual void notify(vsChannel::Event _event, const vsChannel *_channel, vrDrawContext *_context)
{
classBase::traversalDrawEvent(_event, _channel, _context);
}
bool loadModel(void);
void removeModel(void);
virtual void run(void)
{
while( beginFrame() != 0)
{
endFrame();
classBase::traversalRunLoop();
if (!isLoaded)
{
breakFrameLoop();
}
}
unconfigure();
}
protected:
private:
classDve *pDve;
classSensor *pSensor;
classGeometry* pGeometry;
bool isLoaded; //true 模型已经加载 false 模型加载被取消
};
bool myApp::restart = true;
int _tmain(int argc, _TCHAR* argv[])
{
while(myApp::restart)
{
myApp::restart = false;
// initialize Vega Prime
vp::initialize(argc, argv);
vpModule::initializeModule( "vpGLStudio" );
vrUserGeometry::initializeClass(); //这个必须要执行,否则s_classtype为NULL,同时必须有配套的shutdownClass()方法配套
// create my app instance
myApp *app = new myApp;
// use the code generated by LynX Prime
app->define("E:\\newstart\\Data_ACF\\SensorAll_1.acf");
// configure my app instance
app->configure();
// execute the main runtime loop
app->run();
// delete my app instance
app->unref();
vrUserGeometry::shutdownClass();//与shutdownClass()方法配套
// shutdown Vega Prime
vp::shutdown();
}
//system("pause");
return 0;
}
bool myApp::loadModel(void)
{
static char __full_name[MAX_PATH];
static char __directory[MAX_PATH];
static char __file_name[MAX_PATH];
vpScene *__scene = vpScene::find("myScene");
if (__scene == NULL)
{
std::cout << "load new model : Need \"myScene\" in .acf!" << std::endl;
system("pause");
return false;
}
if (getPath(__full_name) > 0)
{
getDirectoryAndFileNameFromFullPath(__directory, __file_name, __full_name);
}
else
return false;
vpSearchPath *__search_path = vpSearchPath::find("mySearchPath");
__search_path->append(__directory);
vpObject * _object = vpObject::find("myObject");
if (_object != NULL)
{std::cout << "load new model() : last mode is still existing!" << std::endl;system("pause");}
_object = new vpObject();
_object->setName( "myObject" );
_object->setCullMask( 0x0FFFFFFFF );
_object->setRenderMask( 0x0FFFFFFFF );
_object->setIsectMask( 0x0FFFFFFFF );
_object->setStrategyEnable( false );
_object->setTranslate( 0.000000 , 0.000000 , 0.000000 );
_object->setRotate( 0.000000 , 0.000000 , 0.000000 );
_object->setScale( 1.000000 , 1.000000 , 1.000000 );
_object->setStaticEnable( false );
_object->setFileName(__file_name);
_object->setAutoPage( vpObject::AUTO_PAGE_SYNCHRONOUS );
_object->setManualLODChild( -1 );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_COMBINE_LIGHT_POINTS , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_COMBINE_LODS , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_IGNORE_DOF_CONSTRAINTS , false );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_EXTERNAL_REF_FLAGS , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_GENERIC_NAMES , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_GENERIC_NODES , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_QUADS , false );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_ALL_GEOMETRIES_LIT , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_USE_MATERIAL_DIFFUSE_COLOR , false );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_MONOCHROME , false );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_CREATE_ANIMATIONS , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_CONTROLS , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_ANIMATIONS , true );
_object->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_APPEARANCES , true );
_object->setLoaderDetailMultiTextureStage( -1 );
_object->setLoaderBlendTolerance( 0.050000f );
_object->setLoaderUnits( vsNodeLoader::Data::LOADER_UNITS_METERS );
_object->setBuilderOption( vsNodeLoader::Data::BUILDER_OPTION_OPTIMIZE_GEOMETRIES , true );
_object->setBuilderOption( vsNodeLoader::Data::BUILDER_OPTION_COLLAPSE_BINDINGS , true );
_object->setBuilderOption( vsNodeLoader::Data::BUILDER_OPTION_COLLAPSE_TRIANGLE_STRIPS , true );
_object->setBuilderNormalMode( vsNodeLoader::Data::BUILDER_NORMAL_MODE_PRESERVE );
_object->setBuilderColorTolerance( 0.001000f );
_object->setBuilderNormalTolerance( 0.860000f );
_object->setBuilderVertexTolerance( 0.000100f );
_object->setGeometryOption( vsNodeLoader::Data::GEOMETRY_OPTION_GENERATE_DISPLAY_LISTS , true );
_object->setGeometryFormat( vrGeometryBase::FORMAT_VERTEX_ARRAY , 0x0FFF );
_object->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_FLATTEN , true );
_object->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_CLEAN , true );
_object->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_MERGE_GEOMETRIES , true );
_object->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_COLLAPSE_BINDINGS , true );
_object->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_COLLAPSE_TRIANGLE_STRIPS , true );
_object->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_VALIDATE , true );
_object->setTextureSubloadEnable( false );
_object->setTextureSubloadRender( vpGeometry::TEXTURE_SUBLOAD_RENDER_DEFERRED );
_object->ref();
__scene->addChild(_object);
return true;
}
void myApp::removeModel(void)
{
vpObject * _object = vpObject::find("myObject");
if (_object == NULL)
{
std::cout << "removeModel() : model is not existing!" << std::endl;
return;
}
vpScene *__scene = vpScene::find("myScene");
__scene->removeChild(_object);
//cout << _object->getRef() << endl;
_object->unref();
}