internal TilePlacementData(PreProcessTileData preProcessData, bool isOnMainPath, DungeonArchetype archetype, TileSet tileSet, Dungeon dungeon)
        {
            root = (GameObject)GameObject.Instantiate(preProcessData.Prefab);

            Bounds       = preProcessData.Proxy.GetComponent <Collider>().bounds;
            IsOnMainPath = isOnMainPath;

            tile = Root.GetComponent <Tile>();

            if (tile == null)
            {
                tile = Root.AddComponent <Tile>();
            }

            tile.Placement = this;
            tile.Archetype = archetype;
            tile.TileSet   = tileSet;
            tile.Dungeon   = dungeon;

            foreach (var doorway in Root.GetComponentsInChildren <Doorway>(true))
            {
                doorway.Dungeon = dungeon;
                doorway.Tile    = tile;
                AllDoorways.Add(doorway);
            }

            UnusedDoorways.AddRange(AllDoorways);
            root.SetActive(false);
        }
예제 #2
0
        private void LoadHumanoid()
        {
            AvatarDescription      = VRM.humanoid.ToDescription(Nodes);
            AvatarDescription.name = "AvatarDescription";
            HumanoidAvatar         = AvatarDescription.CreateAvatar(Root.transform);
            if (!HumanoidAvatar.isValid || !HumanoidAvatar.isHuman)
            {
                throw new Exception("fail to create avatar");
            }

            HumanoidAvatar.name = "VrmAvatar";

            var humanoid = Root.AddComponent <VRMHumanoidDescription>();

            humanoid.Avatar      = HumanoidAvatar;
            humanoid.Description = AvatarDescription;

            var animator = Root.GetComponent <Animator>();

            if (animator == null)
            {
                animator = Root.AddComponent <Animator>();
            }
            animator.avatar = HumanoidAvatar;

            // default としてとりあえず設定する
            // https://docs.unity3d.com/ScriptReference/Renderer-probeAnchor.html
            var head = animator.GetBoneTransform(HumanBodyBones.Head);

            foreach (var smr in animator.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                smr.probeAnchor = head;
            }
        }
예제 #3
0
파일: VCIImporter.cs 프로젝트: notargs/VCI
        public void SetupSpringBone()
        {
            if (GLTF.extensions.VCAST_vci_spring_bone == null)
            {
                return;
            }

            foreach (var bone in GLTF.extensions.VCAST_vci_spring_bone.springBones)
            {
                var sb = Root.AddComponent <VCISpringBone>();
                if (bone.center >= 0)
                {
                    sb.m_center = Nodes[bone.center];
                }
                sb.m_dragForce      = bone.dragForce;
                sb.m_gravityDir     = bone.gravityDir;
                sb.m_gravityPower   = bone.gravityPower;
                sb.m_hitRadius      = bone.hitRadius;
                sb.m_stiffnessForce = bone.stiffiness;
                if (bone.colliderIds != null && bone.colliderIds.Any())
                {
                    sb.m_colliderObjects = bone.colliderIds.Select(id => Nodes[id]).ToList();
                }
                sb.RootBones = bone.bones.Select(x => Nodes[x]).ToList();
            }
        }
예제 #4
0
        void LoadBlendShapeMaster()
        {
            BlendShapeAvatar      = ScriptableObject.CreateInstance <BlendShapeAvatar>();
            BlendShapeAvatar.name = "BlendShape";

            var transformMeshTable = new Dictionary <Mesh, Transform>();

            foreach (var transform in Root.transform.Traverse())
            {
                if (transform.GetSharedMesh() != null)
                {
                    transformMeshTable.Add(transform.GetSharedMesh(), transform);
                }
            }

            var blendShapeList = GLTF.extensions.VRM.blendShapeMaster.blendShapeGroups;

            if (blendShapeList != null && blendShapeList.Count > 0)
            {
                foreach (var x in blendShapeList)
                {
                    BlendShapeAvatar.Clips.Add(LoadBlendShapeBind(x, transformMeshTable));
                }
            }

            var proxy = Root.AddComponent <VRMBlendShapeProxy>();

            BlendShapeAvatar.CreateDefaultPreset();
            proxy.BlendShapeAvatar = BlendShapeAvatar;
        }
예제 #5
0
        protected override async Task OnLoadHierarchy(IAwaitCaller awaitCaller, Func <string, IDisposable> MeasureTime)
        {
            Root.name = "VRM1";

            // humanoid
            var humanoid = Root.AddComponent <UniHumanoid.Humanoid>();

            humanoid.AssignBones(m_map.Nodes.Select(x => (ToUnity(x.Key.HumanoidBone.GetValueOrDefault()), x.Value.transform)));
            m_humanoid      = humanoid.CreateAvatar();
            m_humanoid.name = "humanoid";
            var animator = Root.AddComponent <Animator>();

            animator.avatar = m_humanoid;

            // VrmController
            var controller = Root.AddComponent <VRM10Controller>();

            // vrm
            controller.Vrm = await LoadVrmAsync(awaitCaller, m_vrm);

            // springBone
            if (UniGLTF.Extensions.VRMC_springBone.GltfDeserializer.TryGet(Data.GLTF.extensions, out UniGLTF.Extensions.VRMC_springBone.VRMC_springBone springBone))
            {
                await LoadSpringBoneAsync(awaitCaller, controller, springBone);
            }
            // constraint
            await LoadConstraintAsync(awaitCaller, controller);
        }
예제 #6
0
        public void PhysicsShapeConversionSystem_WhenBodyHasMultipleSiblingShapes_CreatesCompound(int shapeCount)
        {
            CreateHierarchy(
                new[] { typeof(ConvertToEntity), typeof(PhysicsBody) },
                new[] { typeof(ConvertToEntity) },
                new[] { typeof(ConvertToEntity) }
                );
            for (int i = 0; i < shapeCount; ++i)
            {
                Root.AddComponent <PhysicsShape>().SetBox(float3.zero, new float3(1, 1, 1), quaternion.identity);
            }

            var world = new World("Test world");

            GameObjectConversionUtility.ConvertGameObjectHierarchy(Root, world);
            using (var group = world.EntityManager.CreateComponentGroup(typeof(PhysicsCollider)))
            {
                using (var colliders = group.ToComponentDataArray <PhysicsCollider>(Allocator.Persistent))
                {
                    Assume.That(colliders, Has.Length.EqualTo(1));
                    var collider = colliders[0].Value;

                    Assert.That(collider.Value.Type, Is.EqualTo(ColliderType.Compound));
                    unsafe
                    {
                        var compoundCollider = (CompoundCollider *)(collider.GetUnsafePtr());
                        Assert.That(compoundCollider->Children, Has.Length.EqualTo(shapeCount));
                        for (int i = 0; i < compoundCollider->Children.Length; i++)
                        {
                            Assert.That(compoundCollider->Children[i].Collider->Type, Is.EqualTo(ColliderType.Box));
                        }
                    }
                }
            }
        }
예제 #7
0
        private void LoadHumanoid()
        {
            AvatarDescription      = GLTF.extensions.VRM.humanoid.ToDescription(Nodes);
            AvatarDescription.name = "AvatarDescription";
            HumanoidAvatar         = AvatarDescription.CreateAvatar(Root.transform);
            if (!HumanoidAvatar.isValid || !HumanoidAvatar.isHuman)
            {
                throw new Exception("fail to create avatar");
            }

            HumanoidAvatar.name = "VrmAvatar";

            var humanoid = Root.AddComponent <VRMHumanoidDescription>();

            humanoid.Avatar      = HumanoidAvatar;
            humanoid.Description = AvatarDescription;

            var animator = Root.GetComponent <Animator>();

            if (animator == null)
            {
                animator = Root.AddComponent <Animator>();
            }
            animator.avatar = HumanoidAvatar;
        }
예제 #8
0
        void LoadMeta()
        {
            var meta  = ReadMeta();
            var _meta = Root.AddComponent <VRMMeta>();

            _meta.Meta = meta;
            Meta       = meta;
        }
예제 #9
0
 /// <summary>
 /// Initialise the shape handler by initialising the shape scene root and
 /// fetching the default materials.
 /// </summary>
 /// <param name="root">The 3rd Eye Scene root object.</param>
 /// <param name="serverRoot">The server scene root (transformed into the server reference frame).</param>
 /// <param name="materials">Material library from which to resolve materials.</param>
 public override void Initialise(GameObject root, GameObject serverRoot, MaterialLibrary materials)
 {
     // Keep in Unity frame.
     Root.transform.SetParent(root.transform, false);
     if (Root.GetComponent <ScreenFacing>() == null)
     {
         Root.AddComponent <ScreenFacing>();
     }
 }
예제 #10
0
        async Task LoadMetaAsync()
        {
            var meta = await ReadMetaAsync();

            var _meta = Root.AddComponent <VRMMeta>();

            _meta.Meta = meta;
            Meta       = meta;
        }
예제 #11
0
파일: VgoImporter.cs 프로젝트: bmjoy/VGO
 /// <summary>
 /// Set up the root GameObject components.
 /// </summary>
 protected virtual void SetupRootComponent()
 {
     if (GLTF.extensions != null)
     {
         if (GLTF.extensions.VGO != null)
         {
             Root.AddComponent <VgoMeta>(GLTF.extensions.VGO.meta);
             Root.AddComponent <VgoRight>(GLTF.extensions.VGO.right);
         }
     }
 }
예제 #12
0
파일: VCIImporter.cs 프로젝트: notargs/VCI
        public void SetupLocationBounds()
        {
            if (GLTF.extensions.VCAST_vci_location_bounds == null)
            {
                return;
            }

            var locationBounds = Root.AddComponent <VCILocationBounds>();
            var values         = GLTF.extensions.VCAST_vci_location_bounds.LocationBounds;

            locationBounds.Bounds = new Bounds(values.bounds_center, values.bounds_size);
        }
예제 #13
0
        public void OnAwake()
        {
            LevelSystem.LoadingComplete += OnLevelLoadingComplete;

            var camera = Root.AddComponent <Camera>();

            Camera.Current = camera;

            Mouse.ShowCursor();

            Env.Console.ExecuteString("map gridtest");
        }
예제 #14
0
        async Task LoadMetaAsync(IAwaitCaller awaitCaller)
        {
            if (awaitCaller == null)
            {
                throw new ArgumentNullException();
            }
            var meta = await ReadMetaAsync(awaitCaller);

            var _meta = Root.AddComponent <VRMMeta>();

            _meta.Meta = meta;
            Meta       = meta;
        }
예제 #15
0
        void LoadBlendShapeMaster()
        {
            BlendShapeAvatar      = ScriptableObject.CreateInstance <BlendShapeAvatar>();
            BlendShapeAvatar.name = "BlendShape";

            var blendShapeList = GLTF.extensions.VRM.blendShapeMaster.blendShapeGroups;

            if (blendShapeList != null && blendShapeList.Count > 0)
            {
                foreach (var x in blendShapeList)
                {
                    BlendShapeAvatar.Clips.Add(LoadBlendShapeBind(x));
                }
            }

            var proxy = Root.AddComponent <VRMBlendShapeProxy>();

            BlendShapeAvatar.CreateDefaultPreset();
            proxy.BlendShapeAvatar = BlendShapeAvatar;
        }
예제 #16
0
        void LoadMeta()
        {
            var meta = ReadMeta();

            if (meta.Thumbnail == null)
            {
                /*
                 * // 作る
                 * var lookAt = Root.GetComponent<VRMLookAtHead>();
                 * var thumbnail = lookAt.CreateThumbnail();
                 * thumbnail.name = "thumbnail";
                 * meta.Thumbnail = thumbnail;
                 * Textures.Add(new TextureItem(thumbnail));
                 */
            }
            var _meta = Root.AddComponent <VRMMeta>();

            _meta.Meta = meta;
            Meta       = meta;
        }
