mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-03 10:09:40 -06:00
OpenSpace can receive data from Glue as a long string, then read the data and separate x,y,z-coordinates into vectors
This commit is contained in:
@@ -169,6 +169,16 @@ namespace openspace {
|
||||
LINFO(fmt::format("OpenSpace has connected with {} through socket.", software));
|
||||
break;
|
||||
}
|
||||
case SoftwareConnection::MessageType::ReadBinaryData: {
|
||||
std::string binarydata(message.begin(), message.end());
|
||||
LERROR(fmt::format("Binary data recieved {}", binarydata));
|
||||
|
||||
std::vector<float> xCoordinates = readData(message);
|
||||
std::vector<float> yCoordinates = readData(message);
|
||||
std::vector<float> zCoordinates = readData(message);
|
||||
|
||||
break;
|
||||
}
|
||||
case SoftwareConnection::MessageType::AddSceneGraphNode: {
|
||||
std::string identifier = readIdentifier(message);
|
||||
glm::vec3 color = readColor(message);
|
||||
@@ -389,6 +399,36 @@ namespace openspace {
|
||||
return floatValue;
|
||||
}
|
||||
|
||||
std::vector<float> SoftwareIntegrationModule::readData(std::vector<char>& message) {
|
||||
std::string length;
|
||||
for(int i = 0; i <= 8; i++)
|
||||
length.push_back(message[i]);
|
||||
|
||||
int lengthOfData = stoi(length);
|
||||
int counter = 0;
|
||||
messageOffset = 9; // Resets messageOffset
|
||||
|
||||
std::vector< float > data;
|
||||
std::string value;
|
||||
|
||||
while (counter != lengthOfData)
|
||||
{
|
||||
while (message[messageOffset] != ',')
|
||||
{
|
||||
value.push_back(message[messageOffset]);
|
||||
messageOffset++;
|
||||
counter++;
|
||||
}
|
||||
float dataValue = stof(value);
|
||||
data.push_back(dataValue);
|
||||
value = "";
|
||||
messageOffset++;
|
||||
counter++;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::string SoftwareIntegrationModule::readIdentifier(std::vector<char>& message) {
|
||||
std::string length;
|
||||
length.push_back(message[0]);
|
||||
|
||||
Reference in New Issue
Block a user