Exemplo n.º 1
0
        /**
         * @brief load tree command
         **/
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string treeName = ResourceSelectorWindow.SelectResource(ResourceSelectorWindow.ObserveType.BTTree, "", this);

            if (treeName != "")
            {
                LoadBTTree(treeName);
            }
        }
Exemplo n.º 2
0
        public void RunScript()
        {
            if (Mgr <CatProject> .Singleton == null)
            {
                return;
            }
            // ask for model
            string modelName = ResourceSelectorWindow.SelectResource(ResourceSelectorWindow.ObserveType.Model,
                                                                     "");

            if (modelName == "")
            {
                return;
            }
            CatModel model = Mgr <CatProject> .Singleton.modelList1.GetModel(modelName);

            if (model != null)
            {
                CatMaterial material = model.GetMaterial();
                if (material == null || !material.HasParameter("DiffuseMap"))
                {
                    // TODO: give warning
                    return;
                }
            }
            else
            {
                return;
            }
            // ask for texture
            string textureName = ResourceSelectorWindow.SelectResource(ResourceSelectorWindow.ObserveType.Texture,
                                                                       "");

            if (textureName == "")
            {
                return;
            }
            Texture2D texture = Mgr <CatProject> .Singleton.contentManger.Load <Texture2D>("image\\" + textureName);

            if (texture == null)
            {
                return;
            }

            GameObject newGameObject = new GameObject();

            if (Mgr <Camera> .Singleton != null)
            {
                newGameObject.Position = new Vector3(Mgr <Camera> .Singleton.TargetPosition.X,
                                                     Mgr <Camera> .Singleton.TargetPosition.Y,
                                                     0.0f);
            }
            else
            {
                newGameObject.Position = Vector3.Zero;
            }
            ModelComponent modelComponent = new ModelComponent(newGameObject);

            newGameObject.AddComponent(modelComponent);
            modelComponent.Model = model;
            modelComponent.GetCatModelInstance().GetMaterial().SetParameter("DiffuseMap",
                                                                            new CatTexture(texture));
            QuadRender quadRender = new QuadRender(newGameObject);

            newGameObject.AddComponent(quadRender);
            quadRender.OptimalSize = true;
            Mgr <Scene> .Singleton._gameObjectList.AddGameObject(newGameObject);
        }