Merge branch 'develop' of openspace.itn.liu.se:/openspace into develop

This commit is contained in:
Alexander Bock
2014-12-03 15:42:51 +01:00
11 changed files with 132 additions and 63 deletions

View File

@@ -59,6 +59,7 @@ private:
void loadTexture();
properties::StringProperty _texturePath;
properties::BoolProperty _billboard;
glm::vec2 _size;
Origin _origin;

View File

@@ -42,6 +42,7 @@ public:
struct Function {
std::string name;
lua_CFunction function;
std::string argumentText;
std::string helpText;
};
std::string name;

View File

@@ -508,14 +508,18 @@ void OpenSpaceEngine::mouseScrollWheelCallback(int pos) {
void OpenSpaceEngine::encode()
{
_renderEngine.serialize(_syncBuffer);
_syncBuffer->write();
if (_syncBuffer) {
_renderEngine.serialize(_syncBuffer);
_syncBuffer->write();
}
}
void OpenSpaceEngine::decode()
{
_syncBuffer->read();
_renderEngine.deserialize(_syncBuffer);
if (_syncBuffer) {
_syncBuffer->read();
_renderEngine.deserialize(_syncBuffer);
}
}
void OpenSpaceEngine::externalControlCallback(const char* receivedChars,

View File

@@ -847,27 +847,32 @@ scripting::ScriptEngine::LuaLibrary InteractionHandler::luaLibrary() {
{
"setOrigin",
&luascriptfunctions::setOrigin,
"setOrigin(): set the camera origin node by name"
"string",
"Set the camera origin node by name"
},
{
"clearKeys",
&luascriptfunctions::clearKeys,
"clearKeys(): Clear all key bindings"
"",
"Clear all key bindings"
},
{
"bindKey",
&luascriptfunctions::bindKey,
"bindKey(): binds a key by name to a lua string command"
"string, string",
"Binds a key by name to a lua string command"
},
{
"dt",
&luascriptfunctions::dt,
"dt(): Get current frame time"
"",
"Get current frame time"
},
{
"distance",
&luascriptfunctions::distance,
"distance(): Change distance to origin"
"number",
"Change distance to origin"
}
}
};

View File

@@ -469,17 +469,20 @@ scripting::ScriptEngine::LuaLibrary LuaConsole::luaLibrary() {
{
"show",
&luascriptfunctions::show,
"show(): Shows the console"
"",
"Shows the console"
},
{
"hide",
&luascriptfunctions::hide,
"hide(): Hides the console"
"",
"Hides the console"
},
{
"toggle",
&luascriptfunctions::toggle,
"toggle(): Toggles the console"
"",
"Toggles the console"
}
}
};

View File

@@ -47,6 +47,7 @@ namespace openspace {
RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _texturePath("texture", "Texture")
, _billboard("billboard", "Billboard", false)
, _size(glm::vec2(1,1))
, _origin(Origin::Center)
, _shader(nullptr)
@@ -75,6 +76,12 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
}
}
// Attempt to get the billboard value
bool billboard = false;
if (dictionary.getValue("Billboard", billboard)) {
_billboard = billboard;
}
std::string texturePath = "";
bool success = dictionary.getValue("Texture", texturePath);
if (success)
@@ -146,6 +153,8 @@ void RenderablePlane::render(const RenderData& data) {
return;
glm::mat4 transform = glm::mat4(1.0);
if (_billboard)
transform = glm::inverse(data.camera.viewRotationMatrix());
//transform = glm::scale(transform, glm::vec3(0.01));
// Activate shader

View File

@@ -509,12 +509,14 @@ scripting::ScriptEngine::LuaLibrary RenderEngine::luaLibrary() {
{
"printImage",
&luascriptfunctions::printImage,
"printImage(): Renders the current image to a file on disk"
"",
"Renders the current image to a file on disk"
},
{
"visualizeABuffer",
&luascriptfunctions::visualizeABuffer,
"visualizeABuffer(bool): Toggles the visualization of the ABuffer"
"bool",
"Toggles the visualization of the ABuffer"
}
},
};

View File

@@ -523,20 +523,23 @@ scripting::ScriptEngine::LuaLibrary SceneGraph::luaLibrary() {
{
"setPropertyValue",
&luascriptfunctions::property_setValue,
"setPropertyValue(string, *): Sets a property identified by the URI in "
"string, *",
"Sets a property identified by the URI in "
"the first argument. The second argument can be any type, but it has to "
" agree with the type that the property expects"
},
{
"getPropertyValue",
&luascriptfunctions::property_getValue,
"getPropertyValue(string): Returns the value the property, identified by "
"string",
"Returns the value the property, identified by "
"the provided URI."
},
{
"loadScene",
&luascriptfunctions::loadScene,
"loadScene(string): Loads the scene found at the file passed as an "
"string",
"Loads the scene found at the file passed as an "
"argument. If a scene is already loaded, it is unloaded first"
}
}

View File

