mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
Physics test ‘buckyballs’ moved to application.cpp
This commit is contained in:
parent
a9849c131f
commit
246bb1fd2d
4 changed files with 20 additions and 4 deletions
|
@ -1493,6 +1493,8 @@ void Application::idle() {
|
||||||
_idleLoopStdev.reset();
|
_idleLoopStdev.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());
|
||||||
|
|
||||||
// After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
|
// After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
|
||||||
idleTimer->start(2);
|
idleTimer->start(2);
|
||||||
}
|
}
|
||||||
|
@ -2810,6 +2812,8 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
|
||||||
_metavoxels.render();
|
_metavoxels.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_buckyBalls.render();
|
||||||
|
|
||||||
// render particles...
|
// render particles...
|
||||||
_particles.render();
|
_particles.render();
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "Audio.h"
|
#include "Audio.h"
|
||||||
|
|
||||||
#include "BandwidthMeter.h"
|
#include "BandwidthMeter.h"
|
||||||
|
#include "BuckyBalls.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "DatagramProcessor.h"
|
#include "DatagramProcessor.h"
|
||||||
#include "Environment.h"
|
#include "Environment.h"
|
||||||
|
@ -379,6 +380,8 @@ private:
|
||||||
|
|
||||||
Stars _stars;
|
Stars _stars;
|
||||||
|
|
||||||
|
BuckyBalls _buckyBalls;
|
||||||
|
|
||||||
VoxelSystem _voxels;
|
VoxelSystem _voxels;
|
||||||
VoxelTree _clipboard; // if I copy/paste
|
VoxelTree _clipboard; // if I copy/paste
|
||||||
VoxelImporter* _voxelImporter;
|
VoxelImporter* _voxelImporter;
|
||||||
|
|
|
@ -54,9 +54,12 @@ BuckyBalls::BuckyBalls() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuckyBalls::grab(PalmData& palm, const glm::vec3& fingerTipPosition, glm::quat avatarOrientation, float deltaTime) {
|
void BuckyBalls::grab(PalmData& palm, float deltaTime) {
|
||||||
float penetration;
|
float penetration;
|
||||||
glm::vec3 diff;
|
glm::vec3 diff;
|
||||||
|
FingerData& finger = palm.getFingers()[0]; // Sixense has only one finger
|
||||||
|
glm::vec3 fingerTipPosition = finger.getTipPosition();
|
||||||
|
|
||||||
if (palm.getControllerButtons() & BUTTON_FWD) {
|
if (palm.getControllerButtons() & BUTTON_FWD) {
|
||||||
if (!_bballIsGrabbed[palm.getSixenseID()]) {
|
if (!_bballIsGrabbed[palm.getSixenseID()]) {
|
||||||
// Look for a ball to grab
|
// Look for a ball to grab
|
||||||
|
@ -89,7 +92,13 @@ const float COLLISION_BLEND_RATE = 0.5f;
|
||||||
const float ATTRACTION_BLEND_RATE = 0.9f;
|
const float ATTRACTION_BLEND_RATE = 0.9f;
|
||||||
const float ATTRACTION_VELOCITY_BLEND_RATE = 0.10f;
|
const float ATTRACTION_VELOCITY_BLEND_RATE = 0.10f;
|
||||||
|
|
||||||
void BuckyBalls::simulate(float deltaTime) {
|
void BuckyBalls::simulate(float deltaTime, const HandData* handData) {
|
||||||
|
// First, update the grab behavior from the hand controllers
|
||||||
|
for (size_t i = 0; i < handData->getNumPalms(); ++i) {
|
||||||
|
PalmData palm = handData->getPalms()[i];
|
||||||
|
grab(palm, deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
// Look for collisions
|
// Look for collisions
|
||||||
for (int i = 0; i < NUM_BBALLS; i++) {
|
for (int i = 0; i < NUM_BBALLS; i++) {
|
||||||
if (_bballElement[i] != 1) {
|
if (_bballElement[i] != 1) {
|
||||||
|
|
|
@ -26,8 +26,8 @@ const int NUM_BBALLS = 200;
|
||||||
class BuckyBalls {
|
class BuckyBalls {
|
||||||
public:
|
public:
|
||||||
BuckyBalls();
|
BuckyBalls();
|
||||||
void grab(PalmData& palm, const glm::vec3& fingerTipPosition, glm::quat avatarOrientation, float deltaTime);
|
void grab(PalmData& palm, float deltaTime);
|
||||||
void simulate(float deltaTime);
|
void simulate(float deltaTime, const HandData* handData);
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue