예제 #1
0
        private RenderObjectJS CreateRenderObject(string inname = null)
        {
            TreeNode ronode = FindTreeNode("Render Objects");

            string name;
            int idx = 0;
            do
            {
                if (inname == null)
                    name = "RenderObject_" + mROIndex++;
                else
                    name = inname + "_" + idx++;
            } while (!IsUniqueName(ronode, name));

            TreeNode node = ronode.Nodes.Add(name);
            RenderObjectJS obj = new RenderObjectJS(name, node);
            obj.Source = name + ".xml";
            mRenderObjects.Add(obj);
            node.Tag = obj;
            return obj;
        }
예제 #2
0
        public SceneJS(string json, TreeNode node)
        {
            mRenderObjects = new List<RenderObjectJS>();
            mCameras = new List<CameraJS>();
            mLights = new List<LightJS>();

            mTreeNode = node;

            TreeNode unode = AddChildNode("Update Passes", "New Update Pass", onNewUpdatePass);
            TreeNode rnode = AddChildNode("Render Passes", "New Render Pass", onNewRenderPass);
            TreeNode ronode = AddChildNode("Render Objects", "New Render Object", onNewRenderObject);
            TreeNode vpnode = AddChildNode("Viewports", "New Viewport", onNewViewport);
            TreeNode camnode = AddChildNode("Cameras", "New Camera", onNewCamera);
            TreeNode fbnode = AddChildNode("Frame Buffers", "New Frame Buffer", onNewFrameBuffer);
            TreeNode mnode = AddChildNode("Meshes", "New Mesh", onNewMesh);
            TreeNode snode = AddChildNode("Shaders", "New Shader", onNewShader);
            TreeNode lightnode = AddChildNode("Lights", "New Light", onNewLight);
            TreeNode texnode = AddChildNode("Textures", "New Texture", onNewTexture);
            TreeNode particleNode = AddChildNode("Particles", "New Particle", onNewParticle);
            TreeNode particleENode = AddChildNode("Particle Emitters", "New Emitter", onNewEmitter);
            TreeNode particleSNode = AddChildNode("Particle Systems", "New Particle System", onNewParticleSystem);

            texnode.ContextMenu.MenuItems.Add("Import", onImportTextures);

            if (json != null)
            {
                // WorldUpdate;ShadowPass,DiffusePass,2DOverlay
                string[] props = json.Split(';');
                string[] updatePasses = props[0].Split(',');
                string[] renderPasses = props[1].Split(',');
                string[] renderObjects = props[2].Split(',');
                string[] viewports = props[3].Split(',');
                string[] cameras = props[4].Split(',');
                string[] frameBuffers = props[5].Split(',');
                string[] meshes = props[6].Split(',');
                string[] shaders = props[7].Split(',');
                string[] lights = props[8].Split(',');
                string[] textures = props[9].Split(',');
                string[] particles = props[10].Split(',');
                string[] particleEmitters = props[11].Split(',');
                string[] particleSystems = props[12].Split(',');
                mScenePath = props[13];

                for (int i = 0; i < updatePasses.Length; i++)
                {
                    if (updatePasses[i].Length > 0)
                    {
                        TreeNode child = unode.Nodes.Add(updatePasses[i]);
                        UpdatePassJS updatePass = new UpdatePassJS(updatePasses[i], child);
                        child.Tag = updatePass;
                    }
                }

                for (int i = 0; i < renderPasses.Length; i++)
                {
                    if (renderPasses[i].Length > 0)
                    {
                        TreeNode child = rnode.Nodes.Add(renderPasses[i]);
                        RenderPassJS renderPass = new RenderPassJS(renderPasses[i], child);
                        child.Tag = renderPass;
                    }
                }

                for (int i = 0; i < renderObjects.Length; i++)
                {
                    if (renderObjects[i].Length > 0)
                    {
                        TreeNode child = ronode.Nodes.Add(renderObjects[i]);
                        RenderObjectJS ro = new RenderObjectJS(renderObjects[i], child);
                        mRenderObjects.Add(ro);
                        child.Tag = ro;
                    }
                }

                for (int i = 0; i < viewports.Length; i++)
                {
                    if (viewports[i].Length > 0)
                    {
                        TreeNode child = vpnode.Nodes.Add(viewports[i]);
                        ViewportJS vp = new ViewportJS(viewports[i], child);
                        child.Tag = vp;
                    }
                }

                for (int i = 0; i < cameras.Length; i++)
                {
                    if (cameras[i].Length > 0)
                    {
                        TreeNode child = camnode.Nodes.Add(cameras[i]);
                        CameraJS cam = new CameraJS(cameras[i], child);
                        mCameras.Add(cam);
                        child.Tag = cam;
                    }
                }

                for (int i = 0; i < frameBuffers.Length; i++)
                {
                    if (frameBuffers[i].Length > 0)
                    {
                        TreeNode child = fbnode.Nodes.Add(frameBuffers[i]);
                        FrameBufferJS fb = new FrameBufferJS(frameBuffers[i], child);
                        child.Tag = fb;
                    }
                }

                for (int i = 0; i < meshes.Length; i++)
                {
                    if (meshes[i].Length > 0)
                    {
                        TreeNode child = mnode.Nodes.Add(meshes[i]);
                    }
                }

                for (int i = 0; i < shaders.Length; i++)
                {
                    if (shaders[i].Length > 0)
                    {
                        TreeNode child = snode.Nodes.Add(shaders[i]);
                        ShaderJS s = new ShaderJS(shaders[i], child);
                        child.Tag = s;
                    }
                }

                for (int i = 0; i < lights.Length; i++)
                {
                    if (lights[i].Length > 0)
                    {
                        TreeNode child = lightnode.Nodes.Add(lights[i]);
                        LightJS s = new LightJS(lights[i], child);
                        child.Tag = s;
                        mLights.Add(s);
                    }
                }

                for (int i = 0; i < textures.Length; i++)
                {
                    if (textures[i].Length > 0)
                    {
                        TreeNode child = texnode.Nodes.Add(textures[i]);
                        TextureJS s = new TextureJS(textures[i], child);
                        child.Tag = s;
                    }
                }

                for (int i = 0; i < particles.Length; i++)
                {
                    if (particles[i].Length > 0)
                    {
                        TreeNode child = particleNode.Nodes.Add(particles[i]);
                        ParticleJS part = new ParticleJS(particles[i], child);
                        child.Tag = part;
                    }
                }

                for (int i = 0; i < particleEmitters.Length; i++)
                {
                    if (particleEmitters[i].Length > 0)
                    {
                        TreeNode child = particleENode.Nodes.Add(particleEmitters[i]);
                        ParticleEmitterJS part = new ParticleEmitterJS(particleEmitters[i], child);
                        child.Tag = part;
                    }
                }

                for (int i = 0; i < particleSystems.Length; i++)
                {
                    if (particleSystems[i].Length > 0)
                    {
                        TreeNode child = particleSNode.Nodes.Add(particleSystems[i]);
                        ParticleSystemJS part = new ParticleSystemJS(particleSystems[i], child);
                        child.Tag = part;
                    }
                }
            }
        }