예제 #17
0
        public virtual void OnAwake()
        {
            // Initialize highscore functionality.
            _gameData = new GameData();

            // _Cry3DEngine_cs_SWIGTYPE_p_ITimeOfDay.SetTime won't work - therefore use console to set time to 7 am.
            Env.Console.ExecuteString("e_TimeOfDay 24");

            // We are in space, so use (almost) zero gravity (zero gravity would disable physics)
            Env.Console.ExecuteString("p_gravity_z 0.001");

            // Hook on to Key input.
            Input.OnKey += Input_OnKey;

            Camera.Current = Root.AddComponent <Camera>();
            Camera.Current.OnPlayerEntityAssigned += c => UI.MainMenu.SetupMainMenuPerspective();

            _totalGameTime = 0;
            State          = GameState.Finished;
        }
        public bool Open(object[] args)
        {
            if (!Root)
            {
                Debugger.LogError("Open window " + Settings.WinName + " fail!!");
                return(false);
            }

            _canvas.sortingOrder = orderIndex++;
            //bool waiteOpen = false;
            Show();
            if (!_onopeninit)
            {
                Param = args;
                OnOpen(args);
                _onopeninit = true;
                //waiteOpen = true;
                //if (GuideManager.Instance.IsGuiding && !_configData.openEffect)
                //    TimerManager.Instance.AddFarmeTimer(2, WaiteOpen);
            }
            if (Settings.OpenAnim)
            {
                Animation anim = Root.GetComponent <Animation>();
                if (anim == null)
                {
                    anim = Root.AddComponent <Animation>();
                    //anim.AddClip(Common.ResourceManager.Load<AnimationClip>("UI/winopen1.anim"), "winopen1");
                }
                else
                {
                }
                anim.Play("winopen1");
                //if (GuideManager.Instance.IsGuiding && waiteOpen)
                //    TimerManager.Instance.AddTimer(anim.GetClip("winopen1").length /*+ .1f*/, WaiteOpen);
            }
            //TimerManager.Instance.DelTimer(TweenFinish);
            //GL.Clear(false, true, Color.black);
            return(true);
        }
예제 #19
0
        /// <summary>
        /// AnimationClips を AnimationComponent に載せる
        /// </summary>
        protected virtual async Task SetupAnimationsAsync(IAwaitCaller awaitCaller)
        {
            if (AnimationClipFactory.LoadedClipKeys.Count == 0)
            {
                return;
            }

            var animation = Root.AddComponent <Animation>();

            for (var clipIdx = 0; clipIdx < AnimationClipFactory.LoadedClipKeys.Count; ++clipIdx)
            {
                var key  = AnimationClipFactory.LoadedClipKeys[clipIdx];
                var clip = AnimationClipFactory.GetAnimationClip(key);
                animation.AddClip(clip, key.Name);

                if (clipIdx == 0)
                {
                    animation.clip = clip;
                }
            }
            await awaitCaller.NextFrame();
        }
예제 #20
0
        private void InitializeAvatar()
        {
            Root.transform.position = new Vector3(Head.transform.position.x, 0f, Head.transform.position.z);

            var vrIK = Root.AddComponent <VRIK>();

            vrIK.AutoDetectReferences();

            vrIK.solver.rightArm.stretchCurve = new AnimationCurve();
            vrIK.solver.leftArm.stretchCurve  = new AnimationCurve();
            vrIK.solver.spine.headTarget      = Head.transform;
            vrIK.solver.rightArm.target       = RightHand.transform;
            vrIK.solver.leftArm.target        = LeftHand.transform;

            vrIK.solver.rightLeg.swivelOffset     = -15;
            vrIK.solver.leftLeg.swivelOffset      = 15;
            vrIK.solver.locomotion.footDistance   = 0.15f;
            vrIK.solver.locomotion.stepThreshold  = 0.4f;
            vrIK.solver.locomotion.maxVelocity    = 0.3f;
            vrIK.solver.locomotion.velocityFactor = 0.3f;
            vrIK.solver.locomotion.rootSpeed      = 30;
        }
 public bool Close()
 {
     if (!Root)
     {
         Debugger.LogError("Close window " + Settings.WinName + " fail!!");
         return(false);
     }
     _onopeninit = false;
     //TimerManager.Instance.DelTimer(WaiteOpen);
     if (!Settings.OpenAnim)
     {
         OnClose();
         //if (GuideManager.Instance.IsGuiding)
         //    ClientMsgDispatcher.Instance.Dispatch(MsgHandle.MH_Guide, MsgAction.MA_GuideTrigger, GuideTriggerType.GTT_CloseWindow, _configData.winName);
         Hide();
         if (Settings.CloseDelete)
         {
             GameObject.DestroyImmediate(Root);
         }
     }
     else
     {
         Animation anim = Root.GetComponent <Animation>();
         if (anim == null)
         {
             anim = Root.AddComponent <Animation>();
             //anim.AddClip(Common.ResourceManager.Load<AnimationClip>("UI/winclose.anim"), "winclose");
         }
         else
         {
             //anim.AddClip(Common.ResourceManager.Load<AnimationClip>("UI/winclose.anim"), "winclose");
         }
         //anim.Play("winclose");
         //TimerManager.Instance.AddTimer(anim.GetClip("winclose").length /*+ .1f*/, TweenFinish);
     }
     //GL.Clear(false, true, Color.black);
     return(true);
 }
