mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 03:40:20 +02:00
commit
e638805bd7
7 changed files with 34 additions and 413 deletions
|
@ -1,201 +0,0 @@
|
||||||
//
|
|
||||||
// Finger.cpp
|
|
||||||
// interface
|
|
||||||
//
|
|
||||||
// Created by Philip on 1/21/13.
|
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "Finger.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
float fminf( float x, float y )
|
|
||||||
{
|
|
||||||
return x < y ? x : y;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const int NUM_BEADS = 75;
|
|
||||||
const float RADIUS = 50; // Radius of beads around finger
|
|
||||||
|
|
||||||
const int NUM_PUCKS = 10;
|
|
||||||
|
|
||||||
Finger::Finger(int w, int h) {
|
|
||||||
width = w;
|
|
||||||
height = h;
|
|
||||||
pos.x = pos.y = 0;
|
|
||||||
vel.x = vel.y = 0;
|
|
||||||
target.x = target.y = 0;
|
|
||||||
m = 1;
|
|
||||||
pressure = 0;
|
|
||||||
start = true;
|
|
||||||
// Create surface beads
|
|
||||||
beads = new bead[NUM_BEADS];
|
|
||||||
pucks = new puck[NUM_PUCKS];
|
|
||||||
|
|
||||||
float alpha = 0;
|
|
||||||
for (int i = 0; i < NUM_BEADS; i++) {
|
|
||||||
beads[i].target.x = cosf(alpha)*RADIUS + 2.0f*(randFloat() - 0.5f);
|
|
||||||
beads[i].target.y = sinf(alpha)*RADIUS + 2.0f*(randFloat() - 0.5f);
|
|
||||||
beads[i].pos.x = beads[i].pos.y = 0.0;
|
|
||||||
beads[i].vel.x = beads[i].vel.y = 0.0;
|
|
||||||
alpha += 2.0f*PIf/NUM_BEADS;
|
|
||||||
beads[i].color[0] = randFloat()*0.05f; beads[i].color[1] = randFloat()*0.05f; beads[i].color[2] = 0.75f + randFloat()*0.25f;
|
|
||||||
beads[i].brightness = 0.0;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < NUM_PUCKS; i++) {
|
|
||||||
pucks[i].pos.x = randFloat()*width;
|
|
||||||
pucks[i].pos.y = randFloat()*height;
|
|
||||||
pucks[i].radius = 5.0f + randFloat()*30.0f;
|
|
||||||
pucks[i].vel.x = pucks[i].vel.y = 0.0;
|
|
||||||
pucks[i].mass = pucks[i].radius*pucks[i].radius/25.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const float SHADOW_COLOR[4] = {0.0, 0.0, 0.0, 0.75};
|
|
||||||
const float SHADOW_OFFSET = 2.5;
|
|
||||||
|
|
||||||
void Finger::render() {
|
|
||||||
glEnable(GL_POINT_SMOOTH);
|
|
||||||
|
|
||||||
glPointSize(30.0f);
|
|
||||||
glBegin(GL_POINTS);
|
|
||||||
glColor4fv(SHADOW_COLOR);
|
|
||||||
glVertex2f(pos.x + SHADOW_OFFSET, pos.y + SHADOW_OFFSET);
|
|
||||||
glColor4f(0.0, 0.0, 0.7f, 1.0);
|
|
||||||
glVertex2f(pos.x, pos.y);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Render Pucks
|
|
||||||
for (int i = 0; i < NUM_PUCKS; i++) {
|
|
||||||
glColor4fv(SHADOW_COLOR);
|
|
||||||
glPointSize(pucks[i].radius*2.f);
|
|
||||||
glBegin(GL_POINTS);
|
|
||||||
glVertex2f(pucks[i].pos.x + SHADOW_OFFSET, pucks[i].pos.y + SHADOW_OFFSET);
|
|
||||||
glColor4f(1.0, 0.0, 0.0, 1.0);
|
|
||||||
glVertex2f(pucks[i].pos.x, pucks[i].pos.y);
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render beads
|
|
||||||
glPointSize(5.0f);
|
|
||||||
glLineWidth(3.0);
|
|
||||||
|
|
||||||
glBegin(GL_POINTS);
|
|
||||||
for (int i = 0; i < NUM_BEADS; i++) {
|
|
||||||
glColor4fv(SHADOW_COLOR);
|
|
||||||
glVertex2f(beads[i].pos.x + SHADOW_OFFSET, beads[i].pos.y + SHADOW_OFFSET);
|
|
||||||
glColor3f(beads[i].color[0]+beads[i].brightness, beads[i].color[1]+beads[i].brightness, beads[i].color[2]+beads[i].brightness);
|
|
||||||
glVertex2f(beads[i].pos.x, beads[i].pos.y);
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Finger::setTarget(int x, int y) {
|
|
||||||
target.x = static_cast<float>(x);
|
|
||||||
target.y = static_cast<float>(y);
|
|
||||||
if (start) {
|
|
||||||
// On startup, set finger to first target location
|
|
||||||
pos.x = target.x;
|
|
||||||
pos.y = target.y;
|
|
||||||
vel.x = vel.y = 0.0;
|
|
||||||
start = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Finger::simulate(float deltaTime) {
|
|
||||||
// Using the new target position x and y as where the mouse intends the finger to be, move the finger
|
|
||||||
if (!start) {
|
|
||||||
|
|
||||||
// Move the finger
|
|
||||||
float distance = glm::distance(pos, target);
|
|
||||||
//float spring_length = 0;
|
|
||||||
const float SPRING_FORCE = 1000.0;
|
|
||||||
|
|
||||||
if (distance > 0.1) {
|
|
||||||
vel += glm::normalize(target - pos)*deltaTime*SPRING_FORCE*distance;
|
|
||||||
}
|
|
||||||
// Decay Velocity (Drag)
|
|
||||||
|
|
||||||
vel *= 0.8;
|
|
||||||
//vel *= (1.f - CONSTANT_DAMPING*deltaTime);
|
|
||||||
|
|
||||||
// Update position
|
|
||||||
pos += vel*deltaTime;
|
|
||||||
|
|
||||||
// Update the beads
|
|
||||||
const float BEAD_SPRING_FORCE = 500.0;
|
|
||||||
const float BEAD_NEIGHBOR_FORCE = 200.0;
|
|
||||||
const float HARD_SPHERE_FORCE = 2500.0;
|
|
||||||
const float PRESSURE_FACTOR = 0.00;
|
|
||||||
float separation, contact;
|
|
||||||
float newPressure = 0;
|
|
||||||
int n1, n2;
|
|
||||||
float d1, d2;
|
|
||||||
|
|
||||||
for (int i = 0; i < NUM_BEADS; i++) {
|
|
||||||
distance = glm::distance(beads[i].pos, pos + beads[i].target * (1.f + pressure*PRESSURE_FACTOR));
|
|
||||||
if (distance > 0.1) {
|
|
||||||
beads[i].vel += glm::normalize((pos + (beads[i].target*(1.f + pressure*PRESSURE_FACTOR))) - beads[i].pos)*deltaTime*BEAD_SPRING_FORCE*distance;
|
|
||||||
}
|
|
||||||
// Add forces from 2 neighboring beads
|
|
||||||
if ((i-1)>=0) n1 = i - 1;
|
|
||||||
else n1 = NUM_PUCKS - 1;
|
|
||||||
if ((i+1)<NUM_PUCKS) n2 = i + 1;
|
|
||||||
else n2 = 0;
|
|
||||||
d1 = glm::distance(beads[i].pos, beads[n1].pos);
|
|
||||||
if (d1 > 0.01) beads[i].vel += glm::normalize(beads[n1].pos - beads[i].pos)*deltaTime*BEAD_NEIGHBOR_FORCE*distance;
|
|
||||||
d2 = glm::distance(beads[i].pos, beads[n2].pos);
|
|
||||||
if (d2 > 0.01) beads[i].vel += glm::normalize(beads[n2].pos - beads[i].pos)*deltaTime*BEAD_NEIGHBOR_FORCE*distance;
|
|
||||||
|
|
||||||
|
|
||||||
// Look for hard collision with pucks
|
|
||||||
for (int j = 0; j < NUM_PUCKS; j++) {
|
|
||||||
|
|
||||||
separation = glm::distance(beads[i].pos, pucks[j].pos);
|
|
||||||
contact = 2.5f + pucks[j].radius;
|
|
||||||
|
|
||||||
// Hard Sphere Scattering
|
|
||||||
|
|
||||||
if (separation < contact) {
|
|
||||||
beads[i].vel += glm::normalize(beads[i].pos - pucks[j].pos)*
|
|
||||||
deltaTime*HARD_SPHERE_FORCE*(contact - separation);
|
|
||||||
pucks[j].vel -= glm::normalize(beads[i].pos - pucks[j].pos)*
|
|
||||||
deltaTime*HARD_SPHERE_FORCE*(contact - separation)/pucks[j].mass;
|
|
||||||
if (beads[i].brightness < 0.5) beads[i].brightness = 0.5;
|
|
||||||
beads[i].brightness *= 1.1f;
|
|
||||||
} else {
|
|
||||||
beads[i].brightness *= 0.95f;
|
|
||||||
}
|
|
||||||
beads[i].brightness = fminf(beads[i].brightness, 1.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Decay velocity, move beads
|
|
||||||
beads[i].vel *= 0.85;
|
|
||||||
beads[i].pos += beads[i].vel*deltaTime;
|
|
||||||
|
|
||||||
// Measure pressure for next run
|
|
||||||
newPressure += glm::distance(beads[i].pos, pos);
|
|
||||||
}
|
|
||||||
if (fabs(newPressure - NUM_BEADS*RADIUS) < 100.f) pressure = newPressure - (NUM_BEADS*RADIUS);
|
|
||||||
|
|
||||||
// Update the pucks for any pressure they have received
|
|
||||||
for (int j = 0; j < NUM_PUCKS; j++) {
|
|
||||||
pucks[j].vel *= 0.99;
|
|
||||||
|
|
||||||
if (pucks[j].radius < 25.0) pucks[j].pos += pucks[j].vel*deltaTime;
|
|
||||||
|
|
||||||
// wrap at edges
|
|
||||||
if (pucks[j].pos.x > width) pucks[j].pos.x = 0.0;
|
|
||||||
if (pucks[j].pos.x < 0) pucks[j].pos.x = static_cast<float>(width);
|
|
||||||
if (pucks[j].pos.y > height) pucks[j].pos.y = 0.0;
|
|
||||||
if (pucks[j].pos.y < 0) pucks[j].pos.y = static_cast<float>(height);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
//
|
|
||||||
// Finger.h
|
|
||||||
// interface
|
|
||||||
//
|
|
||||||
// Created by Philip on 1/21/13.
|
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef __interface__Finger__
|
|
||||||
#define __interface__Finger__
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include "Util.h"
|
|
||||||
#include "world.h"
|
|
||||||
#include "InterfaceConfig.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
class Finger {
|
|
||||||
public:
|
|
||||||
Finger(int w, int h);
|
|
||||||
void simulate(float deltaTime);
|
|
||||||
void render();
|
|
||||||
void setTarget(int x, int y);
|
|
||||||
private:
|
|
||||||
int width, height; // Screen size in pixels
|
|
||||||
bool start;
|
|
||||||
glm::vec2 pos, vel; // Position and velocity of finger
|
|
||||||
float m; // Velocity of finger
|
|
||||||
float pressure; // Internal pressure of skin vessel as function of measured volume
|
|
||||||
glm::vec2 target; // Where the mouse is
|
|
||||||
// little beads used to render the dynamic skin surface
|
|
||||||
struct bead {
|
|
||||||
glm::vec2 target, pos, vel;
|
|
||||||
float color[3];
|
|
||||||
float brightness;
|
|
||||||
} *beads;
|
|
||||||
struct puck {
|
|
||||||
glm::vec2 pos, vel;
|
|
||||||
float brightness;
|
|
||||||
float radius;
|
|
||||||
float mass;
|
|
||||||
} *pucks;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* defined(__interface__finger__) */
|
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
//
|
|
||||||
// Lattice.cpp
|
|
||||||
// interface
|
|
||||||
//
|
|
||||||
// Created by Philip on 1/19/13.
|
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "Lattice.h"
|
|
||||||
|
|
||||||
Lattice::Lattice(int w, int h) {
|
|
||||||
width = w;
|
|
||||||
height = h;
|
|
||||||
tilegap = 2;
|
|
||||||
lastindex = -1;
|
|
||||||
tiles = new Tile[width*height];
|
|
||||||
for (int i = 0; i < (width*height); i++) {
|
|
||||||
tiles[i].color[0] = tiles[i].color[1] = tiles[i].color[2] = 0.2f + randFloat()*0.3f;
|
|
||||||
tiles[i].x = static_cast<float>(i % width);
|
|
||||||
tiles[i].y = static_cast<float>(i/width);
|
|
||||||
tiles[i].brightness = 1.0;
|
|
||||||
tiles[i].type = 0;
|
|
||||||
tiles[i].excited = tiles[i].inhibited = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lattice::render(int screenWidth, int screenHeight) {
|
|
||||||
float tilewidth = static_cast<float>(screenWidth/width);
|
|
||||||
float tileheight = static_cast<float>(screenHeight/height);
|
|
||||||
float tilecolor[3];
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
for (int i = 0; i < (width*height); i++) {
|
|
||||||
if (tiles[i].type == 0) {
|
|
||||||
tilecolor[0] = 0.25; tilecolor[1] = 0.25; tilecolor[2] = 0.25;
|
|
||||||
} else if (tiles[i].type == 1) {
|
|
||||||
if (tiles[i].inhibited >= 0.1) {
|
|
||||||
tilecolor[0] = 0.5f; tilecolor[1] = 0.0; tilecolor[2] = 0.0;
|
|
||||||
} else {
|
|
||||||
tilecolor[0] = 0.2f; tilecolor[1] = 0.0; tilecolor[2] = 0.5f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
glColor3f(tilecolor[0]*(1.f+tiles[i].excited), tilecolor[1]*(1.f+tiles[i].excited), tilecolor[2]*(1.f+tiles[i].excited));
|
|
||||||
glVertex2f(tiles[i].x*tilewidth, tiles[i].y*tileheight);
|
|
||||||
glVertex2f((tiles[i].x + 1)*tilewidth - tilegap, tiles[i].y*tileheight);
|
|
||||||
glVertex2f((tiles[i].x + 1)*tilewidth - tilegap, (tiles[i].y + 1)*tileheight - tilegap);
|
|
||||||
glVertex2f(tiles[i].x*tilewidth, (tiles[i].y + 1)*tileheight - tilegap);
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lattice::mouseClick(float x, float y) {
|
|
||||||
// Update lattice based on mouse location, where x and y are floats between 0 and 1 corresponding to screen location clicked
|
|
||||||
// Change the clicked cell to a different type
|
|
||||||
//printf("X = %3.1f Y = %3.1f\n", x, y);
|
|
||||||
int index = int(x*(float)width) + int(y*(float)height)*width;
|
|
||||||
if (index != lastindex) {
|
|
||||||
tiles[index].type++;
|
|
||||||
if (tiles[index].type == 2) tiles[index].type = 0;
|
|
||||||
lastindex = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lattice::mouseOver(float x, float y) {
|
|
||||||
// Update lattice based on mouse location, where x and y are floats between 0 and 1 corresponding to screen location clicked
|
|
||||||
// Excite the hovered cell a bit toward firing
|
|
||||||
//printf("X = %3.1f Y = %3.1f\n", x, y);
|
|
||||||
if (0) {
|
|
||||||
int index = int(x*(float)width) + int(y*(float)height)*width;
|
|
||||||
if (tiles[index].type > 0) tiles[index].excited += 0.05f;
|
|
||||||
//printf("excited = %3.1f, inhibited = %3.1f\n", tiles[index].excited, tiles[index].inhibited);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lattice::simulate(float deltaTime) {
|
|
||||||
int index;
|
|
||||||
for (int i = 0; i < (width*height); i++) {
|
|
||||||
if (tiles[i].type > 0) {
|
|
||||||
if ((tiles[i].excited > 0.5) && (tiles[i].inhibited < 0.1)) {
|
|
||||||
tiles[i].excited = 1.0;
|
|
||||||
tiles[i].inhibited = 1.0;
|
|
||||||
// Add Energy to neighbors
|
|
||||||
for (int j = 0; j < 8; j++) {
|
|
||||||
if (j == 0) index = i - width - 1;
|
|
||||||
else if (j == 1) index = i - width;
|
|
||||||
else if (j == 2) index = i - width + 1;
|
|
||||||
else if (j == 3) index = i - 1;
|
|
||||||
else if (j == 4) index = i + 1;
|
|
||||||
else if (j == 5) index = i + width - 1;
|
|
||||||
else if (j == 6) index = i + width;
|
|
||||||
else index = i + width + 1;
|
|
||||||
if ((index > 0) && (index < width*height)) {
|
|
||||||
if (tiles[index].inhibited < 0.1) tiles[index].excited += 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tiles[i].excited *= 0.98f;
|
|
||||||
tiles[i].inhibited *= 0.98f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
//
|
|
||||||
// Lattice.h
|
|
||||||
// interface
|
|
||||||
//
|
|
||||||
// Created by Philip on 1/19/13.
|
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef __interface__Lattice__
|
|
||||||
#define __interface__Lattice__
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include "Util.h"
|
|
||||||
#include "world.h"
|
|
||||||
#include "InterfaceConfig.h"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
class Lattice {
|
|
||||||
public:
|
|
||||||
Lattice(int width, int height);
|
|
||||||
void simulate(float deltaTime);
|
|
||||||
void render(int screenWidth, int screenHeight);
|
|
||||||
void mouseClick(float x, float y);
|
|
||||||
void mouseOver(float x, float y);
|
|
||||||
private:
|
|
||||||
int lastindex;
|
|
||||||
int width, height;
|
|
||||||
int tilegap;
|
|
||||||
struct Tile {
|
|
||||||
float x,y;
|
|
||||||
float color[3];
|
|
||||||
float brightness;
|
|
||||||
float excited;
|
|
||||||
float inhibited;
|
|
||||||
int type;
|
|
||||||
} *tiles;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* defined(__interface__lattice__) */
|
|
|
@ -80,6 +80,23 @@ void render_world_box()
|
||||||
glVertex3f(0,0,0);
|
glVertex3f(0,0,0);
|
||||||
glVertex3f(0, 0, WORLD_SIZE);
|
glVertex3f(0, 0, WORLD_SIZE);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
// Draw little marker dots along the axis
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(WORLD_SIZE,0,0);
|
||||||
|
glColor3f(1,0,0);
|
||||||
|
glutSolidSphere(0.125,10,10);
|
||||||
|
glPopMatrix();
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(0,WORLD_SIZE,0);
|
||||||
|
glColor3f(0,1,0);
|
||||||
|
glutSolidSphere(0.125,10,10);
|
||||||
|
glPopMatrix();
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(0,0,WORLD_SIZE);
|
||||||
|
glColor3f(0,0,1);
|
||||||
|
glutSolidSphere(0.125,10,10);
|
||||||
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
double diffclock(timeval *clock1,timeval *clock2)
|
double diffclock(timeval *clock1,timeval *clock2)
|
||||||
|
|
|
@ -69,8 +69,6 @@
|
||||||
#include <AgentList.h>
|
#include <AgentList.h>
|
||||||
#include <AgentTypes.h>
|
#include <AgentTypes.h>
|
||||||
#include "VoxelSystem.h"
|
#include "VoxelSystem.h"
|
||||||
#include "Lattice.h"
|
|
||||||
#include "Finger.h"
|
|
||||||
#include "Oscilloscope.h"
|
#include "Oscilloscope.h"
|
||||||
#include "UDPSocket.h"
|
#include "UDPSocket.h"
|
||||||
#include "SerialInterface.h"
|
#include "SerialInterface.h"
|
||||||
|
@ -128,9 +126,6 @@ Cloud cloud(0, // Particles
|
||||||
);
|
);
|
||||||
|
|
||||||
VoxelSystem voxels;
|
VoxelSystem voxels;
|
||||||
|
|
||||||
Lattice lattice(160,100);
|
|
||||||
Finger myFinger(WIDTH, HEIGHT);
|
|
||||||
Field field;
|
Field field;
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -197,6 +192,9 @@ float FPS = 120.f;
|
||||||
timeval timerStart, timerEnd;
|
timeval timerStart, timerEnd;
|
||||||
timeval lastTimeIdle;
|
timeval lastTimeIdle;
|
||||||
double elapsedTime;
|
double elapsedTime;
|
||||||
|
timeval applicationStartupTime;
|
||||||
|
bool justStarted = true;
|
||||||
|
|
||||||
|
|
||||||
// Every second, check the frame rates and other stuff
|
// Every second, check the frame rates and other stuff
|
||||||
void Timer(int extra)
|
void Timer(int extra)
|
||||||
|
@ -234,7 +232,7 @@ void displayStats(void)
|
||||||
glm::vec3 avatarPos = myAvatar.getPos();
|
glm::vec3 avatarPos = myAvatar.getPos();
|
||||||
|
|
||||||
char stats[200];
|
char stats[200];
|
||||||
sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)=( %f , %f , %f )",
|
sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ",
|
||||||
FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z);
|
FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z);
|
||||||
drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats);
|
drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats);
|
||||||
if (serialPort.active) {
|
if (serialPort.active) {
|
||||||
|
@ -319,6 +317,7 @@ void init(void)
|
||||||
}
|
}
|
||||||
myAvatar.setPos(start_location );
|
myAvatar.setPos(start_location );
|
||||||
myCamera.setPosition( start_location );
|
myCamera.setPosition( start_location );
|
||||||
|
|
||||||
|
|
||||||
#ifdef MARKER_CAPTURE
|
#ifdef MARKER_CAPTURE
|
||||||
if(marker_capture_enabled){
|
if(marker_capture_enabled){
|
||||||
|
@ -802,7 +801,7 @@ void display(void)
|
||||||
float sphereRadius = 0.25f;
|
float sphereRadius = 0.25f;
|
||||||
glColor3f(1,0,0);
|
glColor3f(1,0,0);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef( 0.0f, sphereRadius, 0.0f );
|
//glTranslatef( 0.0f, sphereRadius, 0.0f );
|
||||||
glutSolidSphere( sphereRadius, 15, 15 );
|
glutSolidSphere( sphereRadius, 15, 15 );
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
@ -861,9 +860,7 @@ void display(void)
|
||||||
gluOrtho2D(0, WIDTH, HEIGHT, 0);
|
gluOrtho2D(0, WIDTH, HEIGHT, 0);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
|
|
||||||
//lattice.render(WIDTH, HEIGHT);
|
|
||||||
//myFinger.render();
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
audio.render(WIDTH, HEIGHT);
|
audio.render(WIDTH, HEIGHT);
|
||||||
if (audioScope.getState()) audioScope.render();
|
if (audioScope.getState()) audioScope.render();
|
||||||
|
@ -921,6 +918,13 @@ void display(void)
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
frameCount++;
|
frameCount++;
|
||||||
|
|
||||||
|
// If application has just started, report time from startup to now (first frame display)
|
||||||
|
if (justStarted) {
|
||||||
|
printf("Startup Time: %4.2f\n",
|
||||||
|
(usecTimestampNow() - usecTimestamp(&applicationStartupTime))/1000000.0);
|
||||||
|
justStarted = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int setValue(int state, int *value) {
|
int setValue(int state, int *value) {
|
||||||
|
@ -1269,8 +1273,6 @@ void idle(void)
|
||||||
myAvatar.simulate(1.f/FPS);
|
myAvatar.simulate(1.f/FPS);
|
||||||
balls.simulate(1.f/FPS);
|
balls.simulate(1.f/FPS);
|
||||||
cloud.simulate(1.f/FPS);
|
cloud.simulate(1.f/FPS);
|
||||||
lattice.simulate(1.f/FPS);
|
|
||||||
myFinger.simulate(1.f/FPS);
|
|
||||||
|
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
lastTimeIdle = check;
|
lastTimeIdle = check;
|
||||||
|
@ -1313,7 +1315,6 @@ void mouseFunc( int button, int state, int x, int y )
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
mousePressed = 1;
|
mousePressed = 1;
|
||||||
lattice.mouseClick((float)x/(float)WIDTH, (float)y/(float)HEIGHT);
|
|
||||||
mouseStartX = x;
|
mouseStartX = x;
|
||||||
mouseStartY = y;
|
mouseStartY = y;
|
||||||
}
|
}
|
||||||
|
@ -1330,8 +1331,6 @@ void motionFunc( int x, int y)
|
||||||
{
|
{
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
|
|
||||||
lattice.mouseClick((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseoverFunc( int x, int y)
|
void mouseoverFunc( int x, int y)
|
||||||
|
@ -1340,10 +1339,7 @@ void mouseoverFunc( int x, int y)
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
if (mousePressed == 0)
|
if (mousePressed == 0)
|
||||||
{
|
{}
|
||||||
// lattice.mouseOver((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
|
|
||||||
// myFinger.setTarget(mouseX, mouseY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void attachNewHeadToAgent(Agent *newAgent) {
|
void attachNewHeadToAgent(Agent *newAgent) {
|
||||||
|
@ -1362,6 +1358,7 @@ int main(int argc, const char * argv[])
|
||||||
{
|
{
|
||||||
AgentList::createInstance(AGENT_TYPE_INTERFACE);
|
AgentList::createInstance(AGENT_TYPE_INTERFACE);
|
||||||
|
|
||||||
|
gettimeofday(&applicationStartupTime, NULL);
|
||||||
const char* domainIP = getCmdOption(argc, argv, "--domain");
|
const char* domainIP = getCmdOption(argc, argv, "--domain");
|
||||||
if (domainIP) {
|
if (domainIP) {
|
||||||
strcpy(DOMAIN_IP,domainIP);
|
strcpy(DOMAIN_IP,domainIP);
|
||||||
|
|
|
@ -390,7 +390,7 @@ void *checkInWithDomainServer(void *args) {
|
||||||
sockaddr_in tempAddress;
|
sockaddr_in tempAddress;
|
||||||
memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
|
memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
|
||||||
strcpy(DOMAIN_IP, inet_ntoa(tempAddress.sin_addr));
|
strcpy(DOMAIN_IP, inet_ntoa(tempAddress.sin_addr));
|
||||||
printf("Domain server %s: \n", DOMAIN_HOSTNAME);
|
printf("Domain server: %s \n", DOMAIN_HOSTNAME);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("Failed lookup domainserver\n");
|
printf("Failed lookup domainserver\n");
|
||||||
|
|
Loading…
Reference in a new issue