diff --git a/Source/lattice.cpp b/Source/lattice.cpp index f6b67fe639..58ecb95093 100644 --- a/Source/lattice.cpp +++ b/Source/lattice.cpp @@ -11,7 +11,7 @@ Lattice::Lattice(int w, int h) { width = w; height = h; - tilegap = 3; + tilegap = 2; lastindex = -1; tiles = new Tile[width*height]; for (int i = 0; i < (width*height); i++) { diff --git a/Source/main.cpp b/Source/main.cpp index f23ca75915..72226d131f 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -110,7 +110,7 @@ Cloud cloud(0, // Particles VoxelSystem voxels(0, box); -Lattice lattice(15,10); +Lattice lattice(160,100); Finger myFinger(WIDTH, HEIGHT); #define RENDER_FRAME_MSECS 8 @@ -119,7 +119,7 @@ int steps_per_frame = 0; float yaw =0.f; // The yaw, pitch for the avatar head float pitch = 0.f; // -float start_yaw = 135.0; +float start_yaw = 116; float render_yaw = start_yaw; float render_pitch = 0.f; float render_yaw_rate = 0.f; @@ -129,7 +129,10 @@ float lateral_vel = 0.f; // Manage speed and direction of motion GLfloat fwd_vec[] = {0.0, 0.0, 1.0}; //GLfloat start_location[] = { WORLD_SIZE*1.5, -WORLD_SIZE/2.0, -WORLD_SIZE/3.0}; -GLfloat start_location[] = { 0.1, -0.15, 0.1}; +//GLfloat start_location[] = { 0.1, -0.15, 0.1}; + +GLfloat start_location[] = {6.1, -2.0, 1.4}; + GLfloat location[] = {start_location[0], start_location[1], start_location[2]}; float fwd_vel = 0.0f; @@ -253,10 +256,11 @@ void display_stats(void) } #endif - char adc[200]; - sprintf(adc, "location = %3.1f,%3.1f,%3.1f", - location[0], location[1], location[2] + sprintf(adc, "location = %3.1f,%3.1f,%3.1f, angle_to(origin) = %3.1f, head yaw = %3.1f, render_yaw = %3.1f", + -location[0], -location[1], -location[2], + angle_to(myHead.getPos()*-1.f, glm::vec3(0,0,0), render_yaw, myHead.getYaw()), + myHead.getYaw(), render_yaw ); drawtext(10, 50, 0.10, 0, 1.0, 0, adc); @@ -564,7 +568,7 @@ void display(void) glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color); glMateriali(GL_FRONT, GL_SHININESS, 96); - // Rotate, translate to camera location + // Rotate, translate to camera location glRotatef(render_pitch, 1, 0, 0); glRotatef(render_yaw, 0, 1, 0); glTranslatef(location[0], location[1], location[2]); @@ -596,7 +600,7 @@ void display(void) if (!display_head) balls.render(); - + // Render the world box if (!display_head && stats_on) render_world_box(); @@ -618,7 +622,8 @@ void display(void) glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); -// lattice.render(WIDTH, HEIGHT); + //lattice.render(WIDTH, HEIGHT); + //drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0); glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic ); diff --git a/Source/util.cpp b/Source/util.cpp index 0db14af235..d33ac70c66 100644 --- a/Source/util.cpp +++ b/Source/util.cpp @@ -19,6 +19,17 @@ float randFloat () { return (rand()%10000)/10000.f; } +// Return the azimuth angle in degrees between two points. +float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos) { + return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) * 180 / PI; +} + +// Return the angle in degrees between the head and an object in the scene. The value is zero if you are looking right at it. The angle is negative if the object is to your right. +float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw) { + return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) * 180 / PI + render_yaw + head_yaw; +} + + void render_vector(glm::vec3 * vec) { diff --git a/Source/util.h b/Source/util.h index 7a1f09847d..263443e2b2 100644 --- a/Source/util.h +++ b/Source/util.h @@ -11,6 +11,9 @@ #include "glm.hpp" +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); + void outstring(char * string, int length); float randFloat(); void render_world_box(); diff --git a/interface.xcodeproj/project.xcworkspace/xcuserdata/philip.xcuserdatad/UserInterfaceState.xcuserstate b/interface.xcodeproj/project.xcworkspace/xcuserdata/philip.xcuserdatad/UserInterfaceState.xcuserstate index 3777b3430e..0cd3691198 100644 Binary files a/interface.xcodeproj/project.xcworkspace/xcuserdata/philip.xcuserdatad/UserInterfaceState.xcuserstate and b/interface.xcodeproj/project.xcworkspace/xcuserdata/philip.xcuserdatad/UserInterfaceState.xcuserstate differ