mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:09:56 +02:00
adding more changes and small improvements to camera, and head...
This commit is contained in:
parent
e6a4647852
commit
87c26a39fb
3 changed files with 50 additions and 67 deletions
|
@ -33,5 +33,11 @@ void Camera::update()
|
||||||
|
|
||||||
position = glm::dvec3( targetPosition );
|
position = glm::dvec3( targetPosition );
|
||||||
position += glm::dvec3( x, y, z );
|
position += glm::dvec3( x, y, z );
|
||||||
|
|
||||||
|
//geterate the ortho-normals for the orientation based on the Euler angles
|
||||||
|
orientation.setToIdentity();
|
||||||
|
orientation.yaw ( yaw );
|
||||||
|
orientation.pitch ( pitch );
|
||||||
|
orientation.roll ( roll );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ void Head::reset()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//this pertains to moving the head with the glasses
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity)
|
void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity)
|
||||||
// Using serial data, update avatar/render position and angles
|
// Using serial data, update avatar/render position and angles
|
||||||
|
@ -285,10 +285,7 @@ void Head::simulate(float deltaTime)
|
||||||
sin( avatar.pitch * PI_OVER_180 ),
|
sin( avatar.pitch * PI_OVER_180 ),
|
||||||
cos( avatar.roll * PI_OVER_180 )
|
cos( avatar.roll * PI_OVER_180 )
|
||||||
);
|
);
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
glm::vec3 forward(-sinf(getRenderYaw()*PI/180),
|
glm::vec3 forward(-sinf(getRenderYaw()*PI/180),
|
||||||
sinf(getRenderPitch()*PI/180),
|
sinf(getRenderPitch()*PI/180),
|
||||||
cosf(getRenderYaw()*PI/180));
|
cosf(getRenderYaw()*PI/180));
|
||||||
|
@ -296,93 +293,54 @@ void Head::simulate(float deltaTime)
|
||||||
thrust = glm::vec3(0);
|
thrust = glm::vec3(0);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const float THRUST_MAG = 10.0;
|
const float THRUST_MAG = 10.0;
|
||||||
|
const float THRUST_LATERAL_MAG = 10.0;
|
||||||
/*
|
const float THRUST_VERTICAL_MAG = 10.0;
|
||||||
const float THRUST_LATERAL_MAG = 10.0;
|
|
||||||
const float THRUST_VERTICAL_MAG = 10.0;
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
avatar.thrust = glm::dvec3( 0.0, 0.0, 0.0 );
|
avatar.thrust = glm::dvec3( 0.0, 0.0, 0.0 );
|
||||||
|
|
||||||
if (driveKeys[FWD])
|
if (driveKeys[FWD])
|
||||||
{
|
{
|
||||||
//position.x += avatar.orientation.getFront().getX() * 0.01;
|
|
||||||
//position.y += avatar.orientation.getFront().getY() * 0.01;
|
|
||||||
//position.z -= avatar.orientation.getFront().getZ() * 0.01;
|
|
||||||
|
|
||||||
avatar.thrust.x += avatar.orientation.getFront().getX() * THRUST_MAG;
|
avatar.thrust.x += avatar.orientation.getFront().getX() * THRUST_MAG;
|
||||||
avatar.thrust.y += avatar.orientation.getFront().getY() * THRUST_MAG;
|
avatar.thrust.y += avatar.orientation.getFront().getY() * THRUST_MAG;
|
||||||
avatar.thrust.z -= avatar.orientation.getFront().getZ() * THRUST_MAG;
|
avatar.thrust.z -= avatar.orientation.getFront().getZ() * THRUST_MAG;
|
||||||
|
|
||||||
//thrust += THRUST_MAG*forward;
|
//thrust += THRUST_MAG*forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (driveKeys[BACK])
|
if (driveKeys[BACK])
|
||||||
{
|
{
|
||||||
//position.x -= avatar.orientation.getFront().getX() * 0.01;
|
|
||||||
//position.y -= avatar.orientation.getFront().getY() * 0.01;
|
|
||||||
//position.z += avatar.orientation.getFront().getZ() * 0.01;
|
|
||||||
|
|
||||||
avatar.thrust.x -= avatar.orientation.getFront().getX() * THRUST_MAG;
|
avatar.thrust.x -= avatar.orientation.getFront().getX() * THRUST_MAG;
|
||||||
avatar.thrust.y -= avatar.orientation.getFront().getY() * THRUST_MAG;
|
avatar.thrust.y -= avatar.orientation.getFront().getY() * THRUST_MAG;
|
||||||
avatar.thrust.z += avatar.orientation.getFront().getZ() * THRUST_MAG;
|
avatar.thrust.z += avatar.orientation.getFront().getZ() * THRUST_MAG;
|
||||||
|
|
||||||
//thrust += -THRUST_MAG*forward;
|
//thrust += -THRUST_MAG*forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (driveKeys[RIGHT])
|
if (driveKeys[RIGHT])
|
||||||
{
|
{
|
||||||
//position.x += avatar.orientation.getRight().getX() * 0.01;
|
avatar.thrust.x += avatar.orientation.getRight().getX() * THRUST_LATERAL_MAG;
|
||||||
//position.y += avatar.orientation.getRight().getY() * 0.01;
|
avatar.thrust.y += avatar.orientation.getRight().getY() * THRUST_LATERAL_MAG;
|
||||||
//position.z -= avatar.orientation.getRight().getZ() * 0.01;
|
avatar.thrust.z -= avatar.orientation.getRight().getZ() * THRUST_LATERAL_MAG;
|
||||||
|
|
||||||
avatar.thrust.x += avatar.orientation.getRight().getX() * THRUST_MAG;
|
|
||||||
avatar.thrust.y += avatar.orientation.getRight().getY() * THRUST_MAG;
|
|
||||||
avatar.thrust.z -= avatar.orientation.getRight().getZ() * THRUST_MAG;
|
|
||||||
|
|
||||||
//thrust.x += forward.z*-THRUST_LATERAL_MAG;
|
//thrust.x += forward.z*-THRUST_LATERAL_MAG;
|
||||||
//thrust.z += forward.x*THRUST_LATERAL_MAG;
|
//thrust.z += forward.x*THRUST_LATERAL_MAG;
|
||||||
}
|
}
|
||||||
if (driveKeys[LEFT])
|
if (driveKeys[LEFT])
|
||||||
{
|
{
|
||||||
//position.x -= avatar.orientation.getRight().getX() * 0.01;
|
avatar.thrust.x -= avatar.orientation.getRight().getX() * THRUST_LATERAL_MAG;
|
||||||
//position.y -= avatar.orientation.getRight().getY() * 0.01;
|
avatar.thrust.y -= avatar.orientation.getRight().getY() * THRUST_LATERAL_MAG;
|
||||||
//position.z += avatar.orientation.getRight().getZ() * 0.01;
|
avatar.thrust.z += avatar.orientation.getRight().getZ() * THRUST_LATERAL_MAG;
|
||||||
|
|
||||||
avatar.thrust.x -= avatar.orientation.getRight().getX() * THRUST_MAG;
|
|
||||||
avatar.thrust.y -= avatar.orientation.getRight().getY() * THRUST_MAG;
|
|
||||||
avatar.thrust.z += avatar.orientation.getRight().getZ() * THRUST_MAG;
|
|
||||||
|
|
||||||
//thrust.x += forward.z*THRUST_LATERAL_MAG;
|
//thrust.x += forward.z*THRUST_LATERAL_MAG;
|
||||||
//thrust.z += forward.x*-THRUST_LATERAL_MAG;
|
//thrust.z += forward.x*-THRUST_LATERAL_MAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (driveKeys[UP])
|
if (driveKeys[UP])
|
||||||
{
|
{
|
||||||
//position.x -= avatar.orientation.getUp().getX() * 0.01;
|
avatar.thrust.x -= avatar.orientation.getUp().getX() * THRUST_VERTICAL_MAG;
|
||||||
//position.y -= avatar.orientation.getUp().getY() * 0.01;
|
avatar.thrust.y -= avatar.orientation.getUp().getY() * THRUST_VERTICAL_MAG;
|
||||||
//position.z += avatar.orientation.getUp().getZ() * 0.01;
|
avatar.thrust.z += avatar.orientation.getUp().getZ() * THRUST_VERTICAL_MAG;
|
||||||
|
|
||||||
avatar.thrust.x -= avatar.orientation.getUp().getX() * THRUST_MAG;
|
|
||||||
avatar.thrust.y -= avatar.orientation.getUp().getY() * THRUST_MAG;
|
|
||||||
avatar.thrust.z += avatar.orientation.getUp().getZ() * THRUST_MAG;
|
|
||||||
|
|
||||||
//thrust.y += -THRUST_VERTICAL_MAG;
|
//thrust.y += -THRUST_VERTICAL_MAG;
|
||||||
}
|
}
|
||||||
if (driveKeys[DOWN])
|
if (driveKeys[DOWN])
|
||||||
{
|
{
|
||||||
//position.x += avatar.orientation.getUp().getX() * 0.01;
|
avatar.thrust.x += avatar.orientation.getUp().getX() * THRUST_VERTICAL_MAG;
|
||||||
//position.y += avatar.orientation.getUp().getY() * 0.01;
|
avatar.thrust.y += avatar.orientation.getUp().getY() * THRUST_VERTICAL_MAG;
|
||||||
//position.z -= avatar.orientation.getUp().getZ() * 0.01;
|
avatar.thrust.z -= avatar.orientation.getUp().getZ() * THRUST_VERTICAL_MAG;
|
||||||
|
|
||||||
avatar.thrust.x += avatar.orientation.getUp().getX() * THRUST_MAG;
|
|
||||||
avatar.thrust.y += avatar.orientation.getUp().getY() * THRUST_MAG;
|
|
||||||
avatar.thrust.z -= avatar.orientation.getUp().getZ() * THRUST_MAG;
|
|
||||||
|
|
||||||
//thrust.y += THRUST_VERTICAL_MAG;
|
//thrust.y += THRUST_VERTICAL_MAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,7 +1013,9 @@ void Head::parseData(void *data, int size)
|
||||||
&Pitch, &Yaw, &Roll,
|
&Pitch, &Yaw, &Roll,
|
||||||
&position.x, &position.y, &position.z,
|
&position.x, &position.y, &position.z,
|
||||||
&loudness, &averageLoudness,
|
&loudness, &averageLoudness,
|
||||||
&handPos.x, &handPos.y, &handPos.z
|
&avatar.bone[ AVATAR_BONE_RIGHT_HAND ].worldPosition.x,
|
||||||
|
&avatar.bone[ AVATAR_BONE_RIGHT_HAND ].worldPosition.y,
|
||||||
|
&avatar.bone[ AVATAR_BONE_RIGHT_HAND ].worldPosition.z
|
||||||
);
|
);
|
||||||
|
|
||||||
if (glm::length(handPos) > 0.0) hand->setPos(handPos);
|
if (glm::length(handPos) > 0.0) hand->setPos(handPos);
|
||||||
|
|
|
@ -608,7 +608,7 @@ void display(void)
|
||||||
{
|
{
|
||||||
myCamera.setYaw ( - myHead.getAvatarYaw() );
|
myCamera.setYaw ( - myHead.getAvatarYaw() );
|
||||||
myCamera.setUp ( 0.4 );
|
myCamera.setUp ( 0.4 );
|
||||||
myCamera.setDistance( 0.08 );
|
myCamera.setDistance( 0.5 );
|
||||||
myCamera.update();
|
myCamera.update();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -618,7 +618,7 @@ void display(void)
|
||||||
{
|
{
|
||||||
myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() );
|
myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() );
|
||||||
myCamera.setUp ( 0.15 );
|
myCamera.setUp ( 0.15 );
|
||||||
myCamera.setDistance( 0.08 );
|
myCamera.setDistance( 1.0 );
|
||||||
myCamera.update();
|
myCamera.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,14 +653,16 @@ void display(void)
|
||||||
// if (!display_head) cloud.render();
|
// if (!display_head) cloud.render();
|
||||||
|
|
||||||
// Draw voxels
|
// Draw voxels
|
||||||
voxels.render();
|
//voxels.render();
|
||||||
|
|
||||||
// Draw field vectors
|
// Draw field vectors
|
||||||
if (display_field) field.render();
|
if (display_field) field.render();
|
||||||
|
|
||||||
// Render heads of other agents
|
// Render heads of other agents
|
||||||
for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) {
|
for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++)
|
||||||
if (agent->getLinkedData() != NULL) {
|
{
|
||||||
|
if (agent->getLinkedData() != NULL)
|
||||||
|
{
|
||||||
Head *agentHead = (Head *)agent->getLinkedData();
|
Head *agentHead = (Head *)agent->getLinkedData();
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glm::vec3 pos = agentHead->getPos();
|
glm::vec3 pos = agentHead->getPos();
|
||||||
|
@ -670,7 +672,7 @@ void display(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!display_head) balls.render();
|
if ( !display_head ) balls.render();
|
||||||
|
|
||||||
// Render the world box
|
// Render the world box
|
||||||
if (!display_head && stats_on) render_world_box();
|
if (!display_head && stats_on) render_world_box();
|
||||||
|
@ -1046,6 +1048,21 @@ void idle(void)
|
||||||
|
|
||||||
// Simulation
|
// Simulation
|
||||||
simulateHead(1.f/FPS);
|
simulateHead(1.f/FPS);
|
||||||
|
|
||||||
|
|
||||||
|
//test
|
||||||
|
/*
|
||||||
|
// simulate the other agents
|
||||||
|
for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++)
|
||||||
|
{
|
||||||
|
if (agent->getLinkedData() != NULL)
|
||||||
|
{
|
||||||
|
Head *agentHead = (Head *)agent->getLinkedData();
|
||||||
|
agentHead->simulate(1.f/FPS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
simulateHand(1.f/FPS);
|
simulateHand(1.f/FPS);
|
||||||
|
|
||||||
if (simulate_on) {
|
if (simulate_on) {
|
||||||
|
@ -1078,7 +1095,7 @@ void reshape(int width, int height)
|
||||||
glMatrixMode(GL_PROJECTION); //hello
|
glMatrixMode(GL_PROJECTION); //hello
|
||||||
fov.setResolution(width, height)
|
fov.setResolution(width, height)
|
||||||
.setBounds(glm::vec3(-0.5f,-0.5f,-500.0f), glm::vec3(0.5f, 0.5f, 0.1f) )
|
.setBounds(glm::vec3(-0.5f,-0.5f,-500.0f), glm::vec3(0.5f, 0.5f, 0.1f) )
|
||||||
.setPerspective(0.7854f);
|
.setPerspective(0.7854f);
|
||||||
glLoadMatrixf(glm::value_ptr(fov.getViewerScreenXform()));
|
glLoadMatrixf(glm::value_ptr(fov.getViewerScreenXform()));
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
Loading…
Reference in a new issue