예제 #1
0
        public BaseDisposable SharedComponentCreate(string id, string name, int classId)
        {
            SceneController.i.OnMessageDecodeStart?.Invoke("ComponentCreated");
            sharedComponentCreatedMessage.id      = id;
            sharedComponentCreatedMessage.name    = name;
            sharedComponentCreatedMessage.classId = classId;
            SceneController.i.OnMessageDecodeEnds?.Invoke("ComponentCreated");

            BaseDisposable disposableComponent;

            if (disposableComponents.TryGetValue(sharedComponentCreatedMessage.id, out disposableComponent))
            {
                return(disposableComponent);
            }

            BaseDisposable newComponent = null;

            switch ((CLASS_ID)sharedComponentCreatedMessage.classId)
            {
            case CLASS_ID.BOX_SHAPE:
            {
                newComponent = new BoxShape(this);
                break;
            }

            case CLASS_ID.SPHERE_SHAPE:
            {
                newComponent = new SphereShape(this);
                break;
            }

            case CLASS_ID.CONE_SHAPE:
            {
                newComponent = new ConeShape(this);
                break;
            }

            case CLASS_ID.CYLINDER_SHAPE:
            {
                newComponent = new CylinderShape(this);
                break;
            }

            case CLASS_ID.PLANE_SHAPE:
            {
                newComponent = new PlaneShape(this);
                break;
            }

            case CLASS_ID.GLTF_SHAPE:
            {
                newComponent = new GLTFShape(this);
                break;
            }

            case CLASS_ID.NFT_SHAPE:
            {
                newComponent = new NFTShape(this);
                break;
            }

            case CLASS_ID.OBJ_SHAPE:
            {
                newComponent = new OBJShape(this);
                break;
            }

            case CLASS_ID.BASIC_MATERIAL:
            {
                newComponent = new BasicMaterial(this);
                break;
            }

            case CLASS_ID.PBR_MATERIAL:
            {
                newComponent = new PBRMaterial(this);
                break;
            }

            case CLASS_ID.AUDIO_CLIP:
            {
                newComponent = new DCLAudioClip(this);
                break;
            }

            case CLASS_ID.TEXTURE:
            {
                newComponent = new DCLTexture(this);
                break;
            }

            case CLASS_ID.UI_INPUT_TEXT_SHAPE:
            {
                newComponent = new UIInputText(this);
                break;
            }

            case CLASS_ID.UI_FULLSCREEN_SHAPE:
            case CLASS_ID.UI_SCREEN_SPACE_SHAPE:
            {
                if (uiScreenSpace == null)
                {
                    newComponent = new UIScreenSpace(this);
                }

                break;
            }

            case CLASS_ID.UI_CONTAINER_RECT:
            {
                newComponent = new UIContainerRect(this);
                break;
            }

            case CLASS_ID.UI_SLIDER_SHAPE:
            {
                newComponent = new UIScrollRect(this);
                break;
            }

            case CLASS_ID.UI_CONTAINER_STACK:
            {
                newComponent = new UIContainerStack(this);
                break;
            }

            case CLASS_ID.UI_IMAGE_SHAPE:
            {
                newComponent = new UIImage(this);
                break;
            }

            case CLASS_ID.UI_TEXT_SHAPE:
            {
                newComponent = new UIText(this);
                break;
            }

            case CLASS_ID.VIDEO_CLIP:
            {
                newComponent = new DCLVideoClip(this);
                break;
            }

            case CLASS_ID.VIDEO_TEXTURE:
            {
                newComponent = new DCLVideoTexture(this);
                break;
            }

            case CLASS_ID.FONT:
            {
                newComponent = new DCLFont(this);
                break;
            }

            default:
                Debug.LogError($"Unknown classId");
                break;
            }

            if (newComponent != null)
            {
                newComponent.id = sharedComponentCreatedMessage.id;
                disposableComponents.Add(sharedComponentCreatedMessage.id, newComponent);

                if (state != State.READY)
                {
                    disposableNotReady.Add(id);
                }
            }

            return(newComponent);
        }
