Exemplo n.º 1
0
        private void getMaterialsByteArray()
        {
            materialsByteData = new byte[0];

            foreach (MaterialPackage matPack in materialList)
            {
                byte[] matByteData = new byte[SceneDataHandler.size_int + SceneDataHandler.size_int + matPack.name.Length + SceneDataHandler.size_int + matPack.src.Length];
                int    dstIdx      = 0;

                // type
                Buffer.BlockCopy(BitConverter.GetBytes(matPack.type), 0, matByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                // name length
                Buffer.BlockCopy(BitConverter.GetBytes(matPack.name.Length), 0, matByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                // name
                byte[] nameByte = Encoding.ASCII.GetBytes(matPack.name);
                Buffer.BlockCopy(nameByte, 0, matByteData, dstIdx, matPack.name.Length);
                dstIdx += matPack.name.Length;

                // src length
                Buffer.BlockCopy(BitConverter.GetBytes(matPack.src.Length), 0, matByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                // src
                nameByte = Encoding.ASCII.GetBytes(matPack.src);
                Buffer.BlockCopy(nameByte, 0, matByteData, dstIdx, matPack.src.Length);
                dstIdx += matPack.src.Length;

                // concate
                materialsByteData = SceneDataHandler.Concat <byte>(materialsByteData, matByteData);
            }
        }
Exemplo n.º 2
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>();
            textureList = new List <TexturePackage>();
#if TRUNK
            materialList = new List <MaterialPackage>();
#endif

            iterLocation(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 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.StructureToByteArray <VpetHeader>(vpetHeader);
            getNodesByteArray();
            getObjectsByteArray();
            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}: TexturesByteArray size: {1}", this.GetType(), texturesByteData.Length));
#if TRUNK
            Debug.Log(string.Format("{0}: MaterialsByteArray size: {1}", this.GetType(), materialsByteData.Length));
#endif
        }
Exemplo n.º 3
0
        private void getTexturesByteArray()
        {
            texturesByteData = BitConverter.GetBytes(textureBinaryType);

            foreach (TexturePackage texPack in textureList)
            {
                byte[] texByteData = new byte[4 * SceneDataHandler.size_int + texPack.colorMapDataSize];
                int    dstIdx      = 0;
                // width
                Buffer.BlockCopy(BitConverter.GetBytes(texPack.width), 0, texByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                // height
                Buffer.BlockCopy(BitConverter.GetBytes(texPack.height), 0, texByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                // format
                Buffer.BlockCopy(BitConverter.GetBytes((int)texPack.format), 0, texByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                // pixel data
                Buffer.BlockCopy(BitConverter.GetBytes(texPack.colorMapDataSize), 0, texByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                Buffer.BlockCopy(texPack.colorMapData, 0, texByteData, dstIdx, texPack.colorMapDataSize);
                dstIdx += texPack.colorMapDataSize;

                // concate
                texturesByteData = SceneDataHandler.Concat <byte>(texturesByteData, texByteData);
            }
        }
Exemplo n.º 4
0
        public static SceneNode ParseNode(NodeType nodeType, ref byte[] nodesByteData, ref int dataIdx)
        {
            switch (nodeType)
            {
            case NodeType.GROUP:
                SceneNode sceneNode = SceneDataHandler.ByteArrayToStructure <SceneNode>(nodesByteData, ref dataIdx);
                return(sceneNode);

                break;

            case NodeType.GEO:
                SceneNodeGeo sceneNodeGeo = SceneDataHandler.ByteArrayToStructure <SceneNodeGeo>(nodesByteData, ref dataIdx);
                return(sceneNodeGeo);

                break;

            case NodeType.LIGHT:
                SceneNodeLight sceneNodeLight = SceneDataHandler.ByteArrayToStructure <SceneNodeLight>(nodesByteData, ref dataIdx);
                return(sceneNodeLight);

                break;

            case NodeType.CAMERA:
                SceneNodeCam sceneNodeCamera = SceneDataHandler.ByteArrayToStructure <SceneNodeCam>(nodesByteData, ref dataIdx);
                return(sceneNodeCamera);

                break;
            }
            return(null);
        }
Exemplo n.º 5
0
 public static SceneNode ParseNode(NodeType nodeType, ref byte[] nodesByteData, ref int dataIdx)
 {
     if (nodeType == NodeType.MOCAP)
     {
         SceneNodeMocap sceneNodeMocap = SceneDataHandler.ByteArrayToStructure <SceneNodeMocap>(nodesByteData, ref dataIdx);
         return(sceneNodeMocap);
     }
     return(null);
 }
Exemplo n.º 6
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.StructureToByteArray <SceneNodeGeoV1100>(nodeGeoV1100);
                }
                else if (node.GetType() == typeof(SceneNodeLight))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.LIGHT);
                    SceneNodeLight nodeLight = (SceneNodeLight)Convert.ChangeType(node, typeof(SceneNodeLight));
                    nodeBinary = SceneDataHandler.StructureToByteArray <SceneNodeLight>(nodeLight);
                }
                else if (node.GetType() == typeof(SceneNodeCam))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.CAMERA);
                    SceneNodeCam nodeCam = (SceneNodeCam)Convert.ChangeType(node, typeof(SceneNodeCam));
                    nodeBinary = SceneDataHandler.StructureToByteArray <SceneNodeCam>(nodeCam);
                }
                else if (node.GetType() == typeof(SceneNodeMocap))
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.MOCAP);
                    SceneNodeMocap nodeMocap = (SceneNodeMocap)Convert.ChangeType(node, typeof(SceneNodeMocap));
                    nodeBinary = SceneDataHandler.StructureToByteArray <SceneNodeMocap>(nodeMocap);
                }
                else
                {
                    nodeTypeBinary = BitConverter.GetBytes((int)NodeType.GROUP);
                    nodeBinary     = SceneDataHandler.StructureToByteArray <SceneNode>(node);
                }
                // concate arrays
                nodesByteData = SceneDataHandler.Concat <byte>(nodesByteData, nodeTypeBinary);
                nodesByteData = SceneDataHandler.Concat <byte>(nodesByteData, nodeBinary);
            }

            return(nodesByteData);
        }
Exemplo n.º 7
0
        private void convertNodesByteStream()
        {
            m_nodeList = new List <SceneNode>();

            int dataIdx = 0;

            while (dataIdx < m_nodesByteData.Length - 1)
            {
                SceneNode node      = new SceneNode();
                int       numValues = BitConverter.ToInt32(m_nodesByteData, dataIdx);
                dataIdx += size_int;
                //checkEndian(ref sliceInt);
                NodeType nodeType = (NodeType)numValues;

                switch (nodeType)
                {
                case NodeType.GROUP:
                    SceneNode sceneNode = SceneDataHandler.ByteArrayToStructure <SceneNode>(m_nodesByteData, ref dataIdx);
                    node = sceneNode;
                    break;

                case NodeType.GEO:
                    SceneNodeGeo sceneNodeGeo = SceneDataHandler.ByteArrayToStructure <SceneNodeGeo>(m_nodesByteData, ref dataIdx);
                    node = sceneNodeGeo;
                    break;

                case NodeType.LIGHT:
                    SceneNodeLight sceneNodeLight = SceneDataHandler.ByteArrayToStructure <SceneNodeLight>(m_nodesByteData, ref dataIdx);
                    node = sceneNodeLight;
                    break;

                case NodeType.CAMERA:
                    SceneNodeCam sceneNodeCamera = SceneDataHandler.ByteArrayToStructure <SceneNodeCam>(m_nodesByteData, ref dataIdx);
                    node = sceneNodeCamera;
                    break;

                case NodeType.MOCAP:
                    SceneNodeMocap sceneNodeMocap = SceneDataHandler.ByteArrayToStructure <SceneNodeMocap>(m_nodesByteData, ref dataIdx);
                    node = sceneNodeMocap;
                    break;
                }

                m_nodeList.Add(node);
            }

            Array.Clear(m_nodesByteData, 0, m_nodesByteData.Length);
            m_nodesByteData = null;
            GC.Collect();
        }
