protected override void CreateScene() { ((Overlay)OverlayManager.Instance.getByName("Gangsta/Demo/Target")).show(); Light l = mSceneManager.CreateLight("Light"); l.Position = new Math3D.Vector3(400, 500, 300); l.SetSpecularColour(1.0f, 1.0f, 1.0f); l.SetCastShadows(true); mSceneManager.SetShadowTechnique(ShadowTechnique.ShadowTypeStencilModulative); mSceneManager.SetShadowColour(Converter.GetColor(0.5f, 0.5f, 0.5f)); mSceneManager.SetAmbientLight(Converter.GetColor(0.5f, 0.5f, 0.5f)); mSceneManager.SetSkyBox(true, "Gangsta/Skybox/Io"); Plane plane = new Plane(); plane.Normal.x = 0.0f; plane.Normal.y = 1.0f; plane.Normal.z = 0.0f; plane.D = 0.0f; MeshPtr m = MeshManager.GetSingleton().CreatePlane("Plane_mesh", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, 400.0f, 400.0f, 10, 10, true, 1, 16.0f, 16.0f, Vector3.NegativeUnitZ); Entity e = mSceneManager.CreateEntity("Plane_entity", "Plane_mesh"); e.SetCastShadows(false); e.SetMaterialName("Gangsta/Ground/Dust"); m.SetNull(); m = null; SceneNode n = mSceneManager.GetRootSceneNode().CreateChildSceneNode("Plane_node"); n.AttachObject(e); }
protected override void CreateScene() { mMoveScale = 400.0f; mLog = LogManager.Singleton.createLog("DemoFireworks.log", false, true); mLog.LogMessage(string.Format("DemoFireworks log {0}", System.DateTime.Now)); mLog.LogMessage("CreateScene point setup envirenment"); mSceneManager.SetAmbientLight(Converter.GetColor(0.15f, 0.15f, 0.15f)); mSceneManager.SetSkyBox(true, "skybox/Starfield", 1000.0f); mLog.LogMessage("CreateScene point setup mainlight"); /*******/ Light l = mSceneManager.CreateLight("MainLight"); l.SetPosition(0.0f, 50.0f, 0.0f); l.SetSpecularColour(0.25f, 0.25f, 0.25f); l.SetDiffuseColour(0.25f, 0.25f, 0.25f); l.SetCastShadows(false); /*******/ mLog.LogMessage("CreateScene point setup groundplane"); Plane plane = new Plane(new Vector3(0, 1, 0), 0); MeshManager.GetSingleton().CreatePlane("GroundPlane", "General", plane, 150000, 150000, 10, 10, true, 1, 100, 100, Vector3.UnitZ); Entity pPlaneEnt = mSceneManager.CreateEntity("Ground", "GroundPlane"); pPlaneEnt.SetMaterialName("Examples/GrassFloor"); pPlaneEnt.SetCastShadows(false); mSceneManager.GetRootSceneNode().CreateChildSceneNode().AttachObject(pPlaneEnt); /*******/ mLog.LogMessage("CreateScene point setup sky clouds"); plane = new Plane(new Vector3(0, -1, 0), -4000); MeshManager.GetSingleton().CreatePlane("CloudsPlaneBottom", "General", plane, 150000, 150000, 10, 10, true, 1, 1, 1, Vector3.UnitZ); pPlaneEnt = mSceneManager.CreateEntity("CloudsBottom", "CloudsPlaneBottom"); pPlaneEnt.SetMaterialName("firworks/clouds01/512"); pPlaneEnt.SetCastShadows(false); mSceneManager.GetRootSceneNode().CreateChildSceneNode().AttachObject(pPlaneEnt); plane = new Plane(new Vector3(0, 1, 0), 4000); MeshManager.GetSingleton().CreatePlane("CloudsPlaneTop", "General", plane, 150000, 150000, 10, 10, true, 1, 1, 1, Vector3.UnitZ); pPlaneEnt = mSceneManager.CreateEntity("CloudsTop", "CloudsPlaneTop"); pPlaneEnt.SetMaterialName("firworks/clouds01/512"); pPlaneEnt.SetCastShadows(false); SceneNode pNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode(); pNode.AttachObject(pPlaneEnt); pNode.Yaw(180.0f); /*******/ // -1014 x -1363 /*******/ mLog.LogMessage("CreateScene point setup default fountains"); string strName = this.GetFWName(); cfirework fw = new cfirework(strName, cfirework.FWType.Fountain01, mSceneManager); fw.mNode.SetPosition(-50.0f, 1.0f, 0.0f); fw.mTimeToLive = 0; fw.mMoveable = false; mALFireworks.Add(fw); strName = this.GetFWName(); fw = new cfirework(strName, cfirework.FWType.Fountain01, mSceneManager); fw.mNode.SetPosition(50.0f, 1.0f, 0.0f); fw.mTimeToLive = 0; fw.mMoveable = false; mALFireworks.Add(fw); /******/ mtimeNext = OgreDotNet.OgreMath.RangeRandom(0.0f, 2.0f); mLog.LogMessage("CreateScene point setup camera"); mCamera.SetPosition(0.0f, 400.0f, 3000.0f); mCamera._lookAt(0.0f, 5.0f, 0.0f); mLog.LogMessage("CreateScene point call create4LineDebugOverLay"); create4LineDebugOverLay(); Show4LineDebugOverLay(); }
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); }
protected override void CreateScene() { mSceneManager.SetSkyBox(true, "Examples/CloudyNoonSkyBox"); mLog = LogManager.Singleton.createLog("DemoCustomObjects.log", false, true); mLog.LogMessage(string.Format("DemoCustomObjects log {0}", System.DateTime.Now)); create4LineDebugOverLay(); Show4LineDebugOverLay(); Entity e; SceneNode n; Plane plane = new Plane(); plane.Normal.x = 0; plane.Normal.y = 1; plane.Normal.z = 0; plane.D = 0; MeshManager.GetSingleton().CreatePlane("Myplane", "General", plane, 14500, 14500, 10, 10, true, 1, 50, 50, Vector3.UnitZ); e = mSceneManager.CreateEntity("plane", "Myplane"); e.SetMaterialName("Examples/GrassFloor"); e.SetCastShadows(false); n = mSceneManager.GetRootSceneNode().CreateChildSceneNode("Myplane"); n.AttachObject(e); //##MyLine3D test mLog.LogMessage("test line 0"); myLine = new myLine3D(); mLog.LogMessage("test line 1"); myLine.addPoint(new Vector3(0.0f, 9.6f, 0.0f)); myLine.addPoint(new Vector3(160.0f, 9.6f, 0.0f)); myLine.addPoint(new Vector3(160.0f, 9.6f, 160.0f)); myLine.addPoint(new Vector3(0.0f, 9.6f, 160.0f)); myLine.addPoint(new Vector3(0.0f, 9.6f, 0.0f)); mLog.LogMessage("test line 2"); myLine.drawLines(); mLog.LogMessage("test line 3"); n = mSceneManager.GetRootSceneNode().CreateChildSceneNode("Line1"); mLog.LogMessage("test line 4"); n.AttachObject(myLine); mLog.LogMessage("test line 5"); n.SetPosition(0.0f, 200.0f, 0.0f); //## /***/ //## bill board chain mLog.LogMessage("test BBC 1"); mBBC = new DemoCustomObjects.myBillBoardChain(mCamera, 1000); mBBC.setMaterial("DemoCustomObjects/smoketrail"); for (int i = 0; i < 500; i++) { myBillBoardChainElement ce = new myBillBoardChainElement( new Vector3((float)Math.Sin((double)i / 100.0 * 2.0 * Math.PI), (float)Math.Cos((double)i / 100.0 * 2.0 * Math.PI), (float)i / 100.0f), 0.1f, (float)i / 10.0f, Converter.GetColor(1.0f, 1.0f, 1.0f)); mBBC.addChainElement(ce); } mBBC.updateBoundingBox(); // Add it to the scene n = mSceneManager.GetRootSceneNode().CreateChildSceneNode("BBC"); n.AttachObject(mBBC); n.SetPosition(0.0f, 100.0f, 0.0f); n.SetScale(50.0f, 50.0f, 50.0f); mLog.LogMessage("test BBC 2"); //## /***/ mCamera.Move(new Vector3(0, 300, 600)); mCamera.LookAt = new Vector3(0, 0, -600); SetDebugCaption(2, "keys: Y updates and adds a new point"); SetDebugCaption(3, " U updates and deletes the new point"); }
protected override void CreateScene() { mLog = LogManager.Singleton.createLog("DemoGrass.log", false, true); mLog.LogMessage(string.Format("DemoGrass log {0}", System.DateTime.Now)); //Init waveGrass varibles xinc = OgreMath.PI * 0.4f; zinc = OgreMath.PI * 0.55f; xpos = OgreMath.RangeRandom(-OgreDotNet.OgreMath.PI, OgreDotNet.OgreMath.PI); zpos = OgreMath.RangeRandom(-OgreDotNet.OgreMath.PI, OgreDotNet.OgreMath.PI); xxoffset = new Math3D.Vector4(0.0f, 0.0f, 0.0f, 0.0f); mSceneManager.SetSkyBox(true, "Examples/SpaceSkyBox"); setupLighting(); mSceneManager.AmbientLightColor = Color.FromArgb(125, 125, 125, 125); //create a ground plain mLog.LogMessage("Point 1"); Plane plane = new Plane(); plane.Normal.x = 0; plane.Normal.y = 1; plane.Normal.z = 0; plane.D = 0; MeshManager.GetSingleton().CreatePlane("Myplane", "General", plane, 14500, 14500, 10, 10, true, 1, 50, 50, Vector3.UnitZ); Entity pPlaneEnt = mSceneManager.CreateEntity("plane", "Myplane"); pPlaneEnt.SetMaterialName("Examples/GrassFloor"); pPlaneEnt.SetCastShadows(false); mSceneManager.GetRootSceneNode().CreateChildSceneNode().AttachObject(pPlaneEnt); //create the grass mesh mLog.LogMessage("Point 2"); createGrassMesh2(); Entity e = null; e = mSceneManager.CreateEntity("1", GRASS_MESH_NAME); //close the the grass mesh in a region StaticGeometry s = mSceneManager.CreateStaticGeometry("bing"); s.setRegionDimensions(new Vector3(1000, 1000, 1000)); // Set the region origin so the centre is at 0 world s.setOrigin(new Vector3(-500, 500, -500)); mLog.LogMessage("Point 3"); for (int x = -1950; x < 1950; x += 150) //1950 { for (int z = -1950; z < 1950; z += 150) { Vector3 pos; pos.x = x + OgreMath.RangeRandom(-25, 25); pos.y = 0; pos.z = z + OgreMath.RangeRandom(-25, 25); Quaternion orientation = Quaternion.FromAngleAxis( new Degree(OgreMath.RangeRandom(0, 359)).ValueDegrees(), Vector3.UnitY); Vector3 scale = new Vector3(1, OgreMath.RangeRandom(0.85f, 1.15f), 1); s.addEntity(e, pos, orientation, scale); } } mLog.LogMessage("Point 4"); s.build(); mStaticGeom = s; //mStaticGeom.dump("Grass.SG.Dump.txt"); //Put an Ogre head in the middle mLog.LogMessage("Point 5"); OgreDotNet.MeshPtr m = MeshManager.GetSingleton().Load("ogrehead.mesh", "General"); Mesh mm = m.Get(); UInt16 src = 0, dest = 0; if (!mm.SuggestTangentVectorBuildParams(ref src, ref dest)) { mLog.LogMessage("got from SuggestTangentVectorBuildParams src=" + src + " dest=" + dest); mm.BuildTangentVectors(src, dest); } e = mSceneManager.CreateEntity("head", "ogrehead.mesh"); e.SetMaterialName("Examples/OffsetMapping/Specular"); SceneNode headNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode(); headNode.AttachObject(e); headNode.SetScale(7, 7, 7); headNode.SetPosition(0, 200, 0); e.SetNormaliseNormals(true); mLog.LogMessage("Point 6"); //setup camera position mCamera.Move(new Vector3(0, 350, 800)); mCamera.LookAt = new Vector3(0, 200, 0); mLog.LogMessage("Point end"); }
/*** test ***/ protected override void CreateScene() { mSceneManager.SetSkyBox(true, "Examples/CloudyNoonSkyBox"); mLog = LogManager.Singleton.createLog("RSQTest.log", false, true); mLog.LogMessage(string.Format("RSQTest log {0}", System.DateTime.Now)); create4LineDebugOverLay(); Show4LineDebugOverLay(); Entity e; SceneNode n; Plane plane = new Plane(); plane.Normal.x = 0.0f; plane.Normal.y = 1.0f; plane.Normal.z = 0.0f; plane.D = 0.0f; MeshManager.GetSingleton().CreatePlane("Myplane01", "General", plane, 250.0f, 500.0f, 10, 10, true, 1, 5.0f, 5.0f, Vector3.UnitZ); e = mSceneManager.CreateEntity("plane01", "Myplane01"); e.SetMaterialName("Examples/GrassFloor"); e.SetCastShadows(false); n = mSceneManager.GetRootSceneNode().CreateChildSceneNode(); n.SetPosition(-125.0f, 10.0f, 0.0f); n.Pitch(new Radian(new Degree(5.0f))); n.AttachObject(e); plane.Normal.x = 0.0f; plane.Normal.y = 1.0f; plane.Normal.z = 0.0f; plane.D = 0.0f; MeshManager.GetSingleton().CreatePlane("Myplane02", "General", plane, 250.0f, 500.0f, 10, 10, true, 1, 5.0f, 5.0f, Vector3.UnitZ); e = mSceneManager.CreateEntity("plane02", "Myplane02"); e.SetMaterialName("Examples/GrassFloor"); e.SetCastShadows(false); n = mSceneManager.GetRootSceneNode().CreateChildSceneNode(); n.SetPosition(125.0f, 10.0f, 0.0f); n.AttachObject(e); for (int x = 0; x < 4; x++) { string sname = string.Format("head{0}", x); e = mSceneManager.CreateEntity(sname, "ogrehead.mesh"); n = mSceneManager.GetRootSceneNode().CreateChildSceneNode(sname); n.AttachObject(e); float px = (x % 2 == 0? -100.0f: 100.0f); float pz = ((x <= 1)? -100.0f: 100.0f); float py = (x % 2 == 0? 50.0f : 30.0f); n.SetPosition(px, py, pz); } mRay = new OgreDotNet.Ray(Vector3.Zero, Vector3.NegativeUnitY); mRaySceneQuery = mSceneManager.CreateRayQuery(mRay); mCamera.Move(new Vector3(0, 300, 600)); mCamera.LookAt = new Vector3(0, 0, 0); /*** test ***/ myLine = new Line3D(); myLine.addPoint(new Vector3(0.0f, 9.6f, 0.0f)); myLine.addPoint(new Vector3(160.0f, 9.6f, 0.0f)); myLine.addPoint(new Vector3(160.0f, 9.6f, 160.0f)); myLine.addPoint(new Vector3(0.0f, 9.6f, 160.0f)); myLine.addPoint(new Vector3(0.0f, 9.6f, 0.0f)); myLine.drawLines(); SceneNode myNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode("Line1"); myNode.AttachObject(myLine); myNode.SetPosition(0.0f, 200.0f, 0.0f); /*** test ***/ }