mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 17:10:41 +02:00
merge with upstream master and resolve conflicts
This commit is contained in:
commit
dc11055f8e
8 changed files with 166 additions and 372 deletions
|
@ -126,7 +126,7 @@ void *sendBuffer(void *args)
|
||||||
int16_t clientMix[BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2] = {};
|
int16_t clientMix[BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2] = {};
|
||||||
|
|
||||||
|
|
||||||
for (AgentList::iterator otherAgent = agentList->begin(); agent != agentList->end(); agent++) {
|
for (AgentList::iterator otherAgent = agentList->begin(); otherAgent != agentList->end(); otherAgent++) {
|
||||||
if (otherAgent != agent || ( otherAgent == agent && agentWantsLoopback)) {
|
if (otherAgent != agent || ( otherAgent == agent && agentWantsLoopback)) {
|
||||||
AudioRingBuffer* otherAgentBuffer = (AudioRingBuffer*) otherAgent->getLinkedData();
|
AudioRingBuffer* otherAgentBuffer = (AudioRingBuffer*) otherAgent->getLinkedData();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
const bool BALLS_ON = false;
|
||||||
|
|
||||||
float skinColor[] = {1.0, 0.84, 0.66};
|
float skinColor[] = {1.0, 0.84, 0.66};
|
||||||
float lightBlue[] = { 0.7, 0.8, 1.0 };
|
float lightBlue[] = { 0.7, 0.8, 1.0 };
|
||||||
float browColor[] = {210.0/255.0, 105.0/255.0, 30.0/255.0};
|
float browColor[] = {210.0/255.0, 105.0/255.0, 30.0/255.0};
|
||||||
|
@ -129,6 +131,9 @@ Avatar::Avatar(bool isMine) {
|
||||||
printLog("error %u: %s\n", error, lodepng_error_text(error));
|
printLog("error %u: %s\n", error, lodepng_error_text(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (BALLS_ON) { _balls = new Balls(100); }
|
||||||
|
else { _balls = NULL; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,6 +296,9 @@ void Avatar::setMousePressed( bool d ) {
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime) {
|
void Avatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
|
// update balls
|
||||||
|
if (_balls) { _balls->simulate(deltaTime); }
|
||||||
|
|
||||||
// update avatar skeleton
|
// update avatar skeleton
|
||||||
updateSkeleton();
|
updateSkeleton();
|
||||||
|
|
||||||
|
@ -616,6 +624,15 @@ void Avatar::render(bool lookingInMirror) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render the balls
|
||||||
|
|
||||||
|
if (_balls) {
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(_position.x, _position.y, _position.z);
|
||||||
|
_balls->render();
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
if (!_chatMessage.empty()) {
|
if (!_chatMessage.empty()) {
|
||||||
float width = 0;
|
float width = 0;
|
||||||
float lastWidth;
|
float lastWidth;
|
||||||
|
@ -656,7 +673,6 @@ void Avatar::render(bool lookingInMirror) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Avatar::renderHead(bool lookingInMirror) {
|
void Avatar::renderHead(bool lookingInMirror) {
|
||||||
int side = 0;
|
int side = 0;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
#include <glm/gtx/quaternion.hpp> //looks like we might not need this
|
#include <glm/gtx/quaternion.hpp> //looks like we might not need this
|
||||||
|
|
||||||
|
#include "Balls.h"
|
||||||
|
|
||||||
const bool AVATAR_GRAVITY = true;
|
const bool AVATAR_GRAVITY = true;
|
||||||
const float DECAY = 0.1;
|
const float DECAY = 0.1;
|
||||||
const float THRUST_MAG = 1200.0;
|
const float THRUST_MAG = 1200.0;
|
||||||
|
@ -265,41 +267,8 @@ private:
|
||||||
Avatar* _interactingOther;
|
Avatar* _interactingOther;
|
||||||
bool _interactingOtherIsNearby;
|
bool _interactingOtherIsNearby;
|
||||||
float _pelvisStandingHeight;
|
float _pelvisStandingHeight;
|
||||||
|
Balls* _balls;
|
||||||
/*
|
AvatarTouch _avatarTouch;
|
||||||
private:
|
|
||||||
AvatarHead _head;
|
|
||||||
bool _isMine;
|
|
||||||
glm::vec3 _TEST_bigSpherePosition;
|
|
||||||
float _TEST_bigSphereRadius;
|
|
||||||
bool _mousePressed;
|
|
||||||
float _bodyYawDelta;
|
|
||||||
bool _usingBodySprings;
|
|
||||||
glm::vec3 _movedHandOffset;
|
|
||||||
float _springVelocityDecay;
|
|
||||||
float _springForce;
|
|
||||||
glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion
|
|
||||||
AvatarBone _bone[ NUM_AVATAR_BONES ];
|
|
||||||
AvatarMode _mode;
|
|
||||||
AvatarHandHolding _handHolding;
|
|
||||||
glm::vec3 _velocity;
|
|
||||||
glm::vec3 _thrust;
|
|
||||||
float _speed;
|
|
||||||
float _maxArmLength;
|
|
||||||
Orientation _orientation;
|
|
||||||
int _driveKeys[MAX_DRIVE_KEYS];
|
|
||||||
GLUquadric* _sphere;
|
|
||||||
float _renderYaw;
|
|
||||||
float _renderPitch; // Pitch from view frustum when this is own head
|
|
||||||
timeval _transmitterTimer;
|
|
||||||
float _transmitterHz;
|
|
||||||
int _transmitterPackets;
|
|
||||||
Avatar* _interactingOther;
|
|
||||||
bool _interactingOtherIsNearby;
|
|
||||||
float _pelvisStandingHeight;
|
|
||||||
*/
|
|
||||||
|
|
||||||
AvatarTouch _avatarTouch;
|
|
||||||
|
|
||||||
// private methods...
|
// private methods...
|
||||||
void initializeSkeleton();
|
void initializeSkeleton();
|
||||||
|
@ -317,22 +286,6 @@ private:
|
||||||
glm::vec3 collisionUpVector,
|
glm::vec3 collisionUpVector,
|
||||||
float deltaTime
|
float deltaTime
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
void initializeSkeleton();
|
|
||||||
void updateSkeleton();
|
|
||||||
void initializeBodySprings();
|
|
||||||
void updateBodySprings( float deltaTime );
|
|
||||||
void calculateBoneLengths();
|
|
||||||
void readSensors();
|
|
||||||
void renderBoneAsBlock( AvatarBoneID b );
|
|
||||||
void updateAvatarCollisionDetectionAndResponse(glm::vec3 collisionPosition,
|
|
||||||
float collisionGirth,
|
|
||||||
float collisionHeight,
|
|
||||||
glm::vec3 collisionUpVector,
|
|
||||||
float deltaTime);
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
106
interface/src/Balls.cpp
Normal file
106
interface/src/Balls.cpp
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
//
|
||||||
|
// Balls.cpp
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Philip on 4/25/13.
|
||||||
|
//
|
||||||
|
// A cloud of spring-mass spheres to simulate the avatar body/skin. Each ball
|
||||||
|
// connects to as many as 4 neighbors, and executes motion according to a damped
|
||||||
|
// spring, while responding physically to other avatars.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Balls.h"
|
||||||
|
|
||||||
|
Balls::Balls(int numberOfBalls) {
|
||||||
|
_numberOfBalls = numberOfBalls;
|
||||||
|
_balls = new Ball[_numberOfBalls];
|
||||||
|
for (unsigned int i = 0; i < _numberOfBalls; ++i) {
|
||||||
|
_balls[i].position = glm::vec3(1.0 + randFloat()*0.5,
|
||||||
|
0.5 + randFloat()*0.5,
|
||||||
|
1.0 + randFloat()*0.5);
|
||||||
|
_balls[i].radius = 0.02 + randFloat()*0.06;
|
||||||
|
for (unsigned int j = 0; j < NUMBER_SPRINGS; ++j) {
|
||||||
|
_balls[i].links[j] = rand() % (numberOfBalls + 1);
|
||||||
|
if (_balls[i].links[j]-1 == i) { _balls[i].links[j] = 0; }
|
||||||
|
_balls[i].springLength[j] = 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool RENDER_SPRINGS = true;
|
||||||
|
|
||||||
|
void Balls::render() {
|
||||||
|
|
||||||
|
// Render Balls NOTE: This needs to become something other that GlutSpheres!
|
||||||
|
glColor3f(0.62,0.74,0.91);
|
||||||
|
for (unsigned int i = 0; i < _numberOfBalls; ++i) {
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(_balls[i].position.x, _balls[i].position.y, _balls[i].position.z);
|
||||||
|
glutSolidSphere(_balls[i].radius, 15, 15);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render springs
|
||||||
|
if (RENDER_SPRINGS) {
|
||||||
|
glColor3f(0.74,0.91,0.62);
|
||||||
|
for (unsigned int i = 0; i < _numberOfBalls; ++i) {
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
for (unsigned int j = 0; j < NUMBER_SPRINGS; ++j) {
|
||||||
|
if(_balls[i].links[j] > 0) {
|
||||||
|
glVertex3f(_balls[i].position.x,
|
||||||
|
_balls[i].position.y,
|
||||||
|
_balls[i].position.z);
|
||||||
|
glVertex3f(_balls[_balls[i].links[j]-1].position.x,
|
||||||
|
_balls[_balls[i].links[j]-1].position.y,
|
||||||
|
_balls[_balls[i].links[j]-1].position.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const float CONSTANT_VELOCITY_DAMPING = 1.0f;
|
||||||
|
const float NOISE_SCALE = 0.00;
|
||||||
|
const float SPRING_FORCE = 1.0;
|
||||||
|
const float SPRING_DAMPING = 1.0;
|
||||||
|
|
||||||
|
void Balls::simulate(float deltaTime) {
|
||||||
|
for (unsigned int i = 0; i < _numberOfBalls; ++i) {
|
||||||
|
|
||||||
|
// Move particles
|
||||||
|
_balls[i].position += _balls[i].velocity * deltaTime;
|
||||||
|
|
||||||
|
// Drag: decay velocity
|
||||||
|
_balls[i].velocity *= (1.f - CONSTANT_VELOCITY_DAMPING*deltaTime);
|
||||||
|
|
||||||
|
// Add noise
|
||||||
|
_balls[i].velocity += glm::vec3((randFloat() - 0.5) * NOISE_SCALE,
|
||||||
|
(randFloat() - 0.5) * NOISE_SCALE,
|
||||||
|
(randFloat() - 0.5) * NOISE_SCALE);
|
||||||
|
|
||||||
|
// Spring Force
|
||||||
|
|
||||||
|
|
||||||
|
for (unsigned int j = 0; j < NUMBER_SPRINGS; ++j) {
|
||||||
|
if(_balls[i].links[j] > 0) {
|
||||||
|
float separation = glm::distance(_balls[i].position,
|
||||||
|
_balls[_balls[i].links[j]-1].position);
|
||||||
|
_balls[i].velocity += glm::normalize(_balls[i].position -
|
||||||
|
_balls[_balls[i].links[j]-1].position) *
|
||||||
|
deltaTime *
|
||||||
|
SPRING_FORCE *
|
||||||
|
(_balls[i].springLength[j] - separation);
|
||||||
|
|
||||||
|
//_balls[i].velocity *= (1.f - SPRING_DAMPING*deltaTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
37
interface/src/Balls.h
Normal file
37
interface/src/Balls.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
//
|
||||||
|
// Balls.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Philip on 4/25/13.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_Balls_h
|
||||||
|
#define hifi_Balls_h
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include "Util.h"
|
||||||
|
#include "world.h"
|
||||||
|
#include "InterfaceConfig.h"
|
||||||
|
|
||||||
|
|
||||||
|
const int NUMBER_SPRINGS = 4;
|
||||||
|
|
||||||
|
class Balls {
|
||||||
|
public:
|
||||||
|
Balls(int numberOfBalls);
|
||||||
|
|
||||||
|
void simulate(float deltaTime);
|
||||||
|
void render();
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Ball {
|
||||||
|
glm::vec3 position, velocity;
|
||||||
|
int links[NUMBER_SPRINGS];
|
||||||
|
float springLength[NUMBER_SPRINGS];
|
||||||
|
float radius;
|
||||||
|
} *_balls;
|
||||||
|
int _numberOfBalls;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,244 +0,0 @@
|
||||||
//
|
|
||||||
// Particle.cpp
|
|
||||||
// interface
|
|
||||||
//
|
|
||||||
// Created by Seiji Emery on 9/4/12.
|
|
||||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "Particle.h"
|
|
||||||
|
|
||||||
#define NUM_ELEMENTS 4
|
|
||||||
|
|
||||||
glm::vec3 color0(1,0,0); // Motionless particle
|
|
||||||
glm::vec3 color1(0,1,0); // Spring force
|
|
||||||
glm::vec3 color2(0,0,1);
|
|
||||||
glm::vec3 color3(0,1,1);
|
|
||||||
|
|
||||||
float radii[NUM_ELEMENTS] = {0.3f, 0.5f, 0.2f, 0.4f};
|
|
||||||
|
|
||||||
ParticleSystem::ParticleSystem(int num,
|
|
||||||
glm::vec3 box,
|
|
||||||
int wrap,
|
|
||||||
float noiselevel,
|
|
||||||
float setscale,
|
|
||||||
float setgravity) {
|
|
||||||
// Create and initialize particles
|
|
||||||
int element;
|
|
||||||
bounds = box;
|
|
||||||
count = num;
|
|
||||||
wrapBounds = false;
|
|
||||||
noise = noiselevel;
|
|
||||||
gravity = setgravity;
|
|
||||||
scale = setscale;
|
|
||||||
particles = new Particle[count];
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < count; i++) {
|
|
||||||
particles[i].position.x = randFloat()*box.x;
|
|
||||||
particles[i].position.y = randFloat()*box.y;
|
|
||||||
particles[i].position.z = randFloat()*box.z;
|
|
||||||
|
|
||||||
// Constrain to a small box in center
|
|
||||||
//particles[i].position.x = randFloat()+box.x/2.0;
|
|
||||||
//particles[i].position.y = randFloat()+box.y/2.0;
|
|
||||||
//particles[i].position.z = randFloat()+box.z/2.0;
|
|
||||||
|
|
||||||
particles[i].velocity.x = 0;
|
|
||||||
particles[i].velocity.y = 0;
|
|
||||||
particles[i].velocity.z = 0;
|
|
||||||
|
|
||||||
particles[i].parent = 0;
|
|
||||||
particles[i].link *= 0;
|
|
||||||
|
|
||||||
element = 1; //rand()%NUM_ELEMENTS;
|
|
||||||
particles[i].element = element;
|
|
||||||
|
|
||||||
if (element == 0) particles[i].color = color0;
|
|
||||||
else if (element == 1) particles[i].color = color1;
|
|
||||||
else if (element == 2) particles[i].color = color2;
|
|
||||||
else if (element == 3) particles[i].color = color3;
|
|
||||||
|
|
||||||
particles[i].radius = 0.10f; //radii[element]*scale;
|
|
||||||
particles[i].isColliding = false;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ParticleSystem::updateHand(glm::vec3 pos, glm::vec3 vel, float radius) {
|
|
||||||
handPos = pos;
|
|
||||||
handVel = vel;
|
|
||||||
handRadius = radius;
|
|
||||||
return handIsColliding;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::resetHand() {
|
|
||||||
handActive = false;
|
|
||||||
handIsColliding = false;
|
|
||||||
handPos = glm::vec3(0,0,0);
|
|
||||||
handVel = glm::vec3(0,0,0);
|
|
||||||
handRadius = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::render() {
|
|
||||||
for (unsigned int i = 0; i < count; ++i) {
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(particles[i].position.x, particles[i].position.y, particles[i].position.z);
|
|
||||||
if (particles[i].numSprung == 0) glColor3f(1,1,1);
|
|
||||||
else if (particles[i].numSprung == 1) glColor3f(0,1,0);
|
|
||||||
else if (particles[i].numSprung == 2) glColor3f(1,1,0);
|
|
||||||
else if (particles[i].numSprung >= 3) glColor3f(1,0,0);
|
|
||||||
glutSolidSphere(particles[i].radius, 15, 15);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::link(int child, int parent) {
|
|
||||||
particles[child].parent = parent;
|
|
||||||
particles[child].velocity *= 0.5;
|
|
||||||
particles[parent].velocity += particles[child].velocity;
|
|
||||||
particles[child].velocity *= 0.0;
|
|
||||||
particles[child].color = glm::vec3(1,1,0);
|
|
||||||
particles[child].link = particles[parent].position - particles[child].position;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::simulate (float deltaTime) {
|
|
||||||
unsigned int i, j;
|
|
||||||
for (i = 0; i < count; ++i) {
|
|
||||||
if (particles[i].element != 0) {
|
|
||||||
|
|
||||||
if (particles[i].parent == 0) {
|
|
||||||
// Move particles
|
|
||||||
particles[i].position += particles[i].velocity * deltaTime;
|
|
||||||
|
|
||||||
// Add gravity
|
|
||||||
particles[i].velocity.y -= gravity*deltaTime;
|
|
||||||
|
|
||||||
// Drag: decay velocity
|
|
||||||
const float CONSTANT_DAMPING = 0.1f;
|
|
||||||
particles[i].velocity *= (1.f - CONSTANT_DAMPING*deltaTime);
|
|
||||||
|
|
||||||
// Add velocity from field
|
|
||||||
//Field::addTo(particles[i].velocity);
|
|
||||||
//particles[i].velocity += Field::valueAt(particles[i].position);
|
|
||||||
|
|
||||||
// Add noise
|
|
||||||
const float RAND_VEL = 0.05f;
|
|
||||||
if (noise) {
|
|
||||||
if (1) {
|
|
||||||
particles[i].velocity += glm::vec3((randFloat() - 0.5)*RAND_VEL,
|
|
||||||
(randFloat() - 0.5)*RAND_VEL,
|
|
||||||
(randFloat() - 0.5)*RAND_VEL);
|
|
||||||
}
|
|
||||||
if (randFloat() < noise*deltaTime) {
|
|
||||||
particles[i].velocity += glm::vec3((randFloat() - 0.5)*RAND_VEL*100,
|
|
||||||
(randFloat() - 0.5)*RAND_VEL*100,
|
|
||||||
(randFloat() - 0.5)*RAND_VEL*100);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
particles[i].position = particles[particles[i].parent].position + particles[i].link;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Check for collision with manipulator hand
|
|
||||||
particles[i].isColliding = (glm::vec3(particles[i].position - handPos).length() <
|
|
||||||
(radius + handRadius));
|
|
||||||
|
|
||||||
// Check for collision with other balls
|
|
||||||
float separation;
|
|
||||||
const float HARD_SPHERE_FORCE = 100.0;
|
|
||||||
const float SPRING_FORCE = 10.0;
|
|
||||||
const float SPRING_DAMPING = 0.5;
|
|
||||||
float spring_length = 0.5; //2*radii[1];
|
|
||||||
float spring_range = spring_length * 1.2f;
|
|
||||||
float contact;
|
|
||||||
|
|
||||||
particles[i].isColliding = false;
|
|
||||||
particles[i].numSprung = 0;
|
|
||||||
|
|
||||||
for (j = 0; j < count; j++) {
|
|
||||||
if ((j != i) &&
|
|
||||||
(!particles[i].parent)) {
|
|
||||||
separation = glm::distance(particles[i].position, particles[j].position);
|
|
||||||
contact = particles[i].radius + particles[j].radius;
|
|
||||||
|
|
||||||
// Hard Sphere Scattering
|
|
||||||
|
|
||||||
if (separation < contact) {
|
|
||||||
particles[i].velocity += glm::normalize(particles[i].position - particles[j].position)*deltaTime*HARD_SPHERE_FORCE*(contact - separation);
|
|
||||||
particles[i].isColliding = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spring Action
|
|
||||||
if ((particles[i].element == 1) && (separation < spring_range)) {
|
|
||||||
particles[i].velocity += glm::normalize(particles[i].position - particles[j].position)*deltaTime*SPRING_FORCE*(spring_length - separation);
|
|
||||||
particles[i].velocity *= (1.f - SPRING_DAMPING*deltaTime);
|
|
||||||
particles[i].numSprung++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Link!
|
|
||||||
if ((particles[i].parent == 0) &&
|
|
||||||
(particles[j].parent != i) &&
|
|
||||||
(separation > 0.9*(particles[j].radius + particles[i].radius)) &&
|
|
||||||
(separation < 1.0*(particles[j].radius + particles[i].radius)) ) {
|
|
||||||
// Link i to j!!
|
|
||||||
//link(i, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!particles[i].parent) {
|
|
||||||
if (wrapBounds) {
|
|
||||||
// wrap around bounds
|
|
||||||
if (particles[i].position.x > bounds.x)
|
|
||||||
particles[i].position.x -= bounds.x;
|
|
||||||
else if (particles[i].position.x < 0.0f)
|
|
||||||
particles[i].position.x += bounds.x;
|
|
||||||
|
|
||||||
if (particles[i].position.y > bounds.y)
|
|
||||||
particles[i].position.y -= bounds.y;
|
|
||||||
else if (particles[i].position.y < 0.0f)
|
|
||||||
particles[i].position.y += bounds.y;
|
|
||||||
|
|
||||||
if (particles[i].position.z > bounds.z)
|
|
||||||
particles[i].position.z -= bounds.z;
|
|
||||||
else if (particles[i].position.z < 0.0f)
|
|
||||||
particles[i].position.z += bounds.z;
|
|
||||||
} else {
|
|
||||||
// Bounce at bounds
|
|
||||||
if (particles[i].position.x > bounds.x
|
|
||||||
|| particles[i].position.x < 0.f) {
|
|
||||||
if (particles[i].position.x > bounds.x) particles[i].position.x = bounds.x;
|
|
||||||
else particles[i].position.x = 0.f;
|
|
||||||
particles[i].velocity.x *= -1;
|
|
||||||
}
|
|
||||||
if (particles[i].position.y > bounds.y
|
|
||||||
|| particles[i].position.y < 0.f) {
|
|
||||||
if (particles[i].position.y > bounds.y) particles[i].position.y = bounds.y;
|
|
||||||
else particles[i].position.y = 0.f;
|
|
||||||
particles[i].velocity.y *= -1;
|
|
||||||
}
|
|
||||||
if (particles[i].position.z > bounds.z
|
|
||||||
|| particles[i].position.z < 0.f) {
|
|
||||||
if (particles[i].position.z > bounds.z) particles[i].position.z = bounds.z;
|
|
||||||
else particles[i].position.z = 0.f;
|
|
||||||
particles[i].velocity.z *= -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
//
|
|
||||||
// Particle.h
|
|
||||||
// interface
|
|
||||||
//
|
|
||||||
// Created by Seiji Emery on 9/4/12.
|
|
||||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef __interface__Particle__
|
|
||||||
#define __interface__Particle__
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include "Util.h"
|
|
||||||
#include "world.h"
|
|
||||||
#include "InterfaceConfig.h"
|
|
||||||
|
|
||||||
class ParticleSystem {
|
|
||||||
public:
|
|
||||||
ParticleSystem(int num,
|
|
||||||
glm::vec3 box,
|
|
||||||
int wrap,
|
|
||||||
float noiselevel,
|
|
||||||
float setscale,
|
|
||||||
float setgravity);
|
|
||||||
|
|
||||||
void simulate(float deltaTime);
|
|
||||||
void render();
|
|
||||||
bool updateHand(glm::vec3 pos, glm::vec3 vel, float radius);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct Particle {
|
|
||||||
glm::vec3 position, velocity, color, link;
|
|
||||||
int element;
|
|
||||||
int parent;
|
|
||||||
float radius;
|
|
||||||
bool isColliding;
|
|
||||||
int numSprung;
|
|
||||||
} *particles;
|
|
||||||
unsigned int count;
|
|
||||||
|
|
||||||
glm::vec3 bounds;
|
|
||||||
|
|
||||||
float radius;
|
|
||||||
bool wrapBounds;
|
|
||||||
float noise;
|
|
||||||
float gravity;
|
|
||||||
float scale;
|
|
||||||
glm::vec3 color;
|
|
||||||
|
|
||||||
void link(int child, int parent);
|
|
||||||
|
|
||||||
// Manipulator from outside
|
|
||||||
void resetHand();
|
|
||||||
bool handActive;
|
|
||||||
bool handIsColliding;
|
|
||||||
glm::vec3 handPos;
|
|
||||||
glm::vec3 handVel;
|
|
||||||
float handRadius;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -66,7 +66,6 @@
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "ChatEntry.h"
|
#include "ChatEntry.h"
|
||||||
#include "Avatar.h"
|
#include "Avatar.h"
|
||||||
#include "Particle.h"
|
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Cloud.h"
|
#include "Cloud.h"
|
||||||
#include <AgentList.h>
|
#include <AgentList.h>
|
||||||
|
@ -124,14 +123,6 @@ bool showingVoxels = true;
|
||||||
|
|
||||||
glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);
|
glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);
|
||||||
|
|
||||||
ParticleSystem balls(0,
|
|
||||||
box,
|
|
||||||
false, // Wrap?
|
|
||||||
0.02f, // Noise
|
|
||||||
0.3f, // Size scale
|
|
||||||
0.0 // Gravity
|
|
||||||
);
|
|
||||||
|
|
||||||
Cloud cloud(0, // Particles
|
Cloud cloud(0, // Particles
|
||||||
box, // Bounding Box
|
box, // Bounding Box
|
||||||
false // Wrap
|
false // Wrap
|
||||||
|
@ -956,9 +947,7 @@ void display(void)
|
||||||
avatar->render(0);
|
avatar->render(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !::lookingInMirror ) balls.render();
|
|
||||||
|
|
||||||
// Render the world box
|
// Render the world box
|
||||||
if (!::lookingInMirror && ::statsOn) { render_world_box(); }
|
if (!::lookingInMirror && ::statsOn) { render_world_box(); }
|
||||||
|
|
||||||
|
@ -1580,7 +1569,6 @@ void idle(void) {
|
||||||
|
|
||||||
field.simulate (deltaTime);
|
field.simulate (deltaTime);
|
||||||
myAvatar.simulate(deltaTime);
|
myAvatar.simulate(deltaTime);
|
||||||
balls.simulate (deltaTime);
|
|
||||||
cloud.simulate (deltaTime);
|
cloud.simulate (deltaTime);
|
||||||
|
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
|
|
Loading…
Reference in a new issue