-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrame.cpp
44 lines (37 loc) · 1.59 KB
/
Frame.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <string>
#include "Frame.hpp"
std::ostream& cse125framing::operator<<(std::ostream& os, const ClientFrame* frame)
{
const vec3& camera = frame->cameraDirection;
os << "Client frame:" << std::endl;
os << "id: " << frame->id << std::endl;
os << "ctr: " << frame->ctr << std::endl;
os << "camera: " << "(" << camera.x << ", " << camera.y << ", " << camera.z << ")" << std::endl;
return os;
}
std::ostream& cse125framing::operator<<(std::ostream& os, const ServerFrame* frame)
{
os << "Server frame:" << std::endl;
os << "id: " << frame->id << std::endl;
os << "Server frame ctr: " << frame->ctr << std::endl;
//os << "Position: " << "(" << frame->playerPosition.x << ", " << frame->playerPosition.y << ", " << frame->playerPosition.z << ")" << std::endl;
//os << "Direction: " << "(" << frame->playerDirection.x << ", " << frame->playerDirection.y << ", " << frame->playerDirection.z << ")" << std::endl;
return os;
}
void cse125framing::serialize(const ClientFrame* frame, boost::array<char, CLIENT_FRAME_BUFFER_SIZE>& buffer)
{
std::memcpy(&buffer, frame, sizeof(ClientFrame));
}
void cse125framing::deserialize(ClientFrame* frame, const boost::array<char, CLIENT_FRAME_BUFFER_SIZE>& buffer)
{
std::memcpy(frame, &buffer, sizeof(ClientFrame));
}
void cse125framing::serialize(const ServerFrame* frame, boost::array<char, SERVER_FRAME_BUFFER_SIZE>& buffer)
{
std::memcpy(&buffer, frame, sizeof(ServerFrame));
}
void cse125framing::deserialize(ServerFrame* frame, const boost::array<char, SERVER_FRAME_BUFFER_SIZE>& buffer)
{
std::memcpy(frame, &buffer, sizeof(ServerFrame));
}