예제 #3
0
        public void Import(string data)
        {
            int idx = data.IndexOf(':');
            string type = data.Substring(0, idx);

            int idx2 = data.IndexOf(';');
            string name = data.Substring(idx + 1, idx2 - (idx + 1));

            TreeNode node = null;
            object obj = null;
            switch (type)
            {
                case "mesh":
                    node = FindTreeNode("Meshes");
                    break;
                case "renderObject":
                    node = FindTreeNode("Render Objects");
                    RenderObjectJS ro = new RenderObjectJS(name, node);
                    ro.Source = name + ".xml";
                    mRenderObjects.Add(ro);
                    obj = ro;
                    break;
                default:
                    Console.WriteLine("Unhandled import data type: " + type);
                    break;
            }
            if (node != null)
            {
                if (IsUniqueName(node, name))
                {
                    // Child doesnt exist, add it now
                    TreeNode child = node.Nodes.Add(name);
                    child.Tag = obj;
                }
            }
        }
예제 #4
0
        public void CopyFrom(RenderObjectJS other)
        {
            mPos.X = other.Position.X;
            mPos.Y = other.Position.Y;
            mPos.Z = other.Position.Z;

            Rotation.X = other.Rotation.X;
            Rotation.Y = other.Rotation.Y;
            Rotation.Z = other.Rotation.Z;
            Scale.X = other.Scale.X;
            Scale.Y = other.Scale.Y;
            Scale.Z = other.Scale.Z;

            UpdateFunction = other.mUpdateFunction;
            Shader = other.mShader;
            Mesh = other.mMesh;

            Texture = other.mTexture;
            //mTextures.Clear();
            //foreach (string str in other.mTextures)
            //{
            //    mTextures.Add(str);
            //}
            ShadowCamera = other.mShadowCamera;
        }