@@ -382,43 +382,50 @@ void ScriptEngine::addBaseLibrary() {
{
"printDebug",
&luascriptfunctions::printDebug,
"printDebug(*): Logs the passed value to the installed LogManager with a "
"*",
"Logs the passed value to the installed LogManager with a "
"LogLevel of 'Debug'"
},
{
"printInfo",
&luascriptfunctions::printInfo,
"printInfo(*): Logs the passed value to the installed LogManager with a "
"*",
"Logs the passed value to the installed LogManager with a "
" LogLevel of 'Info'"
},
{
"printWarning",
&luascriptfunctions::printWarning,
"printWarning(*): Logs the passed value to the installed LogManager with "
"*",
"Logs the passed value to the installed LogManager with "
"a LogLevel of 'Warning'"
},
{
"printError",
&luascriptfunctions::printError,
"printError(*): Logs the passed value to the installed LogManager with a "
"*",
"Logs the passed value to the installed LogManager with a "
"LogLevel of 'Error'"
},
{
"printFatal",
&luascriptfunctions::printFatal,
"printFatal(*): Logs the passed value to the installed LogManager with a "
"*",
"Logs the passed value to the installed LogManager with a "
"LogLevel of 'Fatal'"
},
{
"absPath",
&luascriptfunctions::absolutePath,
"absPath(string): Returns the absolute path to the passed path, resolving"
"string",
"Returns the absolute path to the passed path, resolving"
" path tokens as well as resolving relative paths"
},
{
"setPathToken",
&luascriptfunctions::setPathToken,
"setPathToken(string, string): Registers a new path token provided by the"
"string, string",
"Registers a new path token provided by the"
" first argument to the path provided in the second argument"
}
}
@@ -493,41 +500,70 @@ bool ScriptEngine::writeDocumentation(const std::string& filename, const std::st
LDEBUG("Writing Lua documentation of type '" << type <<
"' to file '" << filename << "'");
std::ofstream file(filename);
if (file.good()) {
auto concatenate = [](std::string library, std::string function) {
std::string total = "openspace.";
if (!library.empty())
total += std::move(library) + ".";
total += std::move(function);
return std::move(total);
};
// First iterate over all libraries and functions to find the longest
// combination so that can be used as the 'width' parameter for the output
// stream
size_t maxLength = 0;
for (auto library : _registeredLibraries) {
for (auto function : library.functions) {
std::string functionName = concatenate(library.name, function.name);
maxLength = std::max(maxLength, functionName.size());
}
}
maxLength += AdditionalSpace;
// Now write out the functions
for (auto library : _registeredLibraries) {
for (auto function : library.functions) {
std::string functionName = concatenate(library.name, function.name);
file << std::setw(maxLength) << std::left << functionName;
file << std::setw(0) << function.helpText << std::endl;
}
}
return true;
}
else {
if (!file.good()) {
LERROR("Could not open file '" << filename << "' for writing documentation");
return false;
}
auto concatenate = [](std::string library, std::string function) {
std::string total = "openspace.";
if (!library.empty())
total += std::move(library) + ".";
total += std::move(function);
return std::move(total);
};
// Settings
const unsigned int lineWidth = 80;
static const std::string whitespace = " \t";
static const std::string padding = " ";
const bool commandListArguments = true;
file << "Available commands:\n";
// Now write out the functions
for (auto library : _registeredLibraries) {
for (auto function : library.functions) {
std::string functionName = concatenate(library.name, function.name);
file << padding << functionName;
if (commandListArguments)
file << "(" << function.argumentText << ")";
file << std::endl;
}
}
file << std::endl;
// Now write out the functions definitions
for (auto library : _registeredLibraries) {
for (auto function : library.functions) {
std::string functionName = concatenate(library.name, function.name);
file << functionName << "(" << function.argumentText << "):" << std::endl;
std::string remainingHelptext = function.helpText;
while (!remainingHelptext.empty()) {
const auto length = remainingHelptext.length();
const auto paddingLength = padding.length();
if ((length + paddingLength) > lineWidth) {
auto lastSpace = remainingHelptext.find_last_of(whitespace, lineWidth - 1 - paddingLength);
if (lastSpace == remainingHelptext.npos)
lastSpace = lineWidth;
file << padding << remainingHelptext.substr(0, lastSpace) << std::endl;
auto firstNotSpace = remainingHelptext.find_first_not_of(whitespace, lastSpace);
if (firstNotSpace == remainingHelptext.npos)
firstNotSpace = lastSpace;
remainingHelptext = remainingHelptext.substr(firstNotSpace);
}
else {
file << padding << remainingHelptext << std::endl;
remainingHelptext = "";
}
}
file << std::endl;
}
}
return true;
}
else {
LERROR("Undefined type '" << type << "' for Lua documentation");

View File

@@ -212,19 +212,22 @@ scripting::ScriptEngine::LuaLibrary Time::luaLibrary() {
{
"setDeltaTime",
&luascriptfunctions::time_setDeltaTime,
"setDeltaTime(number): Sets the amount of simulation time that happens "
"number",
"Sets the amount of simulation time that happens "
"in one second of real time"
},
{
"deltaTime",
&luascriptfunctions::time_deltaTime,
"deltaTime: Returns the amount of simulated time that passes in one "
"",
"Returns the amount of simulated time that passes in one "
"second of real time"
},
{
"setTime",
&luascriptfunctions::time_setTime,
"setTime({number, string}): Sets the current simulation time to the "
"{number, string}",
"Sets the current simulation time to the "
"specified value. If the parameter is a number, the value is the number "
"of seconds past the J2000 epoch. If it is a string, it has to be a "
"valid ISO 8601 date string (YYYY-MM-DDTHH:MN:SS)"
@@ -232,14 +235,16 @@ scripting::ScriptEngine::LuaLibrary Time::luaLibrary() {
{
"currentTime",
&luascriptfunctions::time_currentTime,
"currentTime(): Returns the current time as the number of seconds since "
"",
"Returns the current time as the number of seconds since "
"the J2000 epoch"
},
{
"currentTimeUTC",
&luascriptfunctions::time_currentTimeUTC,
"currentTimeUTC: Returns the current time as an ISO 8601 date string "
"(YYYY-MM-DDTHH:MN:SS"
"",
"Returns the current time as an ISO 8601 date string "
"(YYYY-MM-DDTHH:MN:SS)"
}
}
};