Ejemplo n.º 1
0
        private void LoadRig(RigData data)
        {
            GameObject obj = rootTransform.Find(data.ObjectName).gameObject;

            if (null != obj)
            {
                GameObject rendererObj = obj.transform.Find(data.meshPath).gameObject;
                if (null != rendererObj)
                {
                    if (rendererObj.TryGetComponent <SkinnedMeshRenderer>(out SkinnedMeshRenderer renderer))
                    {
                        RigController controller = obj.AddComponent <RigController>();
                        controller.SkinMesh   = renderer;
                        controller.RootObject = renderer.rootBone;

                        obj.tag = "PhysicObject";
                        BoxCollider objectCollider = obj.AddComponent <BoxCollider>();
                        objectCollider.center        = renderer.bounds.center;
                        objectCollider.size          = renderer.bounds.size;
                        renderer.updateWhenOffscreen = true;
                        controller.Collider          = objectCollider;

                        GlobalState.GeometryImporter.GenerateImportSkeleton(controller.RootObject, controller);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void FromBytes(byte[] buffer, ref int index)
        {
            for (int i = 0; i < 6; i++)
            {
                if (buffer[i] != headerBuffer[i])
                {
                    throw new Exception("Invalid VRtist file Header");
                }
            }
            index += 6;

            fileVersion = Converter.GetInt(buffer, ref index);
            if (fileVersion > version)
            {
                throw new Exception("File version mismatch, please update VRtist");
            }


            int objectsCount = Converter.GetInt(buffer, ref index);

            for (int i = 0; i < objectsCount; i++)
            {
                ObjectData data = new ObjectData();
                data.FromBytes(buffer, ref index);
                objects.Add(data);
            }

            int lightsCount = Converter.GetInt(buffer, ref index);

            for (int i = 0; i < lightsCount; i++)
            {
                LightData data = new LightData();
                data.FromBytes(buffer, ref index);
                lights.Add(data);
            }

            int camerasCount = Converter.GetInt(buffer, ref index);

            for (int i = 0; i < camerasCount; i++)
            {
                CameraData data = new CameraData();
                data.FromBytes(buffer, ref index);
                cameras.Add(data);
            }

            skyData = new SkySettings
            {
                topColor    = Converter.GetColor(buffer, ref index),
                middleColor = Converter.GetColor(buffer, ref index),
                bottomColor = Converter.GetColor(buffer, ref index)
            };

            int animationsCount = Converter.GetInt(buffer, ref index);

            for (int i = 0; i < animationsCount; i++)
            {
                AnimationData data = new AnimationData();
                data.FromBytes(buffer, ref index);
                animations.Add(data);
            }

            int rigCount = Converter.GetInt(buffer, ref index);

            for (int i = 0; i < rigCount; i++)
            {
                RigData data = new RigData();
                data.FromBytes(buffer, ref index);
                rigs.Add(data);
            }

            fps          = Converter.GetFloat(buffer, ref index);
            startFrame   = Converter.GetInt(buffer, ref index);
            endFrame     = Converter.GetInt(buffer, ref index);
            currentFrame = Converter.GetInt(buffer, ref index);

            int constraintsCount = Converter.GetInt(buffer, ref index);

            for (int i = 0; i < constraintsCount; i++)
            {
                ConstraintData data = new ConstraintData();
                data.FromBytes(buffer, ref index);
                constraints.Add(data);
            }

            int shotsCount = Converter.GetInt(buffer, ref index);

            for (int i = 0; i < shotsCount; i++)
            {
                ShotData data = new ShotData();
                data.FromBytes(buffer, ref index);
                shots.Add(data);
            }

            playerData = new PlayerData();
            playerData.FromBytes(buffer, ref index);
        }