Exemplo n.º 8
0
        private void getObjectsByteArray()
        {
            objectsByteData = new byte[0];

            foreach (ObjectPackage objPack in objectList)
            {
                byte[] objByteData = new byte[5 * SceneDataHandler.size_int +
                                              objPack.vSize * 3 * SceneDataHandler.size_float +
                                              objPack.iSize * SceneDataHandler.size_int +
                                              objPack.nSize * 3 * SceneDataHandler.size_float +
                                              objPack.uvSize * 2 * SceneDataHandler.size_float +
                                              objPack.bWSize * 4 * SceneDataHandler.size_float +
                                              objPack.bWSize * 4 * SceneDataHandler.size_int];
                int dstIdx = 0;
                // vertices
                Buffer.BlockCopy(BitConverter.GetBytes(objPack.vSize), 0, objByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                Buffer.BlockCopy(objPack.vertices, 0, objByteData, dstIdx, objPack.vSize * 3 * SceneDataHandler.size_float);
                dstIdx += objPack.vSize * 3 * SceneDataHandler.size_float;
                // indices
                Buffer.BlockCopy(BitConverter.GetBytes(objPack.iSize), 0, objByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                Buffer.BlockCopy(objPack.indices, 0, objByteData, dstIdx, objPack.iSize * SceneDataHandler.size_int);
                dstIdx += objPack.iSize * SceneDataHandler.size_int;
                // normals
                Buffer.BlockCopy(BitConverter.GetBytes(objPack.nSize), 0, objByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                Buffer.BlockCopy(objPack.normals, 0, objByteData, dstIdx, objPack.nSize * 3 * SceneDataHandler.size_float);
                dstIdx += objPack.nSize * 3 * SceneDataHandler.size_float;
                // uvs
                Buffer.BlockCopy(BitConverter.GetBytes(objPack.uvSize), 0, objByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                Buffer.BlockCopy(objPack.uvs, 0, objByteData, dstIdx, objPack.uvSize * 2 * SceneDataHandler.size_float);
                dstIdx += objPack.uvSize * 2 * SceneDataHandler.size_float;
                // bone weights
                Buffer.BlockCopy(BitConverter.GetBytes(objPack.bWSize), 0, objByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;
                Buffer.BlockCopy(objPack.boneWeights, 0, objByteData, dstIdx, objPack.bWSize * 4 * SceneDataHandler.size_float);
                dstIdx += objPack.bWSize * 4 * SceneDataHandler.size_float;
                // bone indices
                Buffer.BlockCopy(objPack.boneIndices, 0, objByteData, dstIdx, objPack.bWSize * 4 * SceneDataHandler.size_int);
                dstIdx += objPack.bWSize * 4 * SceneDataHandler.size_int;

                // concate
                objectsByteData = SceneDataHandler.Concat <byte>(objectsByteData, objByteData);
            }
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
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>();
            gameObjectList = new List <GameObject>();
#if TRUNK
            materialList = new List <MaterialPackage>();
#endif
            recursiveGameObjectIdExtract(sceneRoot.transform.GetChild(0));

            iterLocation(sceneRoot.transform);

            serverAdapter.sceneObjectRefList = new SceneObject[globalID];

            recursiveIdExtract(sceneRoot.transform.GetChild(0));

            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.StructureToByteArray(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
        }
Exemplo n.º 11
0
        public static SceneNode ParseNode(NodeType nodeType, ref byte[] nodesByteData, int dataIdx, int length)
        {
            switch (nodeType)
            {
            case NodeType.GROUP:
                SceneNode sceneNode = new SceneNode();
                SceneDataHandler.ByteArrayToStruct <SceneNode>(ref nodesByteData, out sceneNode, dataIdx, length);
                return(sceneNode);

                break;

            case NodeType.GEO:
                SceneNodeGeo sceneNodeGeo = new SceneNodeGeo();
                SceneDataHandler.ByteArrayToStruct <SceneNodeGeo>(ref nodesByteData, out sceneNodeGeo, dataIdx, length);
                return(sceneNodeGeo);

                break;

            case NodeType.SKINNEDMESH:
                SceneNodeSkinnedGeo sceneNodeSkinnedGeo = new SceneNodeSkinnedGeo();
                SceneDataHandler.ByteArrayToStruct <SceneNodeSkinnedGeo>(ref nodesByteData, out sceneNodeSkinnedGeo, dataIdx, length);
                return(sceneNodeSkinnedGeo);

                break;

            case NodeType.LIGHT:
                SceneNodeLight sceneNodeLight = new SceneNodeLight();
                SceneDataHandler.ByteArrayToStruct <SceneNodeLight>(ref nodesByteData, out sceneNodeLight, dataIdx, length);
                return(sceneNodeLight);

                break;

            case NodeType.CAMERA:
                SceneNodeCam sceneNodeCamera = new SceneNodeCam();
                SceneDataHandler.ByteArrayToStruct <SceneNodeCam>(ref nodesByteData, out sceneNodeCamera, dataIdx, length);
                return(sceneNodeCamera);

                break;
            }
            return(null);
        }
Exemplo n.º 12
0
 public static void RegisterNodeParser()
 {
     SceneDataHandler.RegisterDelegate(NodeParserBasic.ParseNode);
 }
Exemplo n.º 13
0
 void Awake()
 {
     sceneDataHandler = new SceneDataHandler();
 }
Exemplo n.º 14
0
 void Awake()
 {
     sceneDataHandler = new SceneDataHandler();
     sceneDataHandler.initializeLists();
 }
Exemplo n.º 15
0
        private void getCharacterByteArray()
        {
            charactersByteData = new byte[0];
            foreach (CharacterPackage chrPack in characterList)
            {
                byte[] characterByteData = new byte[SceneDataHandler.size_int * 3 +
                                                    chrPack.boneMapping.Length * SceneDataHandler.size_int +
                                                    chrPack.skeletonMapping.Length * SceneDataHandler.size_int +
                                                    chrPack.sSize * SceneDataHandler.size_float * 10];
                int dstIdx = 0;
                // bone mapping size
                Buffer.BlockCopy(BitConverter.GetBytes(chrPack.bMSize), 0, characterByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                // skeleton mapping size
                Buffer.BlockCopy(BitConverter.GetBytes(chrPack.sSize), 0, characterByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                // root dag id
                Buffer.BlockCopy(BitConverter.GetBytes(chrPack.rootId), 0, characterByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                Buffer.BlockCopy(chrPack.boneMapping, 0, characterByteData, dstIdx, chrPack.bMSize * SceneDataHandler.size_int);
                dstIdx += chrPack.bMSize * SceneDataHandler.size_int;
                //foreach (string dag in chrPack.boneMapping)
                //{
                //    if (dag != null)
                //    {
                //        byte[] dagByte = Encoding.ASCII.GetBytes(dag);
                //        Buffer.BlockCopy(dagByte, 0, characterByteData, dstIdx, dag.Length);
                //        dstIdx += dag.Length;
                //    }
                //}

                // skeleton Mapping
                Buffer.BlockCopy(chrPack.skeletonMapping, 0, characterByteData, dstIdx, chrPack.sSize * SceneDataHandler.size_int);
                dstIdx += chrPack.sSize * SceneDataHandler.size_int;
                //foreach (string sdag in chrPack.skeletonMapping)
                //{
                //    if (sdag != null)
                //    {
                //        byte[] sdagByte = Encoding.ASCII.GetBytes(sdag);
                //        Buffer.BlockCopy(sdagByte, 0, characterByteData, dstIdx, sdag.Length);
                //        dstIdx += sdag.Length;
                //    }
                //}

                //skelton bone positions
                Buffer.BlockCopy(chrPack.bonePosition, 0, characterByteData, dstIdx, chrPack.sSize * 3 * SceneDataHandler.size_float);
                dstIdx += chrPack.sSize * 3 * SceneDataHandler.size_float;

                //skelton bone rotations
                Buffer.BlockCopy(chrPack.boneRotation, 0, characterByteData, dstIdx, chrPack.sSize * 4 * SceneDataHandler.size_float);
                dstIdx += chrPack.sSize * 4 * SceneDataHandler.size_float;

                //skelton bone scales
                Buffer.BlockCopy(chrPack.boneScale, 0, characterByteData, dstIdx, chrPack.sSize * 3 * SceneDataHandler.size_float);
                dstIdx += chrPack.sSize * 3 * SceneDataHandler.size_float;

                // concate
                charactersByteData = SceneDataHandler.Concat <byte>(charactersByteData, characterByteData);
            }
        }
Exemplo n.º 16
0
        private void getCharacterByteArray()
        {
            charactersByteData = new byte[0];
            foreach (CharacterPackage chrPack in characterList)
            {
                int boneMappingLength = 0;
                foreach (int s in chrPack.dagSizes)
                {
                    boneMappingLength += s;
                }
                int skeletonMappingLength = 0;
                foreach (int s in chrPack.sdagSizes)
                {
                    skeletonMappingLength += s;
                }
                byte[] characterByteData = new byte[SceneDataHandler.size_int * 3 +
                                                    chrPack.rootDag.Length +
                                                    chrPack.dagSizes.Length * SceneDataHandler.size_int +
                                                    boneMappingLength +
                                                    chrPack.sdagSizes.Length * SceneDataHandler.size_int +
                                                    skeletonMappingLength +
                                                    chrPack.sdagSizes.Length * SceneDataHandler.size_float * 10];
                int dstIdx = 0;
                // bone mapping size
                Buffer.BlockCopy(BitConverter.GetBytes(chrPack.bMSize), 0, characterByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                // skeleton mapping size
                Buffer.BlockCopy(BitConverter.GetBytes(chrPack.sSize), 0, characterByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                // root dag size
                Buffer.BlockCopy(BitConverter.GetBytes(chrPack.rootDagSize), 0, characterByteData, dstIdx, SceneDataHandler.size_int);
                dstIdx += SceneDataHandler.size_int;

                // root dag path
                byte[] nameByte = Encoding.ASCII.GetBytes(chrPack.rootDag);
                Buffer.BlockCopy(nameByte, 0, characterByteData, dstIdx, chrPack.rootDag.Length);
                dstIdx += chrPack.rootDag.Length;

                // dag sizes
                Buffer.BlockCopy(chrPack.dagSizes, 0, characterByteData, dstIdx, chrPack.bMSize * SceneDataHandler.size_int);
                dstIdx += chrPack.bMSize * SceneDataHandler.size_int;

                // bone Mapping
                foreach (string dag in chrPack.boneMapping)
                {
                    if (dag != null)
                    {
                        byte[] dagByte = Encoding.ASCII.GetBytes(dag);
                        Buffer.BlockCopy(dagByte, 0, characterByteData, dstIdx, dag.Length);
                        dstIdx += dag.Length;
                    }
                }

                // dag sizes
                Buffer.BlockCopy(chrPack.sdagSizes, 0, characterByteData, dstIdx, chrPack.sSize * SceneDataHandler.size_int);
                dstIdx += chrPack.sSize * SceneDataHandler.size_int;

                // bone Mapping
                foreach (string sdag in chrPack.skeletonMapping)
                {
                    if (sdag != null)
                    {
                        byte[] sdagByte = Encoding.ASCII.GetBytes(sdag);
                        Buffer.BlockCopy(sdagByte, 0, characterByteData, dstIdx, sdag.Length);
                        dstIdx += sdag.Length;
                    }
                }

                //skelton bone positions
                Buffer.BlockCopy(chrPack.bonePosition, 0, characterByteData, dstIdx, chrPack.sdagSizes.Length * 3 * SceneDataHandler.size_float);
                dstIdx += chrPack.sdagSizes.Length * 3 * SceneDataHandler.size_float;

                //skelton bone rotations
                Buffer.BlockCopy(chrPack.boneRotation, 0, characterByteData, dstIdx, chrPack.sdagSizes.Length * 4 * SceneDataHandler.size_float);
                dstIdx += chrPack.sdagSizes.Length * 4 * SceneDataHandler.size_float;

                //skelton bone scales
                Buffer.BlockCopy(chrPack.boneScale, 0, characterByteData, dstIdx, chrPack.sdagSizes.Length * 3 * SceneDataHandler.size_float);
                dstIdx += chrPack.sdagSizes.Length * 3 * SceneDataHandler.size_float;

                // concate
                charactersByteData = SceneDataHandler.Concat <byte>(charactersByteData, characterByteData);
            }
        }