diff --git a/.DS_Store b/.DS_Store index 42a5f68581..5ecaaad1ea 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/agent.cpp b/agent.cpp index 093d06832a..84ebc19c75 100644 --- a/agent.cpp +++ b/agent.cpp @@ -59,11 +59,12 @@ void update_agent(in_addr addr, char * data, int length) std::cout << "Looking for agent: " << inet_ntoa(addr) << "\n"; for (int i = 0; i < num_agents; i++) { if (agents[i].sin_addr.s_addr == addr.s_addr) { - std::cout << "Updating agent with: " << data << "\n"; + // Update the agent + agents[i].head.recvBroadcastData(data, length); } } } - + // // Look for an agent by it's IP number, add if it does not exist in local list // @@ -104,7 +105,7 @@ int broadcast_to_agents(int handle, char * data, int length) { if (sent_bytes != length) { std::cout << "Broadcast packet fail!\n"; return 0; - } else std::cout << "Broadcasted Packet: " << data << "\n"; + } } return 1; } diff --git a/interface.xcodeproj/project.xcworkspace/xcuserdata/philip.xcuserdatad/UserInterfaceState.xcuserstate b/interface.xcodeproj/project.xcworkspace/xcuserdata/philip.xcuserdatad/UserInterfaceState.xcuserstate index ddda5ce8a0..b8cb1e1913 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 diff --git a/main.cpp b/main.cpp index e4c8a2b464..af17f44561 100644 --- a/main.cpp +++ b/main.cpp @@ -75,6 +75,7 @@ int head_mirror = 1; // Whether to mirror the head when vie int WIDTH = 1200; int HEIGHT = 800; +int fullscreen = 0; #define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you Head myHead; // The rendered head of oneself or others @@ -101,8 +102,9 @@ float cubes_scale[MAX_CUBES]; float cubes_color[MAX_CUBES*3]; int cube_count = 0; -#define RENDER_FRAME_MSECS 5 +#define RENDER_FRAME_MSECS 8 #define SLEEP 0 +int steps_per_frame = 0; float yaw =0.f; // The yaw, pitch for the avatar head float pitch = 0.f; // @@ -243,7 +245,7 @@ void initDisplay(void) glEnable(GL_DEPTH_TEST); load_png_as_texture(texture_filename); - glutFullScreen(); + if (fullscreen) glutFullScreen(); } void init(void) @@ -487,12 +489,17 @@ void update_pos(float frametime) balls.updateHand(myHead.getPos() + myHand.getPos(), glm::vec3(0,0,0), myHand.getRadius()); // Update all this stuff to any agents that are nearby and need to see it! + /* const int MAX_BROADCAST_STRING = 200; char broadcast_string[MAX_BROADCAST_STRING]; int broadcast_bytes = myHead.getBroadcastData(broadcast_string); broadcast_to_agents(UDP_socket, broadcast_string, broadcast_bytes); + */ } +int render_test_spot = WIDTH/2; +int render_test_direction = 1; + void display(void) { glEnable (GL_DEPTH_TEST); @@ -602,6 +609,18 @@ void display(void) glVertex2f(head_mouse_x, head_mouse_y); glEnd(); } + if (1) + { + glPointSize(50.0f); + glColor4f(1.0, 1.0, 1.0, 1.0); + glEnable(GL_POINT_SMOOTH); + glBegin(GL_POINTS); + glVertex2f(render_test_spot, HEIGHT-100); + glEnd(); + render_test_spot += render_test_direction*50; + if ((render_test_spot > WIDTH-100) || (render_test_spot < 100)) render_test_direction *= -1.0; + + } // Show detected levels from the serial I/O ADC channel sensors if (display_levels) @@ -759,7 +778,7 @@ void read_network() // // Broadcast packet from another agent // - update_agent(from_addr, &incoming_packet[1], bytes_recvd - 1); + //update_agent(from_addr, &incoming_packet[1], bytes_recvd - 1); } } } @@ -772,6 +791,7 @@ void idle(void) // Check and render display frame if (diffclock(last_frame,check) > RENDER_FRAME_MSECS) { + steps_per_frame++; // Simulation update_pos(1.f/FPS); if (simulate_on) { diff --git a/network.cpp b/network.cpp index 953d7e1832..7148f8af04 100644 --- a/network.cpp +++ b/network.cpp @@ -120,6 +120,8 @@ int network_receive(int handle, in_addr * from_addr, char * packet_data, int del { int received_bytes = recvfrom(handle, (char*)packet_data, MAX_PACKET_SIZE, 0, (sockaddr*)&dest_address, &fromLength ); + from_addr->s_addr = dest_address.sin_addr.s_addr; + if (!delay) { // No delay set, so just return packets immediately! return received_bytes; diff --git a/network.h b/network.h index 1e51419005..f780f741bd 100644 --- a/network.h +++ b/network.h @@ -22,7 +22,7 @@ const int UDP_PORT = 30001; const char DESTINATION_IP[] = "127.0.0.1"; // Address and port of spaceserver process to advertise other agents -const char SPACESERVER_IP[] = "192.168.1.16"; +const char SPACESERVER_IP[] = "127.0.0.1"; const int SPACESERVER_PORT = 40000; // Randomly send a ping packet every N packets sent