some cleanup

This commit is contained in:
ZappoMan 2013-06-03 21:53:06 -07:00
parent 510dfc7353
commit eef0636655
4 changed files with 2 additions and 119 deletions

View file

@ -1560,24 +1560,10 @@ void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
float farClip = camera.getFarClip();
glm::quat rotation = camera.getRotation();
glm::vec3 direction = rotation * AVATAR_FRONT;
glm::vec3 up = rotation * AVATAR_UP;
glm::vec3 right = rotation * AVATAR_RIGHT;
/*
printf("position.x=%f, position.y=%f, position.z=%f\n", position.x, position.y, position.z);
printf("yaw=%f, pitch=%f, roll=%f\n", yaw,pitch,roll);
printf("direction.x=%f, direction.y=%f, direction.z=%f\n", direction.x, direction.y, direction.z);
printf("up.x=%f, up.y=%f, up.z=%f\n", up.x, up.y, up.z);
printf("right.x=%f, right.y=%f, right.z=%f\n", right.x, right.y, right.z);
printf("fov=%f\n", fov);
printf("nearClip=%f\n", nearClip);
printf("farClip=%f\n", farClip);
*/
// Set the viewFrustum up with the correct position and orientation of the camera
viewFrustum.setPosition(position);
viewFrustum.setOrientation(o.getQuat());
viewFrustum.setOrientation(rotation);
// Also make sure it's got the correct lens details from the camera
viewFrustum.setFieldOfView(fov);

View file

@ -72,7 +72,6 @@ Avatar::Avatar(Agent* owningAgent) :
_bodyYawDelta(0.0f),
_bodyRollDelta(0.0f),
_movedHandOffset(0.0f, 0.0f, 0.0f),
_rotation(0.0f, 0.0f, 0.0f, 0.0f),
_mode(AVATAR_MODE_STANDING),
_cameraPosition(0.0f, 0.0f, 0.0f),
_handHoldingPosition(0.0f, 0.0f, 0.0f),

View file