예제 #22
0
        void LoadFirstPerson()
        {
            var firstPerson = Root.AddComponent <VRMFirstPerson>();

            var gltfFirstPerson = GLTF.extensions.VRM.firstPerson;

            if (gltfFirstPerson.firstPersonBone != -1)
            {
                firstPerson.FirstPersonBone   = Nodes[gltfFirstPerson.firstPersonBone];
                firstPerson.FirstPersonOffset = gltfFirstPerson.firstPersonBoneOffset;
            }
            else
            {
                // fallback
                firstPerson.SetDefault();
            }
            firstPerson.TraverseRenderers(this);

            // LookAt
            var lookAtHead = Root.AddComponent <VRMLookAtHead>();

            lookAtHead.OnImported(this);
        }
예제 #23
0
        public IEnumerator SetupCorutine()
        {
            VCIObject = Root.AddComponent <VCIObject>();
            yield return(ToUnity(meta => VCIObject.Meta = meta));

            // Script
            if (GLTF.extensions.VCAST_vci_embedded_script != null)
            {
                VCIObject.Scripts.AddRange(GLTF.extensions.VCAST_vci_embedded_script.scripts.Select(x =>
                {
                    var source = "";
                    try
                    {
                        var bytes = GLTF.GetViewBytes(x.source);
                        source    = Utf8String.Encoding.GetString(bytes.Array, bytes.Offset, bytes.Count);
                    }
                    catch (Exception)
                    {
                        // 握りつぶし
                    }

                    return(new VCIObject.Script
                    {
                        name = x.name,
                        mimeType = x.mimeType,
                        targetEngine = x.targetEngine,
                        source = source
                    });
                }));
            }

            // Audio
            if (GLTF.extensions.VCAST_vci_audios != null &&
                GLTF.extensions.VCAST_vci_audios.audios != null)
            {
                var root = Root;
                foreach (var audio in GLTF.extensions.VCAST_vci_audios.audios)
                {
#if ((NET_4_6 || NET_STANDARD_2_0) && UNITY_2017_1_OR_NEWER)
                    if (Application.isPlaying)
                    {
                        var bytes = GLTF.GetViewBytes(audio.bufferView);
                        WaveUtil.WaveHeaderData waveHeader;
                        var audioBuffer = new byte[bytes.Count];
                        Buffer.BlockCopy(bytes.Array, bytes.Offset, audioBuffer, 0, audioBuffer.Length);
                        if (WaveUtil.TryReadHeader(audioBuffer, out waveHeader))
                        {
                            AudioClip audioClip = null;
                            yield return(AudioClipMaker.Create(
                                             audio.name,
                                             audioBuffer,
                                             44,
                                             waveHeader.BitPerSample,
                                             waveHeader.DataChunkSize / waveHeader.BlockSize,
                                             waveHeader.Channel,
                                             waveHeader.SampleRate,
                                             false,
                                             (clip) => { audioClip = clip; }));

                            if (audioClip != null)
                            {
                                var source = root.AddComponent <AudioSource>();
                                source.clip        = audioClip;
                                source.playOnAwake = false;
                                source.loop        = false;
                            }
                        }
                    }
                    else
#endif
                    {
#if UNITY_EDITOR
                        var audioClip =
                            AssetDatabase.LoadAssetAtPath(AudioAssetPathList[audio.name], typeof(AudioClip)) as
                            AudioClip;
                        if (audioClip != null)
                        {
                            var source = root.AddComponent <AudioSource>();
                            source.clip = audioClip;
                        }
                        else
                        {
                            Debug.LogWarning("AudioFile NotFound: " + audio.name);
                        }
#endif
                    }
                }
            }


            // Animation
            var animation = Root.GetComponent <Animation>();
            if (animation != null)
            {
                animation.playAutomatically = false;
            }

            for (var i = 0; i < GLTF.nodes.Count; i++)
            {
                var node = GLTF.nodes[i];
                var go   = Nodes[i].gameObject;
                if (node.extensions != null)
                {
                    if (node.extensions.VCAST_vci_item != null)
                    {
                        var item = go.AddComponent <VCISubItem>();
                        item.Grabbable      = node.extensions.VCAST_vci_item.grabbable;
                        item.Scalable       = node.extensions.VCAST_vci_item.scalable;
                        item.UniformScaling = node.extensions.VCAST_vci_item.uniformScaling;
                        item.GroupId        = node.extensions.VCAST_vci_item.groupId;
                    }
                }
            }
        }
예제 #24
0
파일: VCIImporter.cs 프로젝트: notargs/VCI
        public IEnumerator SetupCoroutine()
        {
            VCIObject = Root.AddComponent <VCIObject>();
            yield return(ToUnity(meta => VCIObject.Meta = meta));

            // Script
            if (GLTF.extensions.VCAST_vci_embedded_script != null)
            {
                VCIObject.Scripts.AddRange(GLTF.extensions.VCAST_vci_embedded_script.scripts.Select(x =>
                {
                    var source = "";
                    try
                    {
                        var bytes = GLTF.GetViewBytes(x.source);
                        source    = Utf8String.Encoding.GetString(bytes.Array, bytes.Offset, bytes.Count);
                    }
                    catch (Exception)
                    {
                        // 握りつぶし
                    }

                    return(new VCIObject.Script
                    {
                        name = x.name,
                        mimeType = x.mimeType,
                        targetEngine = x.targetEngine,
                        source = source
                    });
                }));
            }

            // Audio
            if (GLTF.extensions.VCAST_vci_audios != null &&
                GLTF.extensions.VCAST_vci_audios.audios != null)
            {
                var root = Root;
                foreach (var audio in GLTF.extensions.VCAST_vci_audios.audios)
                {
#if ((NET_4_6 || NET_STANDARD_2_0) && UNITY_2017_1_OR_NEWER)
                    if (Application.isPlaying)
                    {
                        var bytes = GLTF.GetViewBytes(audio.bufferView);
                        yield return(AudioImporter.Import(audio, bytes, root));
                    }
                    else
#endif
                    {
#if UNITY_EDITOR
                        var audioClip =
                            AssetDatabase.LoadAssetAtPath(AudioAssetPathList[audio.name], typeof(AudioClip)) as
                            AudioClip;
                        if (audioClip != null)
                        {
                            var source = root.AddComponent <AudioSource>();
                            source.clip = audioClip;
                        }
                        else
                        {
                            Debug.LogWarning("AudioFile NotFound: " + audio.name);
                        }
#endif
                    }
                }
            }

            // Animation
            var rootAnimation = Root.GetComponent <Animation>();
            if (rootAnimation != null)
            {
                rootAnimation.playAutomatically = false;
            }

            // SubItem
            for (var i = 0; i < GLTF.nodes.Count; i++)
            {
                var node = GLTF.nodes[i];
                if (node.extensions != null)
                {
                    if (node.extensions.VCAST_vci_item != null)
                    {
                        var go   = Nodes[i].gameObject;
                        var item = go.AddComponent <VCISubItem>();
                        item.Grabbable      = node.extensions.VCAST_vci_item.grabbable;
                        item.Scalable       = node.extensions.VCAST_vci_item.scalable;
                        item.UniformScaling = node.extensions.VCAST_vci_item.uniformScaling;
                        item.GroupId        = node.extensions.VCAST_vci_item.groupId;
                    }
                }
            }
        }