Esempio n. 1
0
        private void getNodesByteArray()
        {
            nodesByteData = new byte[0];
            foreach (SceneNode node in nodeList)
            {
                byte[] nodeBinary;
                byte[] nodeTypeBinary;
                byte[] nodeLengthBinary;
                if (node.GetType() == typeof(SceneNodeGeo))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.GEO);
                    SceneNodeGeo nodeGeo = (SceneNodeGeo)Convert.ChangeType(node, typeof(SceneNodeGeo));
                    nodeBinary = SceneDataHandler.StructToByteArray <SceneNodeGeo>(nodeGeo);
                }
                else if (node.GetType() == typeof(SceneNodeSkinnedGeo))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.SKINNEDMESH);
                    SceneNodeSkinnedGeo nodeGeo = (SceneNodeSkinnedGeo)Convert.ChangeType(node, typeof(SceneNodeSkinnedGeo));
                    nodeBinary = SceneDataHandler.StructToByteArray <SceneNodeSkinnedGeo>(nodeGeo);
                }
                else if (node.GetType() == typeof(SceneNodeLight))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.LIGHT);
                    SceneNodeLight nodeLight = (SceneNodeLight)Convert.ChangeType(node, typeof(SceneNodeLight));
                    nodeBinary = SceneDataHandler.StructToByteArray <SceneNodeLight>(nodeLight);
                }
                else if (node.GetType() == typeof(SceneNodeCam))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.CAMERA);
                    SceneNodeCam nodeCam = (SceneNodeCam)Convert.ChangeType(node, typeof(SceneNodeCam));
                    nodeBinary = SceneDataHandler.StructToByteArray <SceneNodeCam>(nodeCam);
                }
                else
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.GROUP);
                    nodeBinary     = SceneDataHandler.StructToByteArray <SceneNode>(node);
                }
                nodeLengthBinary = BitConverter.GetBytes(nodeBinary.Length);

                // concate arrays
                nodesByteData = SceneDataHandler.Concat <byte>(nodesByteData, nodeLengthBinary);
                nodesByteData = SceneDataHandler.Concat <byte>(nodesByteData, nodeTypeBinary);
                nodesByteData = SceneDataHandler.Concat <byte>(nodesByteData, nodeBinary);
            }
        }
Esempio n. 2
0
        private byte[] getNodesByteArrayV1100()
        {
            Byte[] nodesByteData = new byte[0];

            foreach (SceneNode node in sceneDataHandler.NodeList)
            {
                byte[] nodeBinary;
                byte[] nodeTypeBinary;
                if (node.GetType() == typeof(SceneNodeGeo))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.GEO);

                    SceneNodeGeo nodeGeo = (SceneNodeGeo)Convert.ChangeType(node, typeof(SceneNodeGeo));

                    // change to V1100 geo node
                    SceneNodeGeoV1100 nodeGeoV1100 = new SceneNodeGeoV1100();
                    copyProperties(nodeGeo, nodeGeoV1100);
                    nodeGeoV1100.materialId = -1;
                    //PrintProperties(nodeGeoV1100);
                    nodeBinary = SceneDataHandler.StructToByteArray <SceneNodeGeoV1100>(nodeGeoV1100);
                }
                else if (node.GetType() == typeof(SceneNodeLight))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.LIGHT);
                    SceneNodeLight nodeLight = (SceneNodeLight)Convert.ChangeType(node, typeof(SceneNodeLight));
                    nodeBinary = SceneDataHandler.StructToByteArray <SceneNodeLight>(nodeLight);
                }
                else if (node.GetType() == typeof(SceneNodeCam))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.CAMERA);
                    SceneNodeCam nodeCam = (SceneNodeCam)Convert.ChangeType(node, typeof(SceneNodeCam));
                    nodeBinary = SceneDataHandler.StructToByteArray <SceneNodeCam>(nodeCam);
                }
                else
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.GROUP);
                    nodeBinary     = SceneDataHandler.StructToByteArray <SceneNode>(node);
                }
                // concate arrays
                nodesByteData = SceneDataHandler.Concat <byte>(nodesByteData, nodeTypeBinary);
                nodesByteData = SceneDataHandler.Concat <byte>(nodesByteData, nodeBinary);
            }

            return(nodesByteData);
        }
Esempio n. 3
0
        /*
         * private bool hasLodLowChild( Transform t )
         * {
         *  if (t.gameObject.layer == lodLowLayer)
         *      return true;
         *
         *  foreach( Transform c in t )
         *  {
         *      if ( hasLodLowChild(c) )
         *      {
         *          return true;
         *      }
         *  }
         *
         *  return false;
         * }
         */

        private void gatherSceneData()
        {
            nodeList      = new List <SceneNode>();
            objectList    = new List <ObjectPackage>();
            characterList = new List <CharacterPackage>();
            textureList   = new List <TexturePackage>();
#if TRUNK
            materialList = new List <MaterialPackage>();
#endif

            iterLocation(sceneRoot.transform);

            serverAdapter.sceneObjectRefList = new SceneObject[globalID];

            recursiveIdExtract(sceneRoot.transform);

            Debug.Log(string.Format("{0}: Collected number nodes: {1}", this.GetType(), nodeList.Count));
            Debug.Log(string.Format("{0}: Collected number objects: {1}", this.GetType(), objectList.Count));
            Debug.Log(string.Format("{0}: Collected number skinned charcaters: {1}", this.GetType(), characterList.Count));
            Debug.Log(string.Format("{0}: Collected number textures: {1}", this.GetType(), textureList.Count));
#if TRUNK
            Debug.Log(string.Format("{0}: Collected number materials: {1}", this.GetType(), materialList.Count));
#endif
            // create byte arrays
            headerByteData = SceneDataHandler.StructToByteArray <VpetHeader>(vpetHeader);
            getNodesByteArray();
            getObjectsByteArray();
            getCharacterByteArray();
            getTexturesByteArray();
#if TRUNK
            getMaterialsByteArray();
#endif
            Debug.Log(string.Format("{0}: HeaderByteArray size: {1}", this.GetType(), headerByteData.Length));
            Debug.Log(string.Format("{0}: NodeByteArray size: {1}", this.GetType(), nodesByteData.Length));
            Debug.Log(string.Format("{0}: ObjectsByteArray size: {1}", this.GetType(), objectsByteData.Length));
            Debug.Log(string.Format("{0}: CharacterByteArray size: {1}", this.GetType(), charactersByteData.Length));
            Debug.Log(string.Format("{0}: TexturesByteArray size: {1}", this.GetType(), texturesByteData.Length));
#if TRUNK
            Debug.Log(string.Format("{0}: MaterialsByteArray size: {1}", this.GetType(), materialsByteData.Length));
#endif
        }