@ -78,13 +78,6 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
// Hand Position - is relative to body position
glm::vec3 handPositionRelative = _handPosition - _position;
memcpy(destinationBuffer, &handPositionRelative, sizeof(float) * 3);
printf("handPositionRelative=%f,%f,%f\n",handPositionRelative.x, handPositionRelative.y, handPositionRelative.z);
printf("_handPosition=%f,%f,%f\n",_handPosition.x, _handPosition.y, _handPosition.z);
printf("_position=%f,%f,%f\n",_position.x, _position.y, _position.z);
packVec3ToBytes(NULL, handPositionRelative, -1.0f , 1.0f, 4);
destinationBuffer += sizeof(float) * 3;
// Lookat Position
@ -92,12 +85,9 @@ packVec3ToBytes(NULL, handPositionRelative, -1.0f , 1.0f, 4);
destinationBuffer += sizeof(_headData->_lookAtPosition);
// Instantaneous audio loudness (used to drive facial animation)
<<<<<<< HEAD
destinationBuffer += packFloatToByte(destinationBuffer, std::min(MAX_AUDIO_LOUDNESS, _audioLoudness), MAX_AUDIO_LOUDNESS);
=======
//destinationBuffer += packFloatToByte(destinationBuffer, std::min(MAX_AUDIO_LOUDNESS, _audioLoudness), MAX_AUDIO_LOUDNESS);
memcpy(destinationBuffer, &_headData->_audioLoudness, sizeof(float));
destinationBuffer += sizeof(float);
>>>>>>> c7921c4be90dc45a82793845a9a55b77a3fb5a3f
// camera details
memcpy(destinationBuffer, &_cameraPosition, sizeof(_cameraPosition));
@ -174,9 +164,6 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
memcpy(&handPositionRelative, sourceBuffer, sizeof(float) * 3);
_handPosition = _position + handPositionRelative;
sourceBuffer += sizeof(float) * 3;
printf("handPositionRelative=%f,%f,%f\n",handPositionRelative.x, handPositionRelative.y, handPositionRelative.z);
printf("_handPosition=%f,%f,%f\n",_handPosition.x, _handPosition.y, _handPosition.z);
printf("_position=%f,%f,%f\n",_position.x, _position.y, _position.z);
// Lookat Position
memcpy(&_headData->_lookAtPosition, sourceBuffer, sizeof(_headData->_lookAtPosition));
@ -341,88 +328,3 @@ int unpackFloatFromByte(unsigned char* buffer, float& value, float scaleBy) {
return sizeof(holder);
}
int packVec3ToBytes(unsigned char* buffer, const glm::vec3& vec, float min, float max, int bytes) {
const int ITEMS_IN_VEC3 = 3;
const int BITS_IN_BYTE = 8;
const int BYTE_MASK = 0xff;
assert(bytes < sizeof(double) * ITEMS_IN_VEC3);
unsigned char holder[bytes];
memset(&holder, 0, bytes);
int bitsTotal = bytes * BITS_IN_BYTE;
int bitsPerItem = floor(bitsTotal / ITEMS_IN_VEC3);
long maxEncodedPerItem = powf(2, bitsPerItem) - 1; // must be a better way to get this
float scaleBy = (max - min);
float conversionRatio = (maxEncodedPerItem / scaleBy);
printf("bitsTotal=%d\n", bitsTotal);
printf("bitsPerItem=%d\n", bitsPerItem);
printf("maxEncodedPerItem=%ld\n", maxEncodedPerItem);
printf("scaleBy=%f\n", scaleBy);
printf("conversionRatio=%f\n", conversionRatio);
int bitInByte = 0;
int byteInHolder = 0;
long encodedItem = 0;
int leftShiftThisByte = 0;
for (int i = 0; i < ITEMS_IN_VEC3; i++) {
printf(">>> item=%d\n", i);
printf("vec[item]=%f\n", vec[i]);
long encodedItemMask = maxEncodedPerItem;
encodedItem = floorf((vec[i] - min) * conversionRatio);
printf("encodedItem=%ld\n", encodedItem);
printf("encodedItemMask=%ld\n", encodedItemMask);
printf("leftShiftThisByte=%d\n", leftShiftThisByte);
for (int bitsInThisItem = 0; bitsInThisItem < bitsPerItem; ) {
printf(">>> bitsInThisItem=%d\n", bitsInThisItem);
unsigned char thisBytePortion = (encodedItemMask << leftShiftThisByte) & BYTE_MASK;
printf("thisBytePortion=%d\n", (int)thisBytePortion);
unsigned char thisByteValue = (encodedItem << leftShiftThisByte) & thisBytePortion;
printf("thisByteValue=%d\n", (int)thisByteValue);
holder[byteInHolder] |= thisByteValue;
printf("after byte %d: ", byteInHolder);
outputBufferBits((unsigned char*)&holder, bytes);
///////not handling this correctly... second portion of second item is not moving to 3rd byte...
leftShiftThisByte = 0; // reset after first time;
int numberOfBitsInThisByte = numberOfOnes(thisBytePortion);
bitsInThisItem += numberOfBitsInThisByte;
if (numberOfBitsInThisByte == 8) {
byteInHolder++;
encodedItemMask = encodedItemMask >> numberOfBitsInThisByte;
encodedItem = encodedItem >> numberOfBitsInThisByte;
} else {
leftShiftThisByte = numberOfBitsInThisByte;
}
printf("numberOfBitsInThisByte=%d\n", numberOfBitsInThisByte);
printf("AFTER bitsInThisItem=%d\n", bitsInThisItem);
printf("AFTER encodedItem=%ld\n", encodedItem);
printf("AFTER encodedItemMask=%ld\n", encodedItemMask);
}
}
printf("done: ");
outputBufferBits((unsigned char*)&holder, bytes);
//memcpy(buffer, &holder, sizeof(holder));
return sizeof(holder);
}
int unpackVec3FromBytes(unsigned char* buffer, glm::vec3& vec, float min, float max, int bytes) {
unsigned char holder[bytes];
return sizeof(holder);
}

View file

@ -164,8 +164,4 @@ int unpackClipValueFromTwoByte(unsigned char* buffer, float& clipValue);
int packFloatToByte(unsigned char* buffer, float value, float scaleBy);
int unpackFloatFromByte(unsigned char* buffer, float& value, float scaleBy);
int unpackVec3FromBytes(unsigned char* buffer, glm::vec3& vec, float min, float max, int bytes);
int packVec3ToBytes(unsigned char* buffer, const glm::vec3& vec, float min, float max, int bytes);
#endif /* defined(__hifi__AvatarData__) */