public PlaneOptimalShadowCameraSetup(MovablePlane plane) : this(OgrePINVOKE.new_PlaneOptimalShadowCameraSetup(MovablePlane.getCPtr(plane)), true) { if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } }
public void enableCustomNearClipPlane(MovablePlane plane) { OgrePINVOKE.Frustum_enableCustomNearClipPlane__SWIG_0(swigCPtr, MovablePlane.getCPtr(plane)); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } }
public void enableReflection(MovablePlane p) { OgrePINVOKE.Frustum_enableReflection__SWIG_1(swigCPtr, MovablePlane.getCPtr(p)); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } }
public ShadowCameraSetupPtr create(MovablePlane plane) { ShadowCameraSetupPtr ret = new ShadowCameraSetupPtr(OgrePINVOKE.PlaneOptimalShadowCameraSetupPtr_create(swigCPtr, MovablePlane.getCPtr(plane)), true); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
/// <summary> /// you should use that function instead of OnEnable() /// </summary> public override void OnCustomEnable() { base.OnCustomEnable(); _attractorPlane = (MovablePlane)GetTarget <MovableShape>(); }
protected override void CreateScene() { mLog = LogManager.Singleton.createLog("RSQTest.log", false, true); mLog.LogMessage(string.Format("RSQTest log {0}", System.DateTime.Now)); create4LineDebugOverLay(); Show4LineDebugOverLay(); //setup RenderTargetListenerDirector mRTListener = new RenderTargetListenerDirector(); mRTListener.SubscribeEvents(); mRTListener.evtPreRenderTargetUpdate += new RenderTargetListenerDirector.RTLD_Delegate_RenderTargetUpdate(event_PreRenderTargetUpdate); mRTListener.evtPostRenderTargetUpdate += new RenderTargetListenerDirector.RTLD_Delegate_RenderTargetUpdate(event_PostRenderTargetUpdate); mSceneManager.SetAmbientLight(Converter.GetColor(0.2f, 0.2f, 0.2f)); mSceneManager.SetSkyBox(true, "Examples/MorningSkyBox"); // Create a light Light l = mSceneManager.CreateLight("MainLight"); l.SetLightType(OgreDotNet.Light.LightTypes.Directional); Math3D.Vector3 dir = new Vector3(0.5f, -1.0f, 0.0f); dir.Normalize(); l.SetDirection(dir); l.SetDiffuseColour(1.0f, 1.0f, 0.8f); l.SetSpecularColour(1.0f, 1.0f, 1.0f); // Create a prefab plane mPlane = new MovablePlane("ReflectPlane"); mPlane.D = 0; mPlane.Normal = OgreVector3.FromVector3(Math3D.Vector3.UnitY); MeshManager.GetSingleton().CreatePlane("ReflectionPlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, mPlane, 2000, 2000, 1, 1, true, 1, 1, 1, Vector3.UnitZ); mPlaneEnt = mSceneManager.CreateEntity("Plane", "ReflectionPlane"); // Create an entity from a model (will be loaded automatically) Entity knotEnt = mSceneManager.CreateEntity("Knot", "knot.mesh"); // Create an entity from a model (will be loaded automatically) Entity ogreHead = mSceneManager.CreateEntity("Head", "ogrehead.mesh"); knotEnt.SetMaterialName("Examples/TextureEffect2"); // Attach the rtt entity to the root of the scene SceneNode rootNode = mSceneManager.GetRootSceneNode(); mPlaneNode = rootNode.CreateChildSceneNode(); // Attach both the plane entity, and the plane definition mPlaneNode.AttachObject(mPlaneEnt); //multi Inheritence problem, use the static Get*From function to convert MovableObject mo = MovableObject.GetMovableObjectFrom(mPlane); mPlaneNode.AttachObject(mo); mPlaneNode.Translate(0.0f, -10.0f, 0.0f); // Tilt it a little to make it interesting //mPlaneNode.Roll( new Radian( new Degree( 5.0f)) ); mPlaneNode.Roll(5.0f); rootNode.CreateChildSceneNode("Head").AttachObject(ogreHead); RenderTexture rttTex = mRoot.GetRenderSystem().CreateRenderTexture("RttTex", 512, 512, TextureType.TEX_TYPE_2D, PixelFormat.PF_R8G8B8); { //new scope for some reason mReflectCam = mSceneManager.CreateCamera("ReflectCam"); mReflectCam.SetNearClipDistance(mCamera.GetNearClipDistance()); mReflectCam.SetFarClipDistance(mCamera.GetFarClipDistance()); mReflectCam.SetAspectRatio( (float)mRenderWindow.GetViewport(0).ActualWidth / (float)mRenderWindow.GetViewport(0).ActualHeight); Viewport v = rttTex.AddViewport(mReflectCam); v.ClearEveryFrame = true; v.BackgroundColor = System.Drawing.Color.Black; //Converter.ToColor( ColourValue.Black ); ResourcePtr resPtr = MaterialManager.Instance.Create("RttMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); MaterialPtr mat = new MaterialPtr(ResourcePtr.getCPtr(resPtr).Handle, false); TextureUnitState t = mat.Get().GetTechnique(0).getPass(0).createTextureUnitState("RustedMetal.jpg"); t = mat.Get().GetTechnique(0).getPass(0).createTextureUnitState("RttTex"); // Blend with base texture t.setColourOperationEx(LayerBlendOperationEx.LBX_BLEND_MANUAL, LayerBlendSource.LBS_TEXTURE, LayerBlendSource.LBS_CURRENT, Color.White, Color.White, 0.25f); t.SetTextureAddressingMode(TextureUnitState.TextureAddressingMode.TAM_CLAMP); t.setProjectiveTexturing(true, mReflectCam); rttTex.AddListener(mRTListener); // set up linked reflection mReflectCam.EnableReflection(mPlane); // Also clip mReflectCam.EnableCustomNearClipPlane(mPlane); } // Give the plane a texture mPlaneEnt.SetMaterialName("RttMat"); // Add a whole bunch of extra transparent entities Entity cloneEnt; for (int n = 0; n < 10; ++n) { // Create a new node under the root SceneNode node = mSceneManager.CreateSceneNode(); // Random translate Vector3 nodePos; nodePos.x = OgreMath.SymmetricRandom() * 750.0f; nodePos.y = OgreMath.SymmetricRandom() * 100.0f + 25.0f; nodePos.z = OgreMath.SymmetricRandom() * 750.0f; node.SetPosition(nodePos); rootNode.AddChild(node); // Clone knot string cloneName = string.Format("Knot{0}", n); cloneEnt = knotEnt.Clone(cloneName); // Attach to new node node.AttachObject(cloneEnt); } mCamera.SetPosition(new Vector3(-50.0f, 100.0f, 500.0f)); mCamera.LookAt = new Vector3(0, 0, 0); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(MovablePlane obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
// Just override the mandatory create scene method public override void CreateScene() { // Set ambient light sceneMgr.AmbientLight = new ColourValue(0.2f, 0.2f, 0.2f); // Skybox sceneMgr.SetSkyBox(true, "Examples/MorningSkyBox"); // Create a light Light l = sceneMgr.CreateLight("MainLight"); l.Type = Light.LightTypes.LT_DIRECTIONAL; Vector3 dir = new Vector3(0.5f, -1, 0); dir.Normalise(); l.Direction = dir; l.DiffuseColour = new ColourValue(1.0f, 1.0f, 0.8f); l.SpecularColour= new ColourValue(1.0f, 1.0f, 1.0f); // Create a prefab plane mPlane = new MovablePlane(Vector3.UNIT_Y, 0); MeshManager.Singleton.CreatePlane("ReflectionPlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, mPlane._getDerivedPlane(), 2000, 2000, 1, 1, true, 1, 1, 1, Vector3.UNIT_Z); mPlaneEnt = sceneMgr.CreateEntity( "Plane", "ReflectionPlane" ); // Create an entity from a model (will be loaded automatically) Entity knotEnt = sceneMgr.CreateEntity("Knot", "knot.mesh"); // Create an entity from a model (will be loaded automatically) Entity ogreHead = sceneMgr.CreateEntity("Head", "ogrehead.mesh"); knotEnt.SetMaterialName("Examples/TextureEffect2"); // Attach the rtt entity to the root of the scene SceneNode rootNode = sceneMgr.RootSceneNode; mPlaneNode = rootNode.CreateChildSceneNode(); // Attach both the plane entity, and the plane definition mPlaneNode.AttachObject(mPlaneEnt); mPlaneNode.AttachObject(mPlane); mPlaneNode.Translate(0, -10, 0); // Tilt it a little to make it interesting mPlaneNode.Roll(new Degree(5)); rootNode.CreateChildSceneNode( "Head" ).AttachObject( ogreHead ); TexturePtr texture = TextureManager.Singleton.CreateManual( "RttTex", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, 512, 512, 0, PixelFormat.PF_R8G8B8, (int) TextureUsage.TU_RENDERTARGET ); RenderTarget rttTex = texture.GetBuffer().GetRenderTarget(); mReflectCam = sceneMgr.CreateCamera("ReflectCam"); mReflectCam.NearClipDistance = camera.NearClipDistance; mReflectCam.FarClipDistance = camera.FarClipDistance; mReflectCam.AspectRatio = (float)window.GetViewport(0).ActualWidth / (float)window.GetViewport(0).ActualHeight; mReflectCam.FOVy = camera.FOVy; Viewport v = rttTex.AddViewport( mReflectCam ); v.SetClearEveryFrame(true); v.BackgroundColour = ColourValue.Black; MaterialPtr mat = MaterialManager.Singleton.Create("RttMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); TextureUnitState t = mat.GetTechnique(0).GetPass(0).CreateTextureUnitState("RustedMetal.jpg"); t = mat.GetTechnique(0).GetPass(0).CreateTextureUnitState("RttTex"); // Blend with base texture t.SetColourOperationEx(LayerBlendOperationEx.LBX_BLEND_MANUAL, LayerBlendSource.LBS_TEXTURE, LayerBlendSource.LBS_CURRENT, ColourValue.White, ColourValue.White, 0.25f); t.SetTextureAddressingMode(TextureUnitState.TextureAddressingMode.TAM_CLAMP); t.SetProjectiveTexturing(true, mReflectCam); rttTex.PostRenderTargetUpdate += postRenderTargetUpdate; rttTex.PreRenderTargetUpdate += preRenderTargetUpdate; // set up linked reflection mReflectCam.EnableReflection(mPlane); // Also clip mReflectCam.EnableCustomNearClipPlane(mPlane); // Give the plane a texture mPlaneEnt.SetMaterialName("RttMat"); // Add a whole bunch of extra transparent entities Entity cloneEnt; for (int n = 0; n < 10; ++n) { // Create a new node under the root SceneNode node = sceneMgr.CreateSceneNode(); // Random translate Vector3 nodePos; nodePos.x = Mogre.Math.SymmetricRandom() * 750.0f; nodePos.y = Mogre.Math.SymmetricRandom() * 100.0f + 25; nodePos.z = Mogre.Math.SymmetricRandom() * 750.0f; node.Position = nodePos; rootNode.AddChild(node); // Clone knot string cloneName = "Knot" + n; cloneEnt = knotEnt.Clone(cloneName); // Attach to new node node.AttachObject(cloneEnt); } camera.Position = new Vector3(-50, 100, 500); camera.LookAt(0,0,0); }
// Just override the mandatory create scene method public override void CreateScene() { // Set ambient light sceneMgr.AmbientLight = new ColourValue(0.2f, 0.2f, 0.2f); // Skybox sceneMgr.SetSkyBox(true, "Examples/MorningSkyBox"); // Create a light Light l = sceneMgr.CreateLight("MainLight"); l.Type = Light.LightTypes.LT_DIRECTIONAL; Vector3 dir = new Vector3(0.5f, -1, 0); dir.Normalise(); l.Direction = dir; l.DiffuseColour = new ColourValue(1.0f, 1.0f, 0.8f); l.SpecularColour = new ColourValue(1.0f, 1.0f, 1.0f); // Create a prefab plane mPlane = new MovablePlane(Vector3.UNIT_Y, 0); MeshManager.Singleton.CreatePlane("ReflectionPlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, mPlane._getDerivedPlane(), 2000, 2000, 1, 1, true, 1, 1, 1, Vector3.UNIT_Z); mPlaneEnt = sceneMgr.CreateEntity("Plane", "ReflectionPlane"); // Create an entity from a model (will be loaded automatically) Entity knotEnt = sceneMgr.CreateEntity("Knot", "knot.mesh"); // Create an entity from a model (will be loaded automatically) Entity ogreHead = sceneMgr.CreateEntity("Head", "ogrehead.mesh"); knotEnt.SetMaterialName("Examples/TextureEffect2"); // Attach the rtt entity to the root of the scene SceneNode rootNode = sceneMgr.RootSceneNode; mPlaneNode = rootNode.CreateChildSceneNode(); // Attach both the plane entity, and the plane definition mPlaneNode.AttachObject(mPlaneEnt); mPlaneNode.AttachObject(mPlane); mPlaneNode.Translate(0, -10, 0); // Tilt it a little to make it interesting mPlaneNode.Roll(new Degree(5)); rootNode.CreateChildSceneNode("Head").AttachObject(ogreHead); TexturePtr texture = TextureManager.Singleton.CreateManual("RttTex", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, 512, 512, 0, PixelFormat.PF_R8G8B8, (int)TextureUsage.TU_RENDERTARGET); RenderTarget rttTex = texture.GetBuffer().GetRenderTarget(); mReflectCam = sceneMgr.CreateCamera("ReflectCam"); mReflectCam.NearClipDistance = camera.NearClipDistance; mReflectCam.FarClipDistance = camera.FarClipDistance; mReflectCam.AspectRatio = (float)window.GetViewport(0).ActualWidth / (float)window.GetViewport(0).ActualHeight; mReflectCam.FOVy = camera.FOVy; Viewport v = rttTex.AddViewport(mReflectCam); v.SetClearEveryFrame(true); v.BackgroundColour = ColourValue.Black; MaterialPtr mat = MaterialManager.Singleton.Create("RttMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); TextureUnitState t = mat.GetTechnique(0).GetPass(0).CreateTextureUnitState("RustedMetal.jpg"); t = mat.GetTechnique(0).GetPass(0).CreateTextureUnitState("RttTex"); // Blend with base texture t.SetColourOperationEx(LayerBlendOperationEx.LBX_BLEND_MANUAL, LayerBlendSource.LBS_TEXTURE, LayerBlendSource.LBS_CURRENT, ColourValue.White, ColourValue.White, 0.25f); t.SetTextureAddressingMode(TextureUnitState.TextureAddressingMode.TAM_CLAMP); t.SetProjectiveTexturing(true, mReflectCam); rttTex.PostRenderTargetUpdate += postRenderTargetUpdate; rttTex.PreRenderTargetUpdate += preRenderTargetUpdate; // set up linked reflection mReflectCam.EnableReflection(mPlane); // Also clip mReflectCam.EnableCustomNearClipPlane(mPlane); // Give the plane a texture mPlaneEnt.SetMaterialName("RttMat"); // Add a whole bunch of extra transparent entities Entity cloneEnt; for (int n = 0; n < 10; ++n) { // Create a new node under the root SceneNode node = sceneMgr.CreateSceneNode(); // Random translate Vector3 nodePos; nodePos.x = Mogre.Math.SymmetricRandom() * 750.0f; nodePos.y = Mogre.Math.SymmetricRandom() * 100.0f + 25; nodePos.z = Mogre.Math.SymmetricRandom() * 750.0f; node.Position = nodePos; rootNode.AddChild(node); // Clone knot string cloneName = "Knot" + n; cloneEnt = knotEnt.Clone(cloneName); // Attach to new node node.AttachObject(cloneEnt); } camera.Position = new Vector3(-50, 100, 500); camera.LookAt(0, 0, 0); }
protected override void CreateScene() { // set ambient light scene.AmbientLight = new ColorEx(0.2f, 0.2f, 0.2f); scene.SetSkyBox(true, "Skybox/Morning", 5000); // create a default point light Light light = scene.CreateLight("MainLight"); light.Type = LightType.Directional; Vector3 dir = new Vector3(0.5f, -1, 0); dir.Normalize(); light.Direction = dir; light.Diffuse = new ColorEx(1.0f, 1.0f, 0.8f); light.Specular = ColorEx.White; // create a plane plane = new MovablePlane("ReflectPlane"); plane.D = 0; plane.Normal = Vector3.UnitY; // create another plane to create the mesh. Ogre's MovablePlane uses multiple inheritance, bah! Plane tmpPlane = new Plane(); tmpPlane.D = 0; tmpPlane.Normal = Vector3.UnitY; MeshManager.Instance.CreatePlane("ReflectionPlane", tmpPlane, 2000, 2000, 1, 1, true, 1, 1, 1, Vector3.UnitZ); planeEntity = scene.CreateEntity("Plane", "ReflectionPlane"); // create an entity from a model Entity knot = scene.CreateEntity("Knot", "knot.mesh"); knot.MaterialName = "TextureFX/Knot"; // create an entity from a model Entity head = scene.CreateEntity("Head", "ogrehead.mesh"); // attach the render to texture entity to the root of the scene SceneNode rootNode = scene.RootSceneNode; planeNode = rootNode.CreateChildSceneNode(); planeNode.AttachObject(planeEntity); planeNode.AttachObject(plane); planeNode.Translate(new Vector3(0, -10, 0)); // tilt it a little to make it interesting planeNode.Roll(5); rootNode.CreateChildSceneNode("Head").AttachObject(head); // create a render texture RenderTexture rttTex = Root.Instance.RenderSystem.CreateRenderTexture("RttTex", 512, 512); reflectCam = scene.CreateCamera("ReflectCam"); reflectCam.Near = camera.Near; reflectCam.Far = camera.Far; reflectCam.AspectRatio = (float)window.GetViewport(0).ActualWidth / (float)window.GetViewport(0).ActualHeight; Viewport viewport = rttTex.AddViewport(reflectCam); viewport.ClearEveryFrame = true; viewport.OverlaysEnabled = false; viewport.BackgroundColor = ColorEx.Black; Material mat = scene.CreateMaterial("RttMat"); TextureUnitState t = mat.GetTechnique(0).GetPass(0).CreateTextureUnitState("RustedMetal.jpg"); t = mat.GetTechnique(0).GetPass(0).CreateTextureUnitState("RttTex"); // blend with base texture t.SetColorOperationEx(LayerBlendOperationEx.BlendManual, LayerBlendSource.Texture, LayerBlendSource.Current, ColorEx.White, ColorEx.White, 0.25f); t.SetProjectiveTexturing(true, reflectCam); // register events for viewport before/after update rttTex.AfterUpdate += new RenderTargetUpdateEventHandler(rttTex_AfterUpdate); rttTex.BeforeUpdate += new RenderTargetUpdateEventHandler(rttTex_BeforeUpdate); // set up linked reflection reflectCam.EnableReflection(plane); // also clip reflectCam.EnableCustomNearClipPlane(plane); planeEntity.MaterialName = "RttMat"; Entity clone = null; for (int i = 0; i < 10; i++) { // create a new node under the root SceneNode node = scene.CreateSceneNode(); // calculate a random position Vector3 nodePosition = new Vector3(); nodePosition.x = MathUtil.SymmetricRandom() * 750.0f; nodePosition.y = MathUtil.SymmetricRandom() * 100.0f + 25; nodePosition.z = MathUtil.SymmetricRandom() * 750.0f; // set the new position node.Position = nodePosition; // attach this node to the root node rootNode.AddChild(node); // clone the knot string cloneName = string.Format("Knot{0}", i); clone = knot.Clone(cloneName); // add the cloned knot to the scene node.AttachObject(clone); } camera.Position = new Vector3(-50, 100, 500); camera.LookAt(new Vector3(0, 0, 0)); }