mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:52:26 +02:00
Commented out broadcast calls, added fullscreen flag
This commit is contained in:
parent
09f3c00b5a
commit
d27bf404a6
6 changed files with 30 additions and 7 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
|
@ -59,7 +59,8 @@ void update_agent(in_addr addr, char * data, int length)
|
||||||
std::cout << "Looking for agent: " << inet_ntoa(addr) << "\n";
|
std::cout << "Looking for agent: " << inet_ntoa(addr) << "\n";
|
||||||
for (int i = 0; i < num_agents; i++) {
|
for (int i = 0; i < num_agents; i++) {
|
||||||
if (agents[i].sin_addr.s_addr == addr.s_addr) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +105,7 @@ int broadcast_to_agents(int handle, char * data, int length) {
|
||||||
if (sent_bytes != length) {
|
if (sent_bytes != length) {
|
||||||
std::cout << "Broadcast packet fail!\n";
|
std::cout << "Broadcast packet fail!\n";
|
||||||
return 0;
|
return 0;
|
||||||
} else std::cout << "Broadcasted Packet: " << data << "\n";
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
26
main.cpp
26
main.cpp
|
@ -75,6 +75,7 @@ int head_mirror = 1; // Whether to mirror the head when vie
|
||||||
|
|
||||||
int WIDTH = 1200;
|
int WIDTH = 1200;
|
||||||
int HEIGHT = 800;
|
int HEIGHT = 800;
|
||||||
|
int fullscreen = 0;
|
||||||
|
|
||||||
#define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you
|
#define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you
|
||||||
Head myHead; // The rendered head of oneself or others
|
Head myHead; // The rendered head of oneself or others
|
||||||
|
@ -101,8 +102,9 @@ float cubes_scale[MAX_CUBES];
|
||||||
float cubes_color[MAX_CUBES*3];
|
float cubes_color[MAX_CUBES*3];
|
||||||
int cube_count = 0;
|
int cube_count = 0;
|
||||||
|
|
||||||
#define RENDER_FRAME_MSECS 5
|
#define RENDER_FRAME_MSECS 8
|
||||||
#define SLEEP 0
|
#define SLEEP 0
|
||||||
|
int steps_per_frame = 0;
|
||||||
|
|
||||||
float yaw =0.f; // The yaw, pitch for the avatar head
|
float yaw =0.f; // The yaw, pitch for the avatar head
|
||||||
float pitch = 0.f; //
|
float pitch = 0.f; //
|
||||||
|
@ -243,7 +245,7 @@ void initDisplay(void)
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
load_png_as_texture(texture_filename);
|
load_png_as_texture(texture_filename);
|
||||||
glutFullScreen();
|
if (fullscreen) glutFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(void)
|
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());
|
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!
|
// Update all this stuff to any agents that are nearby and need to see it!
|
||||||
|
/*
|
||||||
const int MAX_BROADCAST_STRING = 200;
|
const int MAX_BROADCAST_STRING = 200;
|
||||||
char broadcast_string[MAX_BROADCAST_STRING];
|
char broadcast_string[MAX_BROADCAST_STRING];
|
||||||
int broadcast_bytes = myHead.getBroadcastData(broadcast_string);
|
int broadcast_bytes = myHead.getBroadcastData(broadcast_string);
|
||||||
broadcast_to_agents(UDP_socket, broadcast_string, broadcast_bytes);
|
broadcast_to_agents(UDP_socket, broadcast_string, broadcast_bytes);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int render_test_spot = WIDTH/2;
|
||||||
|
int render_test_direction = 1;
|
||||||
|
|
||||||
void display(void)
|
void display(void)
|
||||||
{
|
{
|
||||||
glEnable (GL_DEPTH_TEST);
|
glEnable (GL_DEPTH_TEST);
|
||||||
|
@ -602,6 +609,18 @@ void display(void)
|
||||||
glVertex2f(head_mouse_x, head_mouse_y);
|
glVertex2f(head_mouse_x, head_mouse_y);
|
||||||
glEnd();
|
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
|
// Show detected levels from the serial I/O ADC channel sensors
|
||||||
if (display_levels)
|
if (display_levels)
|
||||||
|
@ -759,7 +778,7 @@ void read_network()
|
||||||
//
|
//
|
||||||
// Broadcast packet from another agent
|
// 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
|
// Check and render display frame
|
||||||
if (diffclock(last_frame,check) > RENDER_FRAME_MSECS)
|
if (diffclock(last_frame,check) > RENDER_FRAME_MSECS)
|
||||||
{
|
{
|
||||||
|
steps_per_frame++;
|
||||||
// Simulation
|
// Simulation
|
||||||
update_pos(1.f/FPS);
|
update_pos(1.f/FPS);
|
||||||
if (simulate_on) {
|
if (simulate_on) {
|
||||||
|
|
|
@ -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,
|
int received_bytes = recvfrom(handle, (char*)packet_data, MAX_PACKET_SIZE,
|
||||||
0, (sockaddr*)&dest_address, &fromLength );
|
0, (sockaddr*)&dest_address, &fromLength );
|
||||||
|
from_addr->s_addr = dest_address.sin_addr.s_addr;
|
||||||
|
|
||||||
if (!delay) {
|
if (!delay) {
|
||||||
// No delay set, so just return packets immediately!
|
// No delay set, so just return packets immediately!
|
||||||
return received_bytes;
|
return received_bytes;
|
||||||
|
|
|
@ -22,7 +22,7 @@ const int UDP_PORT = 30001;
|
||||||
const char DESTINATION_IP[] = "127.0.0.1";
|
const char DESTINATION_IP[] = "127.0.0.1";
|
||||||
|
|
||||||
// Address and port of spaceserver process to advertise other agents
|
// 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;
|
const int SPACESERVER_PORT = 40000;
|
||||||
|
|
||||||
// Randomly send a ping packet every N packets sent
|
// Randomly send a ping packet every N packets sent
|
||||||
|
|
Loading…
Reference in a new issue