History

Merge remote-tracking branch 'upstream/master'

Jeffrey Ventrella committed 13 years ago

Commit 40213df2 parents 5c7fd0f 83c8ac616 files · +624 −204Browse files

Showing the changes to interface/src/main.cpp (1 of 16 files). Show all

Unified · Split

interface/src/main.cpp+14−16
@@ -204,8 +204,7 @@ bool justStarted = true; · 203 unmodified lines
204 204
205 205
206// Every second, check the frame rates and other stuff206// Every second, check the frame rates and other stuff
207void Timer(int extra)207void Timer(int extra) {
208{
209 gettimeofday(&timerEnd, NULL);208 gettimeofday(&timerEnd, NULL);
210 FPS = (float)frameCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f);209 FPS = (float)frameCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f);
211 packetsPerSecond = (float)packetCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f);210 packetsPerSecond = (float)packetCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f);
@@ -223,8 +222,7 @@ void Timer(int extra) · 11 unmodified lines
223 }222 }
224}223}
225 224
226void displayStats(void)225void displayStats(void) {
227{
228 int statsVerticalOffset = 50;226 int statsVerticalOffset = 50;
229 if (::menuOn == 0) {227 if (::menuOn == 0) {
230 statsVerticalOffset = 8;228 statsVerticalOffset = 8;
@@ -265,6 +263,7 @@ void displayStats(void) · 34 unmodified lines
265 263
266 Agent *avatarMixer = AgentList::getInstance()->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER);264 Agent *avatarMixer = AgentList::getInstance()->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER);
267 char avatarMixerStats[200];265 char avatarMixerStats[200];
266
268 if (avatarMixer) {267 if (avatarMixer) {
269 sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",268 sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
270 roundf(avatarMixer->getAverageKilobitsPerSecond()),269 roundf(avatarMixer->getAverageKilobitsPerSecond()),
@@ -272,6 +271,7 @@ void displayStats(void) · 1 unmodified line
272 } else {271 } else {
273 sprintf(avatarMixerStats, "No Avatar Mixer");272 sprintf(avatarMixerStats, "No Avatar Mixer");
274 }273 }
274
275 drawtext(10, statsVerticalOffset + 330, 0.10f, 0, 1.0, 0, avatarMixerStats);275 drawtext(10, statsVerticalOffset + 330, 0.10f, 0, 1.0, 0, avatarMixerStats);
276 276
277 if (::perfStatsOn) {277 if (::perfStatsOn) {
@@ -289,8 +289,7 @@ void displayStats(void) · 11 unmodified lines
289 }289 }
290}290}
291 291
292void initDisplay(void)292void initDisplay(void) {
293{
294 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);293 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
295 glEnable(GL_BLEND);294 glEnable(GL_BLEND);
296 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);295 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -302,8 +301,7 @@ void initDisplay(void) · 5 unmodified lines
302 if (fullscreen) glutFullScreen();301 if (fullscreen) glutFullScreen();
303}302}
304 303
305void init(void)304void init(void) {
306{
307 voxels.init();305 voxels.init();
308 voxels.setViewerAvatar(&myAvatar);306 voxels.setViewerAvatar(&myAvatar);
309 voxels.setCamera(&myCamera);307 voxels.setCamera(&myCamera);
@@ -356,8 +354,7 @@ void terminate () { · 46 unmodified lines
356 exit(EXIT_SUCCESS);354 exit(EXIT_SUCCESS);
357}355}
358 356
359void reset_sensors()357void reset_sensors() {
360{
361 358
362 myAvatar.setPosition(start_location);359 myAvatar.setPosition(start_location);
363 headMouseX = WIDTH/2;360 headMouseX = WIDTH/2;
@@ -373,16 +370,13 @@ void reset_sensors() · 9 unmodified lines
373//370//
374// Using gyro data, update both view frustum and avatar head position371// Using gyro data, update both view frustum and avatar head position
375//372//
376void updateAvatar(float frametime)373void updateAvatar(float frametime) {
377{
378 float gyroPitchRate = serialPort.getRelativeValue(HEAD_PITCH_RATE);374 float gyroPitchRate = serialPort.getRelativeValue(HEAD_PITCH_RATE);
379 float gyroYawRate = serialPort.getRelativeValue(HEAD_YAW_RATE );375 float gyroYawRate = serialPort.getRelativeValue(HEAD_YAW_RATE );
380 376
381 myAvatar.UpdateGyros(frametime, &serialPort, &gravity);377 myAvatar.UpdateGyros(frametime, &serialPort, &gravity);
382 378
383 //
384 // Update gyro-based mouse (X,Y on screen)379 // Update gyro-based mouse (X,Y on screen)
385 //
386 const float MIN_MOUSE_RATE = 30.0;380 const float MIN_MOUSE_RATE = 30.0;
387 const float MOUSE_SENSITIVITY = 0.1f;381 const float MOUSE_SENSITIVITY = 0.1f;
388 if (powf(gyroYawRate*gyroYawRate + 382 if (powf(gyroYawRate*gyroYawRate +
@@ -397,7 +391,7 @@ void updateAvatar(float frametime) · 8 unmodified lines
397 headMouseY = min(headMouseY, HEIGHT);391 headMouseY = min(headMouseY, HEIGHT);
398 392
399 // Update head and body pitch and yaw based on measured gyro rates393 // Update head and body pitch and yaw based on measured gyro rates
400 if (::gyroLook) {394 if (::gyroLook) {
401 // Yaw395 // Yaw
402 const float MIN_YAW_RATE = 50;396 const float MIN_YAW_RATE = 50;
403 const float YAW_SENSITIVITY = 1.0;397 const float YAW_SENSITIVITY = 1.0;
@@ -1686,6 +1680,10 @@ void idle(void) { · 1282 unmodified lines
1686 handControl.stop();1680 handControl.stop();
1687 }1681 }
1688 1682
1683 if (serialPort.active && USING_INVENSENSE_MPU9150) {
1684 serialPort.readData();
1685 }
1686
1689 // Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents1687 // Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents
1690 updateAvatar(deltaTime);1688 updateAvatar(deltaTime);
1691 1689
@@ -1712,7 +1710,7 @@ void idle(void) { · 20 unmodified lines
1712 }1710 }
1713 1711
1714 // Read serial data 1712 // Read serial data
1715 if (serialPort.active) {1713 if (serialPort.active && !USING_INVENSENSE_MPU9150) {
1716 serialPort.readData();1714 serialPort.readData();
1717 }1715 }
1718}1716}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t