protected override void OnNodeSet() { base.OnNodeSet(); DomNodeUtil.SetVector(DomNode, Schema.gameObjectType.scaleAttribute, new Vec3F(0.4f, 0.4f, 0.4f)); UpdateTransform(); TransformationType = TransformationTypes.Translation; }
/// <summary> /// Raises the NodeSet event and performs custom processing</summary> protected override void OnNodeSet() { base.OnNodeSet(); Box boxValue = DomNodeUtil.GetBox(DomNode, Schema.meshType.boundingBoxAttribute); m_boundingBox = boxValue.IsEmpty ? new Cached <Box>(CalculateBoundingBox) : new Cached <Box>(CalculateBoundingBox, boxValue); }
private void SetVector(DomNode domNode, ChildInfo metaElement, AttributeInfo attributeInfo, Vec3F v) { if (domNode == null) { domNode = DomNode.GetChild(metaElement); } DomNodeUtil.SetVector(domNode, attributeInfo, v); }
public static DomNode Create(Uri reference, string name, Vec3F mins, Vec3F maxs) { var result = new DomNode(CellRefST.Type); result.SetAttribute(CellRefST.refAttribute, reference); result.SetAttribute(CellRefST.nameAttribute, name); DomNodeUtil.SetVector(result, CellRefST.captureMinsAttribute, mins); DomNodeUtil.SetVector(result, CellRefST.captureMaxsAttribute, maxs); return(result); }
/// <summary> /// Calculates bounding box of node's children</summary> /// <returns>Bounding box of children</returns> public Box CalculateBoundingBox() { var box = new Box(); foreach (IBoundable boundable in DomNode.Children.AsIEnumerable <IBoundable>()) { box.Extend(boundable.BoundingBox); } box.Transform(Transform); DomNodeUtil.SetBox(DomNode, Schema.nodeType.boundingBoxAttribute, box); return(box); }
private Vec3F GetVector(DomNode domNode, AttributeInfo attributeInfo) { Vec3F result; if (domNode != null) { DomNodeUtil.GetVector(domNode, attributeInfo, out result); } else { result = new Vec3F(); } return(result); }
/// <summary> /// Calculates the geometry's bounding box</summary> /// <returns>Bounding box for geometry</returns> public Box CalculateBoundingBox() { Box box = new Box(); foreach (DataSet dataSet in DataSets) { if (dataSet.Name == "position") { box.Extend(dataSet.Data); break; } } DomNodeUtil.SetBox(DomNode, Schema.meshType.boundingBoxAttribute, box); return(box); }
/// <summary> /// Performs initialization when the adapter's node is set. /// This method is called each time the adapter is connected to its underlying node. /// Typically overridden by creators of DOM adapters.</summary> protected override void OnNodeSet() { base.OnNodeSet(); Box boxValue = DomNodeUtil.GetBox(DomNode, Schema.meshType.boundingBoxAttribute); if (boxValue.IsEmpty) { m_boundingBox = new Cached <Box>(CalculateBoundingBox); // don't set value and force to compute } else { m_boundingBox = new Cached <Box>(CalculateBoundingBox, boxValue); // non-default value found, use it } }
/// <summary> /// Performs custom actions on NodeSet events. /// Called after successfully attaching to internal DOM object.</summary> protected override void OnNodeSet() { base.OnNodeSet(); // Initialize scale to (1, 1, 1) if missing DomNode.SetAttributeIfDefault(Schema.nodeType.scaleAttribute, new Vec3F(1, 1, 1)); m_rotation = DomNode.GetChild(Schema.nodeType.rotEulChild); m_rotationAxis = DomNode.GetChild(Schema.nodeType.rotAxisEulChild); Transform = TransformUtils.CalcTransform(this); Box boxValue = DomNodeUtil.GetBox(DomNode, Schema.nodeType.boundingBoxAttribute); if (boxValue.IsEmpty) { m_boundingBox = new Cached <Box>(CalculateBoundingBox); // don't set value and force to compute } else { m_boundingBox = new Cached <Box>(CalculateBoundingBox, boxValue); // non-default value found, use it } }