예제 #2
0
        public BaseDisposable SharedComponentCreate(string id, int classId)
        {
            BaseDisposable disposableComponent;

            if (disposableComponents.TryGetValue(id, out disposableComponent))
            {
                return(disposableComponent);
            }

            BaseDisposable newComponent = null;

            switch ((CLASS_ID)classId)
            {
            case CLASS_ID.BOX_SHAPE:
            {
                newComponent = new BoxShape(this);
                break;
            }

            case CLASS_ID.SPHERE_SHAPE:
            {
                newComponent = new SphereShape(this);
                break;
            }

            case CLASS_ID.CONE_SHAPE:
            {
                newComponent = new ConeShape(this);
                break;
            }

            case CLASS_ID.CYLINDER_SHAPE:
            {
                newComponent = new CylinderShape(this);
                break;
            }

            case CLASS_ID.PLANE_SHAPE:
            {
                newComponent = new PlaneShape(this);
                break;
            }

            case CLASS_ID.GLTF_SHAPE:
            {
                newComponent = new GLTFShape(this);
                break;
            }

            case CLASS_ID.NFT_SHAPE:
            {
                newComponent = new NFTShape(this);
                break;
            }

            case CLASS_ID.OBJ_SHAPE:
            {
                newComponent = new OBJShape(this);
                break;
            }

            case CLASS_ID.BASIC_MATERIAL:
            {
                newComponent = new BasicMaterial(this);
                break;
            }

            case CLASS_ID.PBR_MATERIAL:
            {
                newComponent = new PBRMaterial(this);
                break;
            }

            case CLASS_ID.AUDIO_CLIP:
            {
                newComponent = new DCLAudioClip(this);
                break;
            }

            case CLASS_ID.TEXTURE:
            {
                newComponent = new DCLTexture(this);
                break;
            }

            case CLASS_ID.UI_INPUT_TEXT_SHAPE:
            {
                newComponent = new UIInputText(this);
                break;
            }

            case CLASS_ID.UI_FULLSCREEN_SHAPE:
            case CLASS_ID.UI_SCREEN_SPACE_SHAPE:
            {
                if (GetSharedComponent <UIScreenSpace>() == null)
                {
                    newComponent = new UIScreenSpace(this);
                }

                break;
            }

            case CLASS_ID.UI_CONTAINER_RECT:
            {
                newComponent = new UIContainerRect(this);
                break;
            }

            case CLASS_ID.UI_SLIDER_SHAPE:
            {
                newComponent = new UIScrollRect(this);
                break;
            }

            case CLASS_ID.UI_CONTAINER_STACK:
            {
                newComponent = new UIContainerStack(this);
                break;
            }

            case CLASS_ID.UI_IMAGE_SHAPE:
            {
                newComponent = new UIImage(this);
                break;
            }

            case CLASS_ID.UI_TEXT_SHAPE:
            {
                newComponent = new UIText(this);
                break;
            }

            case CLASS_ID.VIDEO_CLIP:
            {
                newComponent = new DCLVideoClip(this);
                break;
            }

            case CLASS_ID.VIDEO_TEXTURE:
            {
                newComponent = new DCLVideoTexture(this);
                break;
            }

            case CLASS_ID.FONT:
            {
                newComponent = new DCLFont(this);
                break;
            }

            case CLASS_ID.NAME:
            {
                newComponent = new DCLName(this);
                break;
            }

            case CLASS_ID.LOCKED_ON_EDIT:
            {
                newComponent = new DCLLockedOnEdit(this);
                break;
            }

            case CLASS_ID.VISIBLE_ON_EDIT:
            {
                newComponent = new DCLVisibleOnEdit(this);
                break;
            }

            default:
                Debug.LogError($"Unknown classId");
                break;
            }

            if (newComponent != null)
            {
                newComponent.id = id;
                disposableComponents.Add(id, newComponent);
                OnAddSharedComponent?.Invoke(id, newComponent);
            }

            return(newComponent);
        }
예제 #3
0
    public OBJLoader(string path)
    {
        using (StreamReader sr = new StreamReader($"{Directory.GetCurrentDirectory()}\\{path}", System.Text.Encoding.Default))
        {
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                line = Regex.Replace(line, "  ", " ");
                string[] command = line.Split(' ');
                switch (command[0])
                {
                case "vt":
                    uvList.Add(new Vector2(
                                   (float)double.Parse(command[1]),
                                   (float)double.Parse(command[2])));
                    break;

                case "v":
                    vertexList.Add(new Vector3(
                                       (float)double.Parse(command[1]),
                                       (float)double.Parse(command[2]),
                                       (float)double.Parse(command[3])));
                    break;

                case "f":
                    OBJShape shape = new OBJShape();
                    foreach (var i in command)
                    {
                        if (i != "f" && i != "")
                        {
                            if (i.Contains("/"))
                            {
                                string[] slash = i.Split('/');
                                if (slash.Length == 3)
                                {
                                    shape.IndeciesVertex.Add(Int32.Parse(slash[0]) - 1);
                                    shape.IndeciesUV.Add(Int32.Parse(slash[1]) - 1);
                                    shape.IndeciesNormal.Add(Int32.Parse(slash[2]) - 1);
                                }
                                else     //2, so it's vert and uv
                                {
                                    shape.IndeciesVertex.Add(Int32.Parse(slash[0]) - 1);
                                    shape.IndeciesUV.Add(Int32.Parse(slash[1]) - 1);
                                    shape.IndeciesNormal.Add(0);
                                }
                            }
                            else
                            {
                                shape.IndeciesVertex.Add(Int32.Parse(i) - 1);
                                shape.IndeciesUV.Add(0);
                                shape.IndeciesNormal.Add(0);
                            }
                        }
                    }
                    if (command.Length > 6)
                    {
                        Debug.Log(line);
                    }
                    shapeList.Add(shape);
                    break;

                case "vn":
                    normalsList.Add(new Vector3(
                                        (float)double.Parse(command[1]),
                                        (float)double.Parse(command[2]),
                                        (float)double.Parse(command[3])));
                    break;

                case "dm":
                    Debug.Log("Unfinished dm " + line);
                    break;

                case "sm":
                    Debug.Log("Unfinished sm " + line);
                    break;

                case "em":
                    Debug.Log("Unfinished em " + line);
                    break;
                }
            }
        }
    }
예제 #4
0
        private void SetObjectSize(OBJShape OBJShape, int width, int height)
        {
            switch (OBJShape)
            {
            case OBJShape.Square:
                int objSz = 0;
                while (width != 8)
                {
                    width >>= 8;
                    objSz++;
                }

                OBJSize = (uint)objSz;

                break;

            case OBJShape.Horizontal:
                if (height == 8)
                {
                    if (width == 16)
                    {
                        OBJSize = 0;
                    }
                    else
                    {
                        OBJSize = 1;
                    }
                }
                else if (height == 16)
                {
                    OBJSize = 2;
                }
                else
                {
                    OBJSize = 3;
                }
                break;

            case OBJShape.Vertical:
                if (width == 8)
                {
                    if (height == 16)
                    {
                        OBJSize = 0;
                    }
                    else
                    {
                        OBJSize = 1;
                    }
                }
                else if (width == 16)
                {
                    OBJSize = 2;
                }
                else
                {
                    OBJSize = 3;
                }
                break;

            case OBJShape.Prohibited:
                break;

            default:
                break;
            }
        }