mirror of
https://github.com/JulianGro/overte.git
synced 2025-07-16 17:37:33 +02:00
Don't render head if you are inside it (it's your own)
This commit is contained in:
parent
864bcb0a03
commit
10ff074e38
5 changed files with 125 additions and 112 deletions
|
@ -57,7 +57,7 @@ int update_agents(char * data, int length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the heads of the agents
|
// Render the heads of the agents
|
||||||
void render_agents(int renderSelf) {
|
void render_agents(int renderSelf, float * myLocation) {
|
||||||
for (int i = 0; i < num_agents; i++) {
|
for (int i = 0; i < num_agents; i++) {
|
||||||
glm::vec3 pos = agents[i].head.getPos();
|
glm::vec3 pos = agents[i].head.getPos();
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -120,11 +120,12 @@ int broadcastToAgents(UDPSocket *handle, char * data, int length, int sendToSelf
|
||||||
int sent_bytes;
|
int sent_bytes;
|
||||||
//printf("broadcasting to %d agents\n", num_agents);
|
//printf("broadcasting to %d agents\n", num_agents);
|
||||||
for (int i = 0; i < num_agents; i++) {
|
for (int i = 0; i < num_agents; i++) {
|
||||||
//std::cout << "to: Agent address " << agents[i].address << " port " << agents[i].port << "\n";
|
if (sendToSelf || (((strcmp((char *)"127.0.0.1", agents[i].address) != 0)
|
||||||
if (sendToSelf || ((strcmp((char *)"127.0.0.1", agents[i].address) != 0)
|
&& (agents[i].port != AGENT_UDP_PORT))))
|
||||||
&& (agents[i].port != AGENT_UDP_PORT)))
|
|
||||||
|
|
||||||
if (agents[i].agentType != 'M') {
|
if (agents[i].agentType != 'M') {
|
||||||
|
//std::cout << "broadcasting my agent data to: " << agents[i].address << " : " << agents[i].port << "\n";
|
||||||
|
|
||||||
sent_bytes = handle->send(agents[i].address, agents[i].port, data, length);
|
sent_bytes = handle->send(agents[i].address, agents[i].port, data, length);
|
||||||
if (sent_bytes != length) {
|
if (sent_bytes != length) {
|
||||||
std::cout << "Broadcast to agents FAILED\n";
|
std::cout << "Broadcast to agents FAILED\n";
|
||||||
|
|
|
@ -27,7 +27,7 @@ int broadcastToAgents(UDPSocket * handle, char * data, int length, int sendToSel
|
||||||
void pingAgents(UDPSocket *handle);
|
void pingAgents(UDPSocket *handle);
|
||||||
void setAgentPing(char * address, unsigned short port);
|
void setAgentPing(char * address, unsigned short port);
|
||||||
void update_agent(char * address, unsigned short port, char * data, int length);
|
void update_agent(char * address, unsigned short port, char * data, int length);
|
||||||
void render_agents(int renderSelf);
|
void render_agents(int renderSelf, float * myLocation);
|
||||||
void kludgyMixerUpdate(Audio audio);
|
void kludgyMixerUpdate(Audio audio);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -206,10 +206,17 @@ void Head::simulate(float deltaTime)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::render(int faceToFace)
|
void Head::render(int faceToFace, float * myLocation)
|
||||||
{
|
{
|
||||||
int side = 0;
|
int side = 0;
|
||||||
|
|
||||||
|
glm::vec3 cameraHead(myLocation[0], myLocation[1], myLocation[2]);
|
||||||
|
float distanceToCamera = glm::distance(cameraHead, position);
|
||||||
|
|
||||||
|
//std::cout << distanceToCamera << "\n";
|
||||||
|
|
||||||
|
// Don't render a head if it is really close to your location, because that is your own head!
|
||||||
|
if (distanceToCamera > 0.1) {
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
|
@ -319,6 +326,8 @@ void Head::render(int faceToFace)
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Transmit data to agents requesting it
|
// Transmit data to agents requesting it
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
float getRoll() {return Roll;}
|
float getRoll() {return Roll;}
|
||||||
float getYaw() {return Yaw;}
|
float getYaw() {return Yaw;}
|
||||||
|
|
||||||
void render(int faceToFace);
|
void render(int faceToFace, float * myLocation);
|
||||||
void simulate(float);
|
void simulate(float);
|
||||||
// Send and receive network data
|
// Send and receive network data
|
||||||
int getBroadcastData(char* data);
|
int getBroadcastData(char* data);
|
||||||
|
|
|
@ -58,7 +58,7 @@ int simulate_on = 1;
|
||||||
|
|
||||||
const int MAX_PACKET_SIZE = 1500;
|
const int MAX_PACKET_SIZE = 1500;
|
||||||
char DOMAIN_HOSTNAME[] = "highfidelity.below92.com";
|
char DOMAIN_HOSTNAME[] = "highfidelity.below92.com";
|
||||||
char DOMAIN_IP[100] = ""; // IP Address will be re-set by lookup on startup
|
char DOMAIN_IP[100] = "192.168.1.47"; // IP Address will be re-set by lookup on startup
|
||||||
const int DOMAINSERVER_PORT = 40102;
|
const int DOMAINSERVER_PORT = 40102;
|
||||||
UDPSocket agentSocket(AGENT_UDP_PORT);
|
UDPSocket agentSocket(AGENT_UDP_PORT);
|
||||||
|
|
||||||
|
@ -570,7 +570,7 @@ void display(void)
|
||||||
if (display_field) field.render();
|
if (display_field) field.render();
|
||||||
|
|
||||||
// Render heads of other agents
|
// Render heads of other agents
|
||||||
render_agents(sendToSelf);
|
render_agents(sendToSelf, &location[0]);
|
||||||
|
|
||||||
if (display_hand) myHand.render();
|
if (display_hand) myHand.render();
|
||||||
|
|
||||||
|
@ -585,7 +585,7 @@ void display(void)
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(0.f, 0.f, -7.f);
|
glTranslatef(0.f, 0.f, -7.f);
|
||||||
myHead.render(1);
|
myHead.render(1, &location[0]);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
//glm::vec3 test(0.5, 0.5, 0.5);
|
//glm::vec3 test(0.5, 0.5, 0.5);
|
||||||
|
@ -802,6 +802,7 @@ void *networkReceive(void *args)
|
||||||
//
|
//
|
||||||
// Broadcast packet from another agent
|
// Broadcast packet from another agent
|
||||||
//
|
//
|
||||||
|
//printf("broadcast received");
|
||||||
update_agent(inet_ntoa(senderAddress.sin_addr), ntohs(senderAddress.sin_port), &incomingPacket[1], bytesRecvd - 1);
|
update_agent(inet_ntoa(senderAddress.sin_addr), ntohs(senderAddress.sin_port), &incomingPacket[1], bytesRecvd - 1);
|
||||||
} else if (incomingPacket[0] == 'T') {
|
} else if (incomingPacket[0] == 'T') {
|
||||||
// Received a self-test packet (to get one's own IP), copy it to local variable!
|
// Received a self-test packet (to get one's own IP), copy it to local variable!
|
||||||
|
@ -928,6 +929,7 @@ int main(int argc, char** argv)
|
||||||
incomingPacket = new char[MAX_PACKET_SIZE];
|
incomingPacket = new char[MAX_PACKET_SIZE];
|
||||||
|
|
||||||
// Lookup the IP address of things we have hostnames
|
// Lookup the IP address of things we have hostnames
|
||||||
|
/*
|
||||||
printf("need to look this one up\n");
|
printf("need to look this one up\n");
|
||||||
struct hostent* pHostInfo;
|
struct hostent* pHostInfo;
|
||||||
if ((pHostInfo = gethostbyname(DOMAIN_HOSTNAME)) != NULL) {
|
if ((pHostInfo = gethostbyname(DOMAIN_HOSTNAME)) != NULL) {
|
||||||
|
@ -939,6 +941,7 @@ int main(int argc, char** argv)
|
||||||
} else {
|
} else {
|
||||||
printf("Failed lookup domain server\n");
|
printf("Failed lookup domain server\n");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//std::cout << "Test address: " << inet_ntoa(testAddress.sin_addr) << "\n";
|
//std::cout << "Test address: " << inet_ntoa(testAddress.sin_addr) << "\n";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue