/// <summary> /// Export an entire Rhino instance definition by turning it into a Mitsuba shapegroup /// </summary> /// <param name="parent">The parent node in the output XML document</param> /// <param name="idef">The InstanceDefinition instance to be exported</param> /// <returns>true if any content was exported</returns> private void ExportInstanceDef(XmlElement parent, InstanceDefinition idef) { if (!idef.InUse(1)) { return; } var id = GetID("group"); _idMap.Add(idef.Id, id); var shapeElement = _xmlDocument.CreateElement("shape"); if (idef.Name.Length > 0) { shapeElement.AppendChild(_xmlDocument.CreateComment(" Rhino object '" + idef.Name + "' ")); } shapeElement.SetAttribute("type", "shapegroup"); shapeElement.SetAttribute("id", id); var objects = idef.GetObjects(); var success = false; foreach (var o in objects) { success |= ExportRenderMesh(shapeElement, o); } if (success) { parent.AppendChild(shapeElement); } }
public static InstanceDefinitionModel Create(InstanceDefinition definition) { return(new InstanceDefinitionModel { Description = definition.Description, Id = definition.Id, Index = definition.Index, IsInUse = definition.InUse(2), IsAssembly = !definition.IsRoot(), Name = definition.HasName? definition.Name : "Unnamed", ObjectCount = definition.ObjectCount, ObjectIds = definition.GetObjectIds(), }); }
/// <summary> /// Export an entire Rhino instance definition by turning it into a Mitsuba shapegroup /// </summary> /// <param name="parent">The parent node in the output XML document</param> /// <param name="obj">The InstanceDefinition instance to be exported</param> /// <returns>true if any content was exported</returns> private bool ExportInstanceDef(XmlElement parent, InstanceDefinition idef) { if (!idef.InUse(1)) { return(false); } string id = GetID("group"); m_idMap.Add(idef.Id, id); XmlElement shapeElement = m_xmlDocument.CreateElement("shape"); if (idef.Name.Length > 0) { shapeElement.AppendChild(m_xmlDocument.CreateComment(" Rhino object '" + idef.Name + "' ")); } shapeElement.SetAttribute("type", "shapegroup"); shapeElement.SetAttribute("id", id); RhinoObject[] objects = idef.GetObjects(); bool success = false; foreach (RhinoObject o in objects) { success |= ExportRenderMesh(shapeElement, o, false); } if (success) { parent.AppendChild(shapeElement); } return(success); }
public static bool IsInUse(this InstanceDefinition definition) { return(definition.InUse(0) | definition.InUse(1) | definition.InUse(2)); }