/**
  * Create the model
  * @param String $id
  */
 public function __construct($id)
 {
     parent::__construct($id);
     $this->rotation = new ArelRotation();
 }
 /**
  * @brief Create the XML output of the AREL Object and send it to the junaio server.
  * @param ArelObject $oObject Object to be sent out
  */
 public static function outputObject($oObject)
 {
     $object = new SimpleXMLExtended("<object></object>");
     $object->addAttribute('id', (string) $oObject->getID());
     if ($oObject->getTitle()) {
         $object->addCData('title', $oObject->getTitle());
     }
     if ($oObject->getThumbnail()) {
         $object->addCData('thumbnail', $oObject->getThumbnail());
     }
     if ($oObject->getIcon()) {
         $object->addCData('icon', $oObject->getIcon());
     }
     //location
     if ($oObject->getLocation()) {
         $location = $object->addChild("location");
         $oLocation = $oObject->getLocation();
         try {
             $location->addChild('lat', $oLocation[0]);
             $location->addChild('lon', $oLocation[1]);
             if (isset($oLocation[2])) {
                 $location->addChild('alt', $oLocation[2]);
             } else {
                 $location->addChild('alt', 0);
             }
         } catch (Exception $e) {
             return $e;
         }
     }
     //popup
     if ($oObject->getPopup()) {
         $popup = $object->addChild("popup");
         $oPopUp = $oObject->getPopup();
         if ($oPopUp->getDescription()) {
             $popup->addCData('description', $oPopUp->getDescription());
         }
         if ($oPopUp->getButtons()) {
             $buttons = $popup->addChild("buttons");
             $aButtons = $oPopUp->getButtons();
             foreach ($aButtons as $oButton) {
                 $button = $buttons->addCData("button", $oButton[2]);
                 $button->addAttribute("id", $oButton[1]);
                 $button->addAttribute("name", $oButton[0]);
             }
         }
     }
     if ($oObject instanceof ArelObjectModel3D) {
         //assets3D
         $assets3D = $object->addChild("assets3d");
         if ($oObject->getModel()) {
             $assets3D->addCData('model', $oObject->getModel());
         }
         if ($oObject->getMovie()) {
             $assets3D->addCData('movie', $oObject->getMovie());
         }
         if ($oObject->getTexture()) {
             $assets3D->addCData('texture', $oObject->getTexture());
         }
         //transform
         $transform = $assets3D->addChild("transform");
         $oTransform = $oObject->getTransformParent();
         if (isset($oTransform)) {
             $transform->addAttribute("parent", $oTransform);
         }
         try {
             //translation
             $translation = $transform->addChild("translation");
             $oTranslation = $oObject->getTranslation();
             $translation->addChild("x", $oTranslation[0]);
             $translation->addChild("y", $oTranslation[1]);
             $translation->addChild("z", $oTranslation[2]);
             //rotation
             $rotation = $transform->addChild("rotation");
             $oRotationElement = $oObject->getRotation();
             $oRotation = $oRotationElement->getRotationValues();
             $oRotationType = $oRotationElement->getRotationType();
             $rotation->addAttribute("type", $oRotationType);
             if ($oRotationType !== ArelRotation::ROTATION_MATRIX) {
                 $rotation->addChild("x", $oRotation[0]);
                 $rotation->addChild("y", $oRotation[1]);
                 $rotation->addChild("z", $oRotation[2]);
                 if ($oRotationType == ArelRotation::ROTATION_QUATERNION) {
                     $rotation->addChild("w", $oRotation[3]);
                 } else {
                     if ($oRotationType == ArelRotation::ROTATION_AXISANGLE) {
                         $rotation->addChild("angle", $oRotation[3]);
                     }
                 }
             } else {
                 $rotation->addChild("m0", $oRotation[0]);
                 $rotation->addChild("m1", $oRotation[1]);
                 $rotation->addChild("m2", $oRotation[2]);
                 $rotation->addChild("m3", $oRotation[3]);
                 $rotation->addChild("m4", $oRotation[4]);
                 $rotation->addChild("m5", $oRotation[5]);
                 $rotation->addChild("m6", $oRotation[6]);
                 $rotation->addChild("m7", $oRotation[7]);
                 $rotation->addChild("m8", $oRotation[8]);
             }
             //scale
             $scale = $transform->addChild("scale");
             $oScale = $oObject->getScale();
             $scale->addChild("x", $oScale[0]);
             $scale->addChild("y", $oScale[1]);
             $scale->addChild("z", $oScale[2]);
         } catch (Exception $e) {
             return $e;
         }
         //properties
         $pickingEnabled = $oObject->isPickingEnabled();
         $cosID = $oObject->getCoordinateSystemID();
         $shaderMaterial = $oObject->getShaderMaterial();
         $occluding = $oObject->isOccluding();
         $transparency = $oObject->getTransparency();
         $renderPosition = $oObject->getRenderOrderPosition();
         $screenAnchor = $oObject->getScreenAnchor();
         if (isset($cosID) || isset($shaderMaterial) || isset($occluding) || isset($pickingEnabled) || isset($screenAnchor) || isset($transparency) || isset($renderPosition)) {
             $properties = $assets3D->addChild("properties");
             if (isset($cosID)) {
                 $properties->addChild("coordinatesystemid", $cosID);
             }
             if (isset($shaderMaterial)) {
                 $properties->addChild("shadermaterial", $shaderMaterial);
             }
             if ($occluding) {
                 $properties->addChild("occluding", "true");
             }
             if (isset($transparency) && $transparency > 0) {
                 $properties->addChild("transparency", $oObject->getTransparency());
             }
             if (isset($pickingEnabled) && !$pickingEnabled) {
                 $properties->addChild("pickingenabled", "false");
             }
             if (isset($renderPosition)) {
                 $properties->addChild("renderorder", $oObject->getRenderOrderPosition());
             }
             if (isset($screenAnchor)) {
                 $screenAnchorProperty = $properties->addChild("screenanchor", $oObject->getScreenAnchor());
                 if ($oObject->getScreenAnchorFlag() != NULL) {
                     $screenAnchorProperty->addAttribute("flags", $oObject->getScreenAnchorFlag(), null);
                 }
             }
         }
     }
     //viewparameters
     if ($oObject->getVisibility() || $oObject->getMinAccuracy() || $oObject->getMinDistance() || $oObject->getMaxDistance()) {
         $viewparameter = $object->addChild("viewparameters");
         if ($oObject->getVisibility()) {
             $visibility = $viewparameter->addChild("visibility");
             $oVisibility = $oObject->getVisibility();
             if (isset($oVisibility["liveview"]) && !$oVisibility["liveview"]) {
                 $visibility->addChild("liveview", "false");
             }
             if (isset($oVisibility["maplist"]) && !$oVisibility["maplist"]) {
                 $visibility->addChild("maplist", "false");
             }
             if (isset($oVisibility["radar"]) && !$oVisibility["radar"]) {
                 $visibility->addChild("radar", "false");
             }
             //alternatively for 0,1,2
             if (isset($oVisibility[0]) && !$oVisibility[0]) {
                 $visibility->addChild("liveview", "false");
             }
             if (isset($oVisibility[1]) && !$oVisibility[1]) {
                 $visibility->addChild("maplist", "false");
             }
             if (isset($oVisibility[2]) && !$oVisibility[2]) {
                 $visibility->addChild("radar", "false");
             }
         }
         if ($oObject->getMinAccuracy()) {
             $viewparameter->addChild("minaccuracy", $oObject->getMinAccuracy());
         }
         if ($oObject->getMinDistance()) {
             $viewparameter->addChild("mindistance", $oObject->getMinDistance());
         }
         if ($oObject->getMaxDistance()) {
             $viewparameter->addChild("maxdistance", $oObject->getMaxDistance());
         }
     }
     //parameters
     if ($oObject->getParameters()) {
         $parameters = $object->addChild("parameters");
         foreach ($oObject->getParameters() as $key => $parValue) {
             $parameter = $parameters->addCData("parameter", $parValue);
             $parameter->addAttribute("key", $key);
         }
     }
     $out = $object->asXML();
     $pos = strpos($out, "?>");
     echo utf8_encode(trim(substr($out, $pos + 2)));
     ob_flush();
 }
 public function __construct($id)
 {
     parent::__construct($id);
 }