public override void CreateScene() { // Check capabilities RenderSystemCapabilities caps = Root.Singleton.RenderSystem.Capabilities; if (!caps.HasCapability(Mogre.Capabilities.RSC_VERTEX_PROGRAM) || !(caps.HasCapability(Mogre.Capabilities.RSC_FRAGMENT_PROGRAM))) { MessageBox.Show("Your card does not support vertex and fragment programs, so cannot run this demo. Sorry! CelShading::createScene"); } // Create a point light Light l = sceneMgr.CreateLight("MainLight"); // Accept default settings: point light, white diffuse, just set position // Add light to the scene node rootNode = sceneMgr.RootSceneNode.CreateChildSceneNode(); rootNode.CreateChildSceneNode(new Vector3(20, 40, 50)).AttachObject(l); Entity ent = sceneMgr.CreateEntity("head", "ogrehead.mesh"); camera.Position = new Vector3(20, 0, 100); camera.LookAt(new Vector3(0, 0, 0)); // Set common material, but define custom parameters to change colours // See Example-Advanced.material for how these are finally bound to GPU parameters SubEntity sub; // eyes sub = ent.GetSubEntity(0); sub.SetMaterialName("Examples/CelShading"); sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(35.0f, 0.0f, 0.0f, 0.0f)); sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(1.0f, 0.3f, 0.3f, 1.0f)); sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(1.0f, 0.6f, 0.6f, 1.0f)); // skin sub = ent.GetSubEntity(1); sub.SetMaterialName("Examples/CelShading"); sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(10.0f, 0.0f, 0.0f, 0.0f)); sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(0.0f, 0.5f, 0.0f, 1.0f)); sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(0.3f, 0.5f, 0.3f, 1.0f)); // earring sub = ent.GetSubEntity(2); sub.SetMaterialName("Examples/CelShading"); sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(25.0f, 0.0f, 0.0f, 0.0f)); sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(1.0f, 1.0f, 0.0f, 1.0f)); sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(1.0f, 1.0f, 0.7f, 1.0f)); // teeth sub = ent.GetSubEntity(3); sub.SetMaterialName("Examples/CelShading"); sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(20.0f, 0.0f, 0.0f, 0.0f)); sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(1.0f, 1.0f, 0.7f, 1.0f)); sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(1.0f, 1.0f, 1.0f, 1.0f)); // Add entity to the root scene node sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent); window.GetViewport(0).BackgroundColour = (Mogre.ColourValue.White); }
private void setupCamera(OgreManager engine) { focalPoint = engine.SceneMgr.RootSceneNode.CreateChildSceneNode("menuFocalPoint"); focalPoint.Position = new Vector3(0, -5, 0); engine.Camera.NearClipDistance = 5; engine.Camera.FarClipDistance = 16384; engine.Camera.AutoAspectRatio = true; engine.Camera.SetAutoTracking(true, focalPoint); }
public override void CreateScene() { // Check capabilities RenderSystemCapabilities caps = Root.Singleton.RenderSystem.Capabilities; if (!caps.HasCapability(Mogre.Capabilities.RSC_VERTEX_PROGRAM) || !(caps.HasCapability(Mogre.Capabilities.RSC_FRAGMENT_PROGRAM))) { MessageBox.Show("Your card does not support vertex and fragment programs, so cannot run this demo. Sorry! CelShading::createScene"); } // Create a point light Light l = sceneMgr.CreateLight("MainLight"); // Accept default settings: point light, white diffuse, just set position // Add light to the scene node rootNode = sceneMgr.RootSceneNode.CreateChildSceneNode(); rootNode.CreateChildSceneNode(new Vector3(20,40,50)).AttachObject(l); Entity ent = sceneMgr.CreateEntity("head", "ogrehead.mesh"); camera.Position = new Vector3(20, 0, 100); camera.LookAt( new Vector3(0,0,0)); // Set common material, but define custom parameters to change colours // See Example-Advanced.material for how these are finally bound to GPU parameters SubEntity sub; // eyes sub = ent.GetSubEntity(0); sub.MaterialName = ("Examples/CelShading"); sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(35.0f, 0.0f, 0.0f, 0.0f)); sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(1.0f, 0.3f, 0.3f, 1.0f)); sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(1.0f, 0.6f, 0.6f, 1.0f)); // skin sub = ent.GetSubEntity(1); sub.MaterialName = ("Examples/CelShading"); sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(10.0f, 0.0f, 0.0f, 0.0f)); sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(0.0f, 0.5f, 0.0f, 1.0f)); sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(0.3f, 0.5f, 0.3f, 1.0f)); // earring sub = ent.GetSubEntity(2); sub.MaterialName = ("Examples/CelShading"); sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(25.0f, 0.0f, 0.0f, 0.0f)); sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(1.0f, 1.0f, 0.0f, 1.0f)); sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(1.0f, 1.0f, 0.7f, 1.0f)); // teeth sub = ent.GetSubEntity(3); sub.MaterialName = ("Examples/CelShading"); sub.SetCustomParameter(CUSTOM_SHININESS, new Vector4(20.0f, 0.0f, 0.0f, 0.0f)); sub.SetCustomParameter(CUSTOM_DIFFUSE, new Vector4(1.0f, 1.0f, 0.7f, 1.0f)); sub.SetCustomParameter(CUSTOM_SPECULAR, new Vector4(1.0f, 1.0f, 1.0f, 1.0f)); // Add entity to the root scene node sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent); window.GetViewport(0).BackgroundColour = (Mogre.ColourValue.White); }
public override bool Load() { if (IsLoaded) { return(true); } if (!Parent.Load()) { return(false); } this.handle = Parent.Node.CreateChildSceneNode(Name, Position, Orientation); this.handle.SetScale(Scale); IsLoaded = true; return(true); }
public override bool UnLoad() { if (!IsLoaded) { return(true); } UnLoadAllChildren(); DestroyBoundingBox(); if (this.handle != null) { this.handle.ParentSceneNode.RemoveAndDestroyChild(this.name); this.handle = null; } IsLoaded = false; return(true); }
public override bool UnLoad() { if (!IsLoaded) return true; UnLoadAllChildren(); DestroyBoundingBox(); if (this.handle != null) { this.handle.ParentSceneNode.RemoveAndDestroyChild(this.name); this.handle = null; } IsLoaded = false; return true; }
public override bool Load() { if (IsLoaded) return true; if (!Parent.Load()) return false; this.handle = Parent.Node.CreateChildSceneNode(Name, Position, Orientation); this.handle.SetScale(Scale); IsLoaded = true; return true; }
protected void CreateBoundingBox() { this.boxParentNode = Node.CreateChildSceneNode("scbno" + this.name, new Mogre.Vector3(0, 0, 0), Mogre.Quaternion.IDENTITY); this.oBBoxData = GetAABB(); this.bBoxNode = this.boxParentNode.CreateChildSceneNode("scbnb" + this.name, new Mogre.Vector3(0, 0, 0), Mogre.Quaternion.IDENTITY); this.oBBoxRenderable = new Mogre.OBBoxRenderable("SelectionBBMaterial", MogitorsRoot.Instance.ProjectOptions.SelectionBBColour); this.oBBoxRenderable.SetupVertices(this.oBBoxData); this.bBoxNode.AttachObject(this.oBBoxRenderable); this.bBoxNode.SetVisible(false); this.highlightNode = this.boxParentNode.CreateChildSceneNode("scbnhl" + this.name, new Mogre.Vector3(0, 0, 0), Mogre.Quaternion.IDENTITY); this.highlightNode.SetScale(1.05f, 1.05f, 1.05f); this.highlightRenderable = new Mogre.OBBoxRenderable("HighlightBBMaterial", MogitorsRoot.Instance.ProjectOptions.HighlightBBColour); this.highlightRenderable.SetupVertices(this.oBBoxData); this.highlightNode.AttachObject(this.highlightRenderable); this.highlightNode.SetVisible(false); }
public void DestroyBoundingBox() { if (this.oBBoxRenderable == null) return; this.oBBoxRenderable.ParentSceneNode.DetachObject(this.oBBoxRenderable); this.oBBoxRenderable = null; this.highlightRenderable.ParentSceneNode.DetachObject(this.highlightRenderable); this.highlightRenderable = null; this.boxParentNode.RemoveAndDestroyChild(this.bBoxNode.Name); this.boxParentNode.RemoveAndDestroyChild(this.highlightNode.Name); this.bBoxNode = null; this.highlightNode = null; this.boxParentNode.ParentSceneNode.RemoveAndDestroyChild(this.boxParentNode.Name); this.boxParentNode = null; }