mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 19:23:58 +02:00
move Orientation class to avatars library, constants to SharedUtil
This commit is contained in:
parent
2dfe49a885
commit
a4011934c6
10 changed files with 97 additions and 120 deletions
|
@ -5,8 +5,9 @@
|
|||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "Camera.h"
|
||||
#include "Util.h"
|
||||
|
||||
//------------------------
|
||||
Camera::Camera()
|
||||
|
|
|
@ -42,9 +42,6 @@ vector<unsigned char> iris_texture;
|
|||
unsigned int iris_texture_width = 512;
|
||||
unsigned int iris_texture_height = 256;
|
||||
|
||||
|
||||
|
||||
|
||||
Head::Head() {
|
||||
initializeAvatar();
|
||||
|
||||
|
|
|
@ -10,10 +10,13 @@
|
|||
#define __interface__head__
|
||||
|
||||
#include <iostream>
|
||||
#include "AgentData.h"
|
||||
|
||||
#include <AvatarData.h>
|
||||
#include <Orientation.h> // added by Ventrella as a utility
|
||||
|
||||
#include "Field.h"
|
||||
#include "world.h"
|
||||
#include "Orientation.h" // added by Ventrella as a utility
|
||||
|
||||
#include "InterfaceConfig.h"
|
||||
#include "SerialInterface.h"
|
||||
|
||||
|
@ -31,101 +34,7 @@ enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
|||
|
||||
#define NUM_OTHER_AVATARS 5
|
||||
|
||||
/*
|
||||
enum AvatarJoints
|
||||
{
|
||||
AVATAR_JOINT_NULL = -1,
|
||||
AVATAR_JOINT_PELVIS,
|
||||
AVATAR_JOINT_TORSO,
|
||||
AVATAR_JOINT_CHEST,
|
||||
AVATAR_JOINT_NECK_BASE,
|
||||
AVATAR_JOINT_HEAD_BASE,
|
||||
AVATAR_JOINT_HEAD_TOP,
|
||||
|
||||
AVATAR_JOINT_LEFT_CLAVICLE,
|
||||
AVATAR_JOINT_LEFT_SHOULDER,
|
||||
AVATAR_JOINT_LEFT_ELBOW,
|
||||
AVATAR_JOINT_LEFT_WRIST,
|
||||
AVATAR_JOINT_LEFT_FINGERTIPS,
|
||||
|
||||
AVATAR_JOINT_RIGHT_CLAVICLE,
|
||||
AVATAR_JOINT_RIGHT_SHOULDER,
|
||||
AVATAR_JOINT_RIGHT_ELBOW,
|
||||
AVATAR_JOINT_RIGHT_WRIST,
|
||||
AVATAR_JOINT_RIGHT_FINGERTIPS,
|
||||
|
||||
AVATAR_JOINT_LEFT_HIP,
|
||||
AVATAR_JOINT_LEFT_KNEE,
|
||||
AVATAR_JOINT_LEFT_HEEL,
|
||||
AVATAR_JOINT_LEFT_TOES,
|
||||
|
||||
AVATAR_JOINT_RIGHT_HIP,
|
||||
AVATAR_JOINT_RIGHT_KNEE,
|
||||
AVATAR_JOINT_RIGHT_HEEL,
|
||||
AVATAR_JOINT_RIGHT_TOES,
|
||||
|
||||
NUM_AVATAR_JOINTS
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
enum AvatarBones
|
||||
{
|
||||
AVATAR_BONE_NULL = -1,
|
||||
AVATAR_BONE_PELVIS_SPINE, // connects pelvis joint with torso joint (not supposed to be rotated)
|
||||
AVATAR_BONE_MID_SPINE, // connects torso joint with chest joint
|
||||
AVATAR_BONE_CHEST_SPINE, // connects chest joint with neckBase joint (not supposed to be rotated)
|
||||
AVATAR_BONE_NECK, // connects neckBase joint with headBase joint
|
||||
AVATAR_BONE_HEAD, // connects headBase joint with headTop joint
|
||||
AVATAR_BONE_LEFT_CHEST, // connects chest joint with left clavicle joint (not supposed to be rotated)
|
||||
AVATAR_BONE_LEFT_SHOULDER, // connects left clavicle joint with left shoulder joint
|
||||
AVATAR_BONE_LEFT_UPPER_ARM, // connects left shoulder joint with left elbow joint
|
||||
AVATAR_BONE_LEFT_FOREARM, // connects left elbow joint with left wrist joint
|
||||
AVATAR_BONE_LEFT_HAND, // connects left wrist joint with left fingertips joint
|
||||
AVATAR_BONE_RIGHT_CHEST, // connects chest joint with right clavicle joint (not supposed to be rotated)
|
||||
AVATAR_BONE_RIGHT_SHOULDER, // connects right clavicle joint with right shoulder joint
|
||||
AVATAR_BONE_RIGHT_UPPER_ARM, // connects right shoulder joint with right elbow joint
|
||||
AVATAR_BONE_RIGHT_FOREARM, // connects right elbow joint with right wrist joint
|
||||
AVATAR_BONE_RIGHT_HAND, // connects right wrist joint with right fingertips joint
|
||||
AVATAR_BONE_LEFT_PELVIS, // connects pelvis joint with left hip joint (not supposed to be rotated)
|
||||
AVATAR_BONE_LEFT_THIGH, // connects left hip joint with left knee joint
|
||||
AVATAR_BONE_LEFT_SHIN, // connects left knee joint with left heel joint
|
||||
AVATAR_BONE_LEFT_FOOT, // connects left heel joint with left toes joint
|
||||
AVATAR_BONE_RIGHT_PELVIS, // connects pelvis joint with right hip joint (not supposed to be rotated)
|
||||
AVATAR_BONE_RIGHT_THIGH, // connects right hip joint with right knee joint
|
||||
AVATAR_BONE_RIGHT_SHIN, // connects right knee joint with right heel joint
|
||||
AVATAR_BONE_RIGHT_FOOT, // connects right heel joint with right toes joint
|
||||
|
||||
NUM_AVATAR_BONES
|
||||
};
|
||||
|
||||
struct AvatarBone
|
||||
{
|
||||
AvatarBones parent; // which bone is this bone connected to?
|
||||
glm::vec3 position; // the position at the "end" of the bone
|
||||
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
|
||||
glm::dvec3 springyVelocity; // used for special effects ( the velocity of the springy position)
|
||||
float springBodyTightness; // how tightly (0 to 1) the springy position tries to stay on the position
|
||||
float yaw; // the yaw Euler angle of the bone rotation off the parent
|
||||
float pitch; // the pitch Euler angle of the bone rotation off the parent
|
||||
float roll; // the roll Euler angle of the bone rotation off the parent
|
||||
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
|
||||
float length; // the length of the bone
|
||||
};
|
||||
|
||||
struct Avatar
|
||||
{
|
||||
glm::dvec3 velocity;
|
||||
glm::vec3 thrust;
|
||||
float maxArmLength;
|
||||
Orientation orientation;
|
||||
AvatarBone bone[ NUM_AVATAR_BONES ];
|
||||
};
|
||||
|
||||
class Head : public AgentData {
|
||||
class Head : public AvatarData {
|
||||
public:
|
||||
Head();
|
||||
~Head();
|
||||
|
|
|
@ -8,8 +8,11 @@
|
|||
|
||||
#include "InterfaceConfig.h"
|
||||
#include <iostream>
|
||||
#include <glm/glm.hpp>
|
||||
#include <cstring>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "world.h"
|
||||
#include "Util.h"
|
||||
|
||||
|
|
|
@ -17,21 +17,6 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
static const double ZERO = 0.0;
|
||||
static const double ONE = 1.0;
|
||||
static const double ONE_HALF = 0.5;
|
||||
static const double ONE_THIRD = 0.3333333;
|
||||
static const double PIE = 3.14159265359;
|
||||
static const double PI_TIMES_TWO = 3.14159265359 * 2.0;
|
||||
static const double PI_OVER_180 = 3.14159265359 / 180.0;
|
||||
static const double EPSILON = 0.00001; //smallish number - used as margin of error for some computations
|
||||
static const double SQUARE_ROOT_OF_2 = sqrt(2);
|
||||
static const double SQUARE_ROOT_OF_3 = sqrt(3);
|
||||
static const double METER = 1.0;
|
||||
static const double DECIMETER = 0.1;
|
||||
static const double CENTIMETER = 0.01;
|
||||
static const double MILLIIMETER = 0.001;
|
||||
|
||||
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos);
|
||||
float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw);
|
||||
|
||||
|
|
|
@ -3,7 +3,16 @@ cmake_minimum_required(VERSION 2.8)
|
|||
set(ROOT_DIR ../..)
|
||||
set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
set(TARGET_NAME avatars)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} ${MACRO_DIR})
|
||||
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
|
@ -10,8 +10,66 @@
|
|||
#define __hifi__AvatarData__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <AgentData.h>
|
||||
|
||||
#include "Orientation.h"
|
||||
|
||||
enum AvatarBones
|
||||
{
|
||||
AVATAR_BONE_NULL = -1,
|
||||
AVATAR_BONE_PELVIS_SPINE, // connects pelvis joint with torso joint (not supposed to be rotated)
|
||||
AVATAR_BONE_MID_SPINE, // connects torso joint with chest joint
|
||||
AVATAR_BONE_CHEST_SPINE, // connects chest joint with neckBase joint (not supposed to be rotated)
|
||||
AVATAR_BONE_NECK, // connects neckBase joint with headBase joint
|
||||
AVATAR_BONE_HEAD, // connects headBase joint with headTop joint
|
||||
AVATAR_BONE_LEFT_CHEST, // connects chest joint with left clavicle joint (not supposed to be rotated)
|
||||
AVATAR_BONE_LEFT_SHOULDER, // connects left clavicle joint with left shoulder joint
|
||||
AVATAR_BONE_LEFT_UPPER_ARM, // connects left shoulder joint with left elbow joint
|
||||
AVATAR_BONE_LEFT_FOREARM, // connects left elbow joint with left wrist joint
|
||||
AVATAR_BONE_LEFT_HAND, // connects left wrist joint with left fingertips joint
|
||||
AVATAR_BONE_RIGHT_CHEST, // connects chest joint with right clavicle joint (not supposed to be rotated)
|
||||
AVATAR_BONE_RIGHT_SHOULDER, // connects right clavicle joint with right shoulder joint
|
||||
AVATAR_BONE_RIGHT_UPPER_ARM, // connects right shoulder joint with right elbow joint
|
||||
AVATAR_BONE_RIGHT_FOREARM, // connects right elbow joint with right wrist joint
|
||||
AVATAR_BONE_RIGHT_HAND, // connects right wrist joint with right fingertips joint
|
||||
AVATAR_BONE_LEFT_PELVIS, // connects pelvis joint with left hip joint (not supposed to be rotated)
|
||||
AVATAR_BONE_LEFT_THIGH, // connects left hip joint with left knee joint
|
||||
AVATAR_BONE_LEFT_SHIN, // connects left knee joint with left heel joint
|
||||
AVATAR_BONE_LEFT_FOOT, // connects left heel joint with left toes joint
|
||||
AVATAR_BONE_RIGHT_PELVIS, // connects pelvis joint with right hip joint (not supposed to be rotated)
|
||||
AVATAR_BONE_RIGHT_THIGH, // connects right hip joint with right knee joint
|
||||
AVATAR_BONE_RIGHT_SHIN, // connects right knee joint with right heel joint
|
||||
AVATAR_BONE_RIGHT_FOOT, // connects right heel joint with right toes joint
|
||||
|
||||
NUM_AVATAR_BONES
|
||||
};
|
||||
|
||||
struct AvatarBone
|
||||
{
|
||||
AvatarBones parent; // which bone is this bone connected to?
|
||||
glm::vec3 position; // the position at the "end" of the bone
|
||||
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
|
||||
glm::dvec3 springyVelocity; // used for special effects ( the velocity of the springy position)
|
||||
float springBodyTightness; // how tightly (0 to 1) the springy position tries to stay on the position
|
||||
float yaw; // the yaw Euler angle of the bone rotation off the parent
|
||||
float pitch; // the pitch Euler angle of the bone rotation off the parent
|
||||
float roll; // the roll Euler angle of the bone rotation off the parent
|
||||
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
|
||||
float length; // the length of the bone
|
||||
};
|
||||
|
||||
struct Avatar
|
||||
{
|
||||
glm::dvec3 velocity;
|
||||
glm::vec3 thrust;
|
||||
float maxArmLength;
|
||||
Orientation orientation;
|
||||
AvatarBone bone[ NUM_AVATAR_BONES ];
|
||||
};
|
||||
|
||||
class AvatarData : public AgentData {
|
||||
public:
|
||||
AvatarData();
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
//-----------------------------------------------------------
|
||||
|
||||
#include "Orientation.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
Orientation::Orientation() {
|
||||
right = glm::vec3( 1.0, 0.0, 0.0 );
|
|
@ -10,6 +10,7 @@
|
|||
#define __hifi__SharedUtil__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Systime.h"
|
||||
|
@ -17,6 +18,21 @@
|
|||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
static const double ZERO = 0.0;
|
||||
static const double ONE = 1.0;
|
||||
static const double ONE_HALF = 0.5;
|
||||
static const double ONE_THIRD = 0.3333333;
|
||||
static const double PIE = 3.14159265359;
|
||||
static const double PI_TIMES_TWO = 3.14159265359 * 2.0;
|
||||
static const double PI_OVER_180 = 3.14159265359 / 180.0;
|
||||
static const double EPSILON = 0.00001; //smallish number - used as margin of error for some computations
|
||||
static const double SQUARE_ROOT_OF_2 = sqrt(2);
|
||||
static const double SQUARE_ROOT_OF_3 = sqrt(3);
|
||||
static const double METER = 1.0;
|
||||
static const double DECIMETER = 0.1;
|
||||
static const double CENTIMETER = 0.01;
|
||||
static const double MILLIIMETER = 0.001;
|
||||
|
||||
double usecTimestamp(timeval *time);
|
||||
double usecTimestampNow();
|
||||
|
||||
|
|
Loading…
Reference in a new issue