private ViewportJS CreateViewport() { TreeNode pnode = FindTreeNode("Viewports"); string name; do { name = "Viewport_" + mVPIndex++; } while (!IsUniqueName(pnode, name)); TreeNode node = pnode.Nodes.Add(name); ViewportJS obj = new ViewportJS(name, node); obj.Source = name + ".xml"; node.Tag = obj; return obj; }
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; } } } }