moved AvatarAgentData to AvatarData

This commit is contained in:
Stephen Birarda 2013-04-15 15:05:55 -07:00
parent 4702e6ade0
commit 2dfe49a885
4 changed files with 129 additions and 131 deletions

View file

@ -32,7 +32,7 @@
#include <StdDev.h>
#include <UDPSocket.h>
#include "AvatarAgentData.h"
#include "AvatarData.h"
const int AVATAR_LISTEN_PORT = 55444;
const unsigned short BROADCAST_INTERVAL_USECS = 20 * 1000 * 1000;
@ -40,7 +40,7 @@ const unsigned short BROADCAST_INTERVAL_USECS = 20 * 1000 * 1000;
unsigned char *addAgentToBroadcastPacket(unsigned char *currentPosition, Agent *agentToAdd) {
currentPosition += packAgentId(currentPosition, agentToAdd->getAgentId());
AvatarAgentData *agentData = (AvatarAgentData *)agentToAdd->getLinkedData();
AvatarData *agentData = (AvatarData *)agentToAdd->getLinkedData();
int bytesWritten = sprintf((char *)currentPosition,
PACKET_FORMAT,
@ -62,7 +62,7 @@ unsigned char *addAgentToBroadcastPacket(unsigned char *currentPosition, Agent *
void attachAvatarDataToAgent(Agent *newAgent) {
if (newAgent->getLinkedData() == NULL) {
newAgent->setLinkedData(new AvatarAgentData());
newAgent->setLinkedData(new AvatarData());
}
}

View file

@ -1,118 +0,0 @@
//
// AvatarAgentData.cpp
// hifi
//
// Created by Stephen Birarda on 4/9/13.
//
//
#include <cstdio>
#include "AvatarAgentData.h"
AvatarAgentData::AvatarAgentData() {
}
AvatarAgentData::~AvatarAgentData() {
}
AvatarAgentData* AvatarAgentData::clone() const {
return new AvatarAgentData(*this);
}
void AvatarAgentData::parseData(void *data, int size) {
char* packetData = (char *)data + 1;
// Extract data from packet
sscanf(packetData,
PACKET_FORMAT,
&_pitch,
&_yaw,
&_roll,
&_headPositionX,
&_headPositionY,
&_headPositionZ,
&_loudness,
&_averageLoudness,
&_handPositionX,
&_handPositionY,
&_handPositionZ);
}
float AvatarAgentData::getPitch() {
return _pitch;
}
float AvatarAgentData::getYaw() {
return _yaw;
}
float AvatarAgentData::getRoll() {
return _roll;
}
float AvatarAgentData::getHeadPositionX() {
return _headPositionX;
}
float AvatarAgentData::getHeadPositionY() {
return _headPositionY;
}
float AvatarAgentData::getHeadPositionZ() {
return _headPositionZ;
}
float AvatarAgentData::getLoudness() {
return _loudness;
}
float AvatarAgentData::getAverageLoudness() {
return _averageLoudness;
}
float AvatarAgentData::getHandPositionX() {
return _handPositionX;
}
float AvatarAgentData::getHandPositionY() {
return _handPositionY;
}
float AvatarAgentData::getHandPositionZ() {
return _handPositionZ;
}
void AvatarAgentData::setPitch(float pitch) {
_pitch = pitch;
}
void AvatarAgentData::setYaw(float yaw) {
_yaw = yaw;
}
void AvatarAgentData::setRoll(float roll) {
_roll = roll;
}
void AvatarAgentData::setHeadPosition(float x, float y, float z) {
_headPositionX = x;
_headPositionY = y;
_headPositionZ = z;
}
void AvatarAgentData::setLoudness(float loudness) {
_loudness = loudness;
}
void AvatarAgentData::setAverageLoudness(float averageLoudness) {
_averageLoudness = averageLoudness;
}
void AvatarAgentData::setHandPosition(float x, float y, float z) {
_handPositionX = x;
_handPositionY = y;
_handPositionZ = z;
}

View file

@ -0,0 +1,118 @@
//
// AvatarData.cpp
// hifi
//
// Created by Stephen Birarda on 4/9/13.
//
//
#include <cstdio>
#include "AvatarData.h"
AvatarData::AvatarData() {
}
AvatarData::~AvatarData() {
}
AvatarData* AvatarData::clone() const {
return new AvatarData(*this);
}
void AvatarData::parseData(void *data, int size) {
char* packetData = (char *)data + 1;
// // Extract data from packet
// sscanf(packetData,
// PACKET_FORMAT,
// &_pitch,
// &_yaw,
// &_roll,
// &_headPositionX,
// &_headPositionY,
// &_headPositionZ,
// &_loudness,
// &_averageLoudness,
// &_handPositionX,
// &_handPositionY,
// &_handPositionZ);
}
float AvatarData::getPitch() {
return _pitch;
}
float AvatarData::getYaw() {
return _yaw;
}
float AvatarData::getRoll() {
return _roll;
}
float AvatarData::getHeadPositionX() {
return _headPositionX;
}
float AvatarData::getHeadPositionY() {
return _headPositionY;
}
float AvatarData::getHeadPositionZ() {
return _headPositionZ;
}
float AvatarData::getLoudness() {
return _loudness;
}
float AvatarData::getAverageLoudness() {
return _averageLoudness;
}
float AvatarData::getHandPositionX() {
return _handPositionX;
}
float AvatarData::getHandPositionY() {
return _handPositionY;
}
float AvatarData::getHandPositionZ() {
return _handPositionZ;
}
void AvatarData::setPitch(float pitch) {
_pitch = pitch;
}
void AvatarData::setYaw(float yaw) {
_yaw = yaw;
}
void AvatarData::setRoll(float roll) {
_roll = roll;
}
void AvatarData::setHeadPosition(float x, float y, float z) {
_headPositionX = x;
_headPositionY = y;
_headPositionZ = z;
}
void AvatarData::setLoudness(float loudness) {
_loudness = loudness;
}
void AvatarData::setAverageLoudness(float averageLoudness) {
_averageLoudness = averageLoudness;
}
void AvatarData::setHandPosition(float x, float y, float z) {
_handPositionX = x;
_handPositionY = y;
_handPositionZ = z;
}

View file

@ -1,26 +1,24 @@
//
// AvatarAgentData.h
// AvatarData.h
// hifi
//
// Created by Stephen Birarda on 4/9/13.
//
//
#ifndef __hifi__AvatarAgentData__
#define __hifi__AvatarAgentData__
#ifndef __hifi__AvatarData__
#define __hifi__AvatarData__
#include <iostream>
#include <AgentData.h>
const char PACKET_FORMAT[] = "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f";
class AvatarAgentData : public AgentData {
class AvatarData : public AgentData {
public:
AvatarAgentData();
~AvatarAgentData();
AvatarData();
~AvatarData();
void parseData(void *data, int size);
AvatarAgentData* clone() const;
AvatarData* clone() const;
float getPitch();
void setPitch(float pitch);
@ -55,4 +53,4 @@ private:
float _handPositionZ;
};
#endif /* defined(__hifi__AvatarAgentData__) */
#endif /* defined(__hifi__AvatarData__) */