Skip to content

Commit

Permalink
Merge branch 'master' into trunk
Browse files Browse the repository at this point in the history
# Conflicts:
#	SynchronisationServer/SyncServer/SyncServer.pro.user
#	SynchronisationServer/src/mainapp.cpp
#	SynchronisationServer/src/zeroMQHandler.cpp
#	VPET_Unity/Assets/VPET/Scripts/IO/InputAdapter.cs
#	VPET_Unity/VPET.unitypackage
  • Loading branch information
smoi23 committed Jul 27, 2017
2 parents 8b3e320 + bf0fc72 commit cadf383
Show file tree
Hide file tree
Showing 23 changed files with 658 additions and 112 deletions.
Binary file added Docs/Images/vpetScene.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions Docs/Tutorials.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ <h1>How to build VPET for Windows, Android and Google Tango</h1>
<iframe width="560" height="315" src="https://www.youtube.com/embed/iv0dDoPE_0E" frameborder="0" allowfullscreen></iframe>
<h1>Katana + VPET Tutorial</h1>
<iframe width="560" height="315" src="https://www.youtube.com/embed/z3BAYGiIeC8" frameborder="0" allowfullscreen></iframe>
<h1>How to export example data set for use in Katana</h1>
<p>The data set shows a Ranch and contains a Maya project including scene file, textures, exported scenegraph xml and Katana files. You can download it from here: <a href="#">VpetScene</a>
</p>
<p>
<img src="images/vpetScene.png">
</p>
<p>After you unpacked the zip file open Maya and set the project to 'vpetScene'. Open 'vpetSceneExport.mb' and copy/paste the script 'exportVpetScene.py' from 'scripts/python' into Maya's script editor. You will find a few more details in the script but basically select the top node 'master' and run the script. This will write the scenegraph xml and alembic cachses to a subfolder within scenes.
</p>
<p>To start Katana navigate to the vpetScene root folder (where the bash script 'vpetKatana.sh' lives) and open 'vpetKatana.sh' in a text editor. Make sure the paths are set correctly and save the file, then run the script as bash. Now in Katana open vpetMasterScene and in the very top of the node graph you will find a node called 'RanchSceneXML'. Make sure the asset is pointing to the correct vpet.xml source file - either the one you just exported or the one which is included inside the package.
</p>
<p>From here render the scene with Arnold or start distributing it to a VPET client. Have a look at the Katana+VPET Tutorial how to do this.
</p>
</td>
</tr>
</table>
Expand Down
10 changes: 10 additions & 0 deletions SceneDistribution_Katana/src/Render/include/PluginState.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ namespace Katana
unsigned char* colorMapData;
};


#pragma pack(4)
struct VpetHeader
{
float lightIntensityFactor = 1.0;
int textureBinaryType = 0;
};


struct SceneDistributorPluginState
{
SceneDistributorPluginState():
Expand Down Expand Up @@ -143,6 +152,7 @@ namespace Katana
std::string lodTag;

// Data holder
VpetHeader vpetHeader;
std::vector<Node*> nodeList;
std::vector<NodeType> nodeTypeList;
std::vector<ObjectPackage> objPackList;
Expand Down
38 changes: 36 additions & 2 deletions SceneDistribution_Katana/src/Render/src/SceneDistributorPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@ int SceneDistributorPlugin::start()

FnKat::FnScenegraphIterator rootIterator = getRootIterator();


// get header values
FnAttribute::FloatAttribute lightIntensityAttr = rootIterator.getAttribute("sceneDistributorGlobalStatements.lightIntensityFactor");
if ( lightIntensityAttr.isValid())
{

_sharedState.vpetHeader.lightIntensityFactor = lightIntensityAttr.getValue(1.0, false);
}
else
{
std::cout << "[INFO SceneDistributor] ERROR Not found attribute: lightIntensityFactor" << std::endl;
}

FnAttribute::IntAttribute textureTypeAttr = rootIterator.getAttribute("sceneDistributorGlobalStatements.textureBinaryType");
if ( textureTypeAttr.isValid())
{

_sharedState.vpetHeader.textureBinaryType = textureTypeAttr.getValue(0, false);
}
else
{
std::cout << "[INFO SceneDistributor] ERROR Not found attribute: textureBinaryType" << std::endl;
}




// Process render settings
/*int width, height;
FnKat::RenderOutputUtils::getRenderResolution(rootIterator, &width, &height);
Expand Down Expand Up @@ -302,9 +329,16 @@ static void* server(void *scene)

std::cout << "[INFO SceneDistributorPlugin.server] Got request string: " << msgString << std::endl;

if (msgString == "objects")
if (msgString == "header")
{
std::cout << "[INFO SceneDistributorPlugin.server] Got Header Request" << std::endl;
responseLength =sizeof(VpetHeader);
messageStart = responseMessageContent = (char*)malloc(responseLength);
memcpy(responseMessageContent, (char*)&(sharedState->vpetHeader), sizeof(VpetHeader));
}
else if (msgString == "objects")
{
std::cout << "[INFO SceneDistributorPlugin.server] Got Objcts Request" << std::endl;
std::cout << "[INFO SceneDistributorPlugin.server] Got Objects Request" << std::endl;
std::cout << "[INFO SceneDistributorPlugin.server] Object count " << sharedState->objPackList.size() << std::endl;
responseLength = sizeof(int) * 4 * sharedState->objPackList.size();
for (int i = 0; i < sharedState->objPackList.size(); i++)
Expand Down
50 changes: 35 additions & 15 deletions SceneDistribution_Katana/src/Render/src/SceneIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,34 @@ void buildLocation(FnKat::FnScenegraphIterator sgIterator, SceneDistributorPlugi
*/

FnAttribute::GroupAttribute xformAttr = sgIterator.getAttribute("xform");

if (xformAttr.isValid())
{
FnAttribute::DoubleAttribute matrixAttr = FnGeolibServices::FnXFormUtil::CalcTransformMatrixAtTime(xformAttr, 0.0f).first;
FnAttribute::DoubleConstVector matrixData = matrixAttr.getNearestSample(0.0);
transform = glm::mat4(matrixData[ 0], matrixData[ 1], matrixData[ 2], matrixData[ 3],
matrixData[ 4], matrixData[ 5], matrixData[ 6], matrixData[ 7],
matrixData[ 8], matrixData[ 9], matrixData[10], matrixData[11],
matrixData[12], matrixData[13], matrixData[14], matrixData[15]);
// transform = glm::mat4(matrixData[ 0], matrixData[ 1], matrixData[ 2], matrixData[ 3],
// matrixData[ 4], matrixData[ 5], matrixData[ 6], matrixData[ 7],
// matrixData[ 8], matrixData[ 9], matrixData[10], matrixData[11],
// matrixData[12], matrixData[13], matrixData[14], matrixData[15]);

// TODO: Hardcoded handiness
if ( sharedState->nodeTypeList[sharedState->nodeTypeList.size()-1] == Dreamspace::Katana::NodeType::CAMERA || sharedState->nodeTypeList[sharedState->nodeTypeList.size()-1] == Dreamspace::Katana::NodeType::LIGHT)
{

transform = glm::mat4(matrixData[ 0], -matrixData[ 4], -matrixData[ 8], matrixData[ 3],
-matrixData[ 1], matrixData[ 5], matrixData[ 9], matrixData[ 7],
-matrixData[ 2], matrixData[ 6], matrixData[10], matrixData[11],
-matrixData[12], matrixData[13], matrixData[14], matrixData[15]);
}
else
{
transform = glm::mat4(matrixData[ 0], -matrixData[ 4], -matrixData[ 8], matrixData[ 3],
-matrixData[ 1], matrixData[ 5], matrixData[ 9], matrixData[ 7],
-matrixData[ 2], matrixData[ 6], matrixData[10], matrixData[11],
-matrixData[12], matrixData[13], matrixData[14], matrixData[15]);

}

}


Expand Down Expand Up @@ -144,31 +164,31 @@ void buildLocation(FnKat::FnScenegraphIterator sgIterator, SceneDistributorPlugi
}





glm::vec3 skew, position, scale;
glm::vec4 persp;
glm::quat _rotation;
glm::quat rotation;
glm::decompose(transform, scale, _rotation, position, skew, persp);

glm::quat rotation(_rotation.w, -_rotation.x, -_rotation.y, -_rotation.z);

// TODO: Hardcoded handiness
if ( sharedState->nodeTypeList[sharedState->nodeTypeList.size()-1] == Dreamspace::Katana::NodeType::CAMERA)
if ( sharedState->nodeTypeList[sharedState->nodeTypeList.size()-1] == Dreamspace::Katana::NodeType::CAMERA || sharedState->nodeTypeList[sharedState->nodeTypeList.size()-1] == Dreamspace::Katana::NodeType::LIGHT)
{
glm::vec3 axisY(0.0f, 1.0f, 0.0f);
rotation = glm::rotate( rotation, 3.140f, axisY);
glm::vec3 axis (0, 1, 0);
float angle = 3.14;
rotation = glm::rotate(_rotation, angle, axis);
}
else if ( sharedState->nodeTypeList[sharedState->nodeTypeList.size()-1] == Dreamspace::Katana::NodeType::LIGHT)
else
{
glm::vec3 axisY(0.0f, 1.0f, 0.0f);
rotation = glm::rotate( rotation, 3.140f, axisY);
rotation = _rotation;
}


//std::cout << "pos: " << position[0] << " " << position[1] << " " << position[2] << std::endl;
// std::cout << "rot: " << rotation[0] << " " << rotation[1] << " " << rotation[2] << " " << rotation[3] << std::endl;

// TODO: Hardcoded handiness
sharedState->node->position[0] = -position[0];
sharedState->node->position[0] = position[0];
sharedState->node->position[1] = position[1];
sharedState->node->position[2] = position[2];

Expand Down
Loading

0 comments on commit cadf383

Please sign in to comment.