mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +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
|
||||
void render_agents(int renderSelf) {
|
||||
void render_agents(int renderSelf, float * myLocation) {
|
||||
for (int i = 0; i < num_agents; i++) {
|
||||
glm::vec3 pos = agents[i].head.getPos();
|
||||
glPushMatrix();
|
||||
|
@ -120,11 +120,12 @@ int broadcastToAgents(UDPSocket *handle, char * data, int length, int sendToSelf
|
|||
int sent_bytes;
|
||||
//printf("broadcasting to %d agents\n", num_agents);
|
||||
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)
|
||||
&& (agents[i].port != AGENT_UDP_PORT)))
|
||||
if (sendToSelf || (((strcmp((char *)"127.0.0.1", agents[i].address) != 0)
|
||||
&& (agents[i].port != AGENT_UDP_PORT))))
|
||||
|
||||
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);
|
||||
if (sent_bytes != length) {
|
||||
std::cout << "Broadcast to agents FAILED\n";
|
||||
|
@ -142,7 +143,7 @@ void pingAgents(UDPSocket *handle) {
|
|||
if (agents[i].agentType != 'M') {
|
||||
gettimeofday(&agents[i].pingStarted, NULL);
|
||||
handle->send(agents[i].address, agents[i].port, payload, 1);
|
||||
// printf("\nSent Ping at %d usecs\n", agents[i].pingStarted.tv_usec);
|
||||
//printf("\nSent Ping at %d usecs\n", agents[i].pingStarted.tv_usec);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ int broadcastToAgents(UDPSocket * handle, char * data, int length, int sendToSel
|
|||
void pingAgents(UDPSocket *handle);
|
||||
void setAgentPing(char * address, unsigned short port);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -206,117 +206,126 @@ void Head::simulate(float deltaTime)
|
|||
|
||||
}
|
||||
|
||||
void Head::render(int faceToFace)
|
||||
void Head::render(int faceToFace, float * myLocation)
|
||||
{
|
||||
int side = 0;
|
||||
int side = 0;
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glPushMatrix();
|
||||
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);
|
||||
glPushMatrix();
|
||||
|
||||
glScalef(scale, scale, scale);
|
||||
glTranslatef(leanSideways, 0.f, leanForward);
|
||||
glScalef(scale, scale, scale);
|
||||
glTranslatef(leanSideways, 0.f, leanForward);
|
||||
|
||||
glRotatef(Yaw/2.0, 0, 1, 0);
|
||||
glRotatef(Pitch/2.0, 1, 0, 0);
|
||||
glRotatef(Roll/2.0, 0, 0, 1);
|
||||
glRotatef(Yaw/2.0, 0, 1, 0);
|
||||
glRotatef(Pitch/2.0, 1, 0, 0);
|
||||
glRotatef(Roll/2.0, 0, 0, 1);
|
||||
|
||||
|
||||
// Overall scale of head
|
||||
if (faceToFace) glScalef(1.5, 2.0, 2.0);
|
||||
glColor3fv(skinColor);
|
||||
|
||||
// Head
|
||||
glutSolidSphere(1, 30, 30);
|
||||
|
||||
// Ears
|
||||
glPushMatrix();
|
||||
glTranslatef(1, 0, 0);
|
||||
for(side = 0; side < 2; side++)
|
||||
|
||||
// Overall scale of head
|
||||
if (faceToFace) glScalef(1.5, 2.0, 2.0);
|
||||
glColor3fv(skinColor);
|
||||
|
||||
// Head
|
||||
glutSolidSphere(1, 30, 30);
|
||||
|
||||
// Ears
|
||||
glPushMatrix();
|
||||
glTranslatef(1, 0, 0);
|
||||
for(side = 0; side < 2; side++)
|
||||
{
|
||||
glPushMatrix();
|
||||
glScalef(0.5, 0.75, 1.0);
|
||||
glutSolidSphere(0.5, 30, 30);
|
||||
glPopMatrix();
|
||||
glTranslatef(-2, 0, 0);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
// Eyebrows
|
||||
glPushMatrix();
|
||||
glTranslatef(-interBrowDistance/2.0,0.4,0.45);
|
||||
for(side = 0; side < 2; side++)
|
||||
{
|
||||
glColor3fv(browColor);
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0.4, 0);
|
||||
glRotatef(EyebrowPitch[side]/2.0, 1, 0, 0);
|
||||
glRotatef(EyebrowRoll[side]/2.0, 0, 0, 1);
|
||||
glScalef(browWidth, browThickness, 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
glTranslatef(interBrowDistance, 0, 0);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
// Mouth
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0,-0.3,0.75);
|
||||
glColor3f(loudness/1000.0,0,0);
|
||||
glRotatef(MouthPitch, 1, 0, 0);
|
||||
glRotatef(MouthYaw, 0, 0, 1);
|
||||
glScalef(MouthWidth*(.5 + averageLoudness/3000.0), MouthHeight*(1.0 + averageLoudness/6000.0), 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
|
||||
glTranslatef(0, 1.0, 0);
|
||||
|
||||
glTranslatef(-interPupilDistance/2.0,-0.68,0.7);
|
||||
// Right Eye
|
||||
glRotatef(-10, 1, 0, 0);
|
||||
glColor3fv(eyeColor);
|
||||
glPushMatrix();
|
||||
{
|
||||
glPushMatrix();
|
||||
glScalef(0.5, 0.75, 1.0);
|
||||
glutSolidSphere(0.5, 30, 30);
|
||||
glPopMatrix();
|
||||
glTranslatef(-2, 0, 0);
|
||||
glTranslatef(interPupilDistance/10.0, 0, 0.05);
|
||||
glRotatef(20, 0, 0, 1);
|
||||
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
// Right Pupil
|
||||
glPushMatrix();
|
||||
glRotatef(EyeballPitch[1], 1, 0, 0);
|
||||
glRotatef(EyeballYaw[1] + PupilConverge, 0, 1, 0);
|
||||
glTranslatef(0,0,.35);
|
||||
if (!eyeContact) glColor3f(0,0,0); else glColor3f(0.3,0.3,0.3);
|
||||
//glRotatef(90,0,1,0);
|
||||
glutSolidSphere(PupilSize, 15, 15);
|
||||
|
||||
// Eyebrows
|
||||
glPushMatrix();
|
||||
glTranslatef(-interBrowDistance/2.0,0.4,0.45);
|
||||
for(side = 0; side < 2; side++)
|
||||
glPopMatrix();
|
||||
// Left Eye
|
||||
glColor3fv(eyeColor);
|
||||
glTranslatef(interPupilDistance, 0, 0);
|
||||
glPushMatrix();
|
||||
{
|
||||
glColor3fv(browColor);
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0.4, 0);
|
||||
glRotatef(EyebrowPitch[side]/2.0, 1, 0, 0);
|
||||
glRotatef(EyebrowRoll[side]/2.0, 0, 0, 1);
|
||||
glScalef(browWidth, browThickness, 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
glTranslatef(interBrowDistance, 0, 0);
|
||||
glTranslatef(-interPupilDistance/10.0, 0, .05);
|
||||
glRotatef(-20, 0, 0, 1);
|
||||
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
// Mouth
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0,-0.3,0.75);
|
||||
glColor3f(loudness/1000.0,0,0);
|
||||
glRotatef(MouthPitch, 1, 0, 0);
|
||||
glRotatef(MouthYaw, 0, 0, 1);
|
||||
glScalef(MouthWidth*(.5 + averageLoudness/3000.0), MouthHeight*(1.0 + averageLoudness/6000.0), 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
|
||||
glTranslatef(0, 1.0, 0);
|
||||
|
||||
glTranslatef(-interPupilDistance/2.0,-0.68,0.7);
|
||||
// Right Eye
|
||||
glRotatef(-10, 1, 0, 0);
|
||||
glColor3fv(eyeColor);
|
||||
glPushMatrix();
|
||||
{
|
||||
glTranslatef(interPupilDistance/10.0, 0, 0.05);
|
||||
glRotatef(20, 0, 0, 1);
|
||||
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
glPopMatrix();
|
||||
// Left Pupil
|
||||
glPushMatrix();
|
||||
glRotatef(EyeballPitch[0], 1, 0, 0);
|
||||
glRotatef(EyeballYaw[0] - PupilConverge, 0, 1, 0);
|
||||
glTranslatef(0,0,.35);
|
||||
if (!eyeContact) glColor3f(0,0,0); else glColor3f(0.3,0.3,0.3);
|
||||
//glRotatef(90,0,1,0);
|
||||
glutSolidSphere(PupilSize, 15, 15);
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
// Right Pupil
|
||||
glPushMatrix();
|
||||
glRotatef(EyeballPitch[1], 1, 0, 0);
|
||||
glRotatef(EyeballYaw[1] + PupilConverge, 0, 1, 0);
|
||||
glTranslatef(0,0,.35);
|
||||
if (!eyeContact) glColor3f(0,0,0); else glColor3f(0.3,0.3,0.3);
|
||||
//glRotatef(90,0,1,0);
|
||||
glutSolidSphere(PupilSize, 15, 15);
|
||||
|
||||
glPopMatrix();
|
||||
// Left Eye
|
||||
glColor3fv(eyeColor);
|
||||
glTranslatef(interPupilDistance, 0, 0);
|
||||
glPushMatrix();
|
||||
{
|
||||
glTranslatef(-interPupilDistance/10.0, 0, .05);
|
||||
glRotatef(-20, 0, 0, 1);
|
||||
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
// Left Pupil
|
||||
glPushMatrix();
|
||||
glRotatef(EyeballPitch[0], 1, 0, 0);
|
||||
glRotatef(EyeballYaw[0] - PupilConverge, 0, 1, 0);
|
||||
glTranslatef(0,0,.35);
|
||||
if (!eyeContact) glColor3f(0,0,0); else glColor3f(0.3,0.3,0.3);
|
||||
//glRotatef(90,0,1,0);
|
||||
glutSolidSphere(PupilSize, 15, 15);
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
float getRoll() {return Roll;}
|
||||
float getYaw() {return Yaw;}
|
||||
|
||||
void render(int faceToFace);
|
||||
void render(int faceToFace, float * myLocation);
|
||||
void simulate(float);
|
||||
// Send and receive network data
|
||||
int getBroadcastData(char* data);
|
||||
|
|
|
@ -58,7 +58,7 @@ int simulate_on = 1;
|
|||
|
||||
const int MAX_PACKET_SIZE = 1500;
|
||||
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;
|
||||
UDPSocket agentSocket(AGENT_UDP_PORT);
|
||||
|
||||
|
@ -74,7 +74,7 @@ int bytescount = 0;
|
|||
int target_x, target_y;
|
||||
int target_display = 0;
|
||||
|
||||
int head_mirror = 1; // Whether to mirror own head when viewing it
|
||||
int head_mirror = 1; // Whether to mirror own head when viewing it
|
||||
int sendToSelf = 1;
|
||||
|
||||
int WIDTH = 1200;
|
||||
|
@ -570,7 +570,7 @@ void display(void)
|
|||
if (display_field) field.render();
|
||||
|
||||
// Render heads of other agents
|
||||
render_agents(sendToSelf);
|
||||
render_agents(sendToSelf, &location[0]);
|
||||
|
||||
if (display_hand) myHand.render();
|
||||
|
||||
|
@ -585,7 +585,7 @@ void display(void)
|
|||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.f, 0.f, -7.f);
|
||||
myHead.render(1);
|
||||
myHead.render(1, &location[0]);
|
||||
glPopMatrix();
|
||||
}
|
||||
//glm::vec3 test(0.5, 0.5, 0.5);
|
||||
|
@ -795,13 +795,14 @@ void *networkReceive(void *args)
|
|||
//
|
||||
// Message from domainserver
|
||||
//
|
||||
// printf("agent list received!\n");
|
||||
//printf("agent list received!\n");
|
||||
nearbyAgents = update_agents(&incomingPacket[1], bytesRecvd - 1);
|
||||
kludgyMixerUpdate(audio);
|
||||
} else if (incomingPacket[0] == 'H') {
|
||||
//
|
||||
// Broadcast packet from another agent
|
||||
//
|
||||
//printf("broadcast received");
|
||||
update_agent(inet_ntoa(senderAddress.sin_addr), ntohs(senderAddress.sin_port), &incomingPacket[1], bytesRecvd - 1);
|
||||
} else if (incomingPacket[0] == 'T') {
|
||||
// Received a self-test packet (to get one's own IP), copy it to local variable!
|
||||
|
@ -927,7 +928,8 @@ int main(int argc, char** argv)
|
|||
// Create network socket and buffer
|
||||
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");
|
||||
struct hostent* pHostInfo;
|
||||
if ((pHostInfo = gethostbyname(DOMAIN_HOSTNAME)) != NULL) {
|
||||
|
@ -939,6 +941,7 @@ int main(int argc, char** argv)
|
|||
} else {
|
||||
printf("Failed lookup domain server\n");
|
||||
}
|
||||
*/
|
||||
|
||||
//std::cout << "Test address: " << inet_ntoa(testAddress.sin_addr) << "\n";
|
||||
|
||||
|
|
Loading…
Reference in a new issue