-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainsub_opbr_plyascii.cpp
executable file
·172 lines (136 loc) · 5.16 KB
/
mainsub_opbr_plyascii.cpp
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
//////////////////////////////////////
///// mainsub_opbr_plyascii.cpp /////
//////////////////////////////////////
#include <kvs/glut/Application>
#include <kvs/Version> //KVS2
#if KVS_VERSION_MAJOR == 1
#include <kvs/glew/PointRenderer> //KVS1
#elif KVS_VERSION_MAJOR == 2
#include <kvs/PointRenderer> //KVS2
#endif
#include <kvs/glut/Screen>
#include <kvs/RotationMatrix33>
#include <cstring>
#include <iostream>
#include "fpscount.h"
#include "event_control.h"
#include "wireframebox.h"
#include "spbr.h"
#include "version.h"
#include "display_opbr_usage.h"
#include "toolxform.h"
#include "mainfn_utility.h"
//#define DEBUG_MAIN
//-----
int mainsub_opbr_plyascii ( int argc, char** argv )
{
// Create an application
kvs::glut::Application app( argc, argv );
InitializeEvent init;
KeyPressEvent key;
// Read the first data file (argv[1])
SPBR* spbr_engine = new SPBR( argv[1], PLY_ASCII );
kvs::PointObject* object = spbr_engine ;
// Read and append the remaining files:
// argv[2], argv[3], ..., argv[argc-1]
for (int i = 3; i <= argc; i++) {
if ( isASCII_PLY_File(argv[i - 1]) ) {
SPBR* spbr_tmp = new SPBR(argv[i - 1], PLY_ASCII);
object->add(*kvs::PointObject::DownCast(spbr_tmp));
}
else if ( isBINARY_PLY_File(argv[i - 1]) ) {
SPBR* spbr_tmp = new SPBR(argv[i - 1], PLY_BINARY);
object->add(*kvs::PointObject::DownCast(spbr_tmp));
}
else if ( isBinarySPBR_File(argv[i - 1]) ) {
SPBR* spbr_tmp = new SPBR(argv[i - 1], SPBR_BINARY);
object->add(*kvs::PointObject::DownCast(spbr_tmp));
}
else {
SPBR* spbr_tmp = new SPBR(argv[i - 1], SPBR_ASCII);
object->add(*kvs::PointObject::DownCast(spbr_tmp));
}
}//for
// Set the total bounding box
// Note: This updates the total bounding box of the
// read point objects.
addBoundingBoxToScene ( spbr_engine ) ;
#if defined DEBUG_MAIN
std::cout << *object << std::endl;
#endif
#if KVS_VERSION_MAJOR == 1
kvs::glew::PointRenderer* renderer = new kvs::glew::PointRenderer();//KVS1
#elif KVS_VERSION_MAJOR == 2
kvs::glsl::PointRenderer* renderer = new kvs::glsl::PointRenderer(); //KVS2
#endif
// Set Lambert shading or keep Phong shading
setShadingType ( spbr_engine, renderer ) ;
// Shading control
if( spbr_engine->isShading() == false ) {
std::cout << "** Shading is off" << std::endl;
renderer->disableShading();
}
// Create a screen and make registration
kvs::glut::Screen screen( &app );
screen.registerObject( object, renderer );
// Mouse rotation speed //ROTSPEED
double mouse_rot_speed = spbr_engine->mouseRotSpeed(); // get scaling factor
double virtual_sphere_size = screen.scene()->mouse()->trackball().size();
virtual_sphere_size /= mouse_rot_speed ;
screen.scene()->mouse()->trackball().setSize( virtual_sphere_size );
// Mouse zoom speed //ZOOMSPEED
double mouse_zoom_speed = spbr_engine->mouseZoomSpeed(); // get scaling factor
mouse_zoom_speed *= screen.scene()->mouse()->trackball().scalingFactor();
screen.scene()->mouse()->trackball().setScalingFactor( mouse_zoom_speed );
/////2018/10/17
//// Object rotation (Z==>X)
if ( spbr_engine->isZXRotation() ) {
double zrot_deg = spbr_engine->objectZXRotAngle (0) ;
double xrot_deg = spbr_engine->objectZXRotAngle (1) ;
ToolXform::rotateZX( object, zrot_deg, xrot_deg, kvs::Vector3f( 0, 0, 0 ) );
} // if object rotation (Z==>X)
// Create wireframe-box line object if required
drawWireframeBox( spbr_engine, &screen );
// Set camera type (orthogonal/perspective) and
// other camera parameters:
// camera position, look-at position, and view angle
setCameraParameters ( spbr_engine, &screen );
// Window title
char WINDOW_TITLE[256];
strcpy( WINDOW_TITLE, OPBR_WINDOW_TITLE );
strcat( WINDOW_TITLE, " with GLSL" );
strcat( WINDOW_TITLE, " (" );
strcat( WINDOW_TITLE, argv[1] );
strcat( WINDOW_TITLE, ")" );
// Set camera type (orthogonal/perspective) and
// other camera parameters:
// camera position, look-at position, and view angle
//setCameraParameters ( spbr_engine, &screen );
// Draw
unsigned int img_resoln = spbr_engine->imageResolution();
screen.setGeometry( 0, 0, img_resoln, img_resoln );
#if KVS_VERSION_MAJOR == 1
screen.background()->setColor( spbr_engine->backGroundColor() ); //KVS1
#elif KVS_VERSION_MAJOR == 2
screen.setBackgroundColor ( spbr_engine->backGroundColor() );//KVS2
#endif
screen.setTitle( WINDOW_TITLE );
screen.addEvent( &init );
screen.addEvent( &key );
screen.show();
std::cout << "** Executing particle-based rendering..." << std::endl;
key.displayMenu();
// FPS count
/***** //TANAKA
FPSLabel fpslabel( &screen );
if( spbr_engine->isFPSDisplayed()) {
kvs::RGBColor textcolor( 255 - spbr_engine->bg_Rb() ,
255 - spbr_engine->bg_Gb() ,
255 - spbr_engine->bg_Bb() );
fpslabel.setTextColor(textcolor);
fpslabel.show();
}
*****/
// Start
return( app.run() );
} // mainsub_opbr_plyascii ()