/** * @brief * Writes the scene node position, rotation, scale, bounding box and flags into a file */ void PLSceneNode::WriteToFilePosRotScaleBoxFlags(XmlElement &cNodeElement) const { // Currently ONLY the center of the container the node is in use used to make it relative const Point3 vParentWorldSpaceCenter = GetContainer() ? GetContainer()->GetWorldSpaceCenter() : Point3(0.0f, 0.0f, 0.0f); // Write down the position PLTools::XmlElementSetAttributeWithDefault(cNodeElement, "Position", (GetType() != TypeScene && GetType() != TypeCell) ? m_vPos-vParentWorldSpaceCenter : static_cast<const PLSceneContainer*>(this)->GetWorldSpaceCenter(), Point3(0.0f, 0.0f, 0.0f)); // Write down the rotation PLTools::XmlElementSetAttributeWithDefault(cNodeElement, "Rotation", m_vRot, Point3(0.0f, 0.0f, 0.0f)); // Write down the scale PLTools::XmlElementSetAttributeWithDefault(cNodeElement, "Scale", m_vScale, Point3(1.0f, 1.0f, 1.0f)); // Are there any flags? if (m_sFlags.GetLength()) { String sFlags = cNodeElement.GetAttribute("Flags"); if (sFlags.GetLength()) sFlags += '|' + m_sFlags; else sFlags = m_sFlags; sFlags.Trim(); cNodeElement.SetAttribute("Flags", sFlags); } }
/** * @brief * Writes the flexible scene node variables */ void PLSceneNode::WriteVariables(XmlElement &cNodeElement) const { // Export variables? if (g_SEOptions.bUserPropVariables) { // Is there a 3ds Max node (No 3ds Max node, no properties) INode *pMaxNode = GetMaxNode(); if (pMaxNode) { // Check for variables TSTR s3dsMaxString; if (pMaxNode->GetUserPropString(_T("Vars"), s3dsMaxString)) { // Get all expressions static RegEx cExpressionRegEx("\\s*((\\w*\\s*=\\s*\"[^\"]*\")|(\\w*\\s*=\\s*[\\w|]*))"); const String sString = s3dsMaxString; uint32 nExpressionParsePos = 0; while (cExpressionRegEx.Match(sString, nExpressionParsePos)) { // Get expression nExpressionParsePos = cExpressionRegEx.GetPosition(); const String sExpression = cExpressionRegEx.GetResult(0); // Process the found expression static RegEx cRegEx("\\s*(\\w*)\\s*=\\s*\"?\\s*([^\"]*)\\s*\"?"); if (cRegEx.Match(sExpression)) { // Get name and value const String sName = cRegEx.GetResult(0); const String sValue = cRegEx.GetResult(1); // Flags variable? if (sName == "Flags") { // Update attribute String sFlags = cNodeElement.GetAttribute(sName); if (sFlags.GetLength()) sFlags += '|' + sValue; else sFlags = sValue; sFlags.Trim(); cNodeElement.SetAttribute(sName, sFlags); } else { // Set attribute cNodeElement.SetAttribute(sName, sValue); } } } } } } }