/// <summary> /// This method creates 4000 quads and attaches them to the scenegraph as static geometry /// </summary> public void StaticGeometry() { Quad(); staticGeo = mSceneMgr.CreateStaticGeometry("staticQuads"); // Initializes the static geometry container for (int i = 0; i < 200; i++) { for (int j = 0; j < 200; j++) { manualObjEntity = mSceneMgr.CreateEntity("Quad"); // Loads the quad in an entity staticGeo.AddEntity(manualObjEntity, new Vector3(i * 5, j * 5, 0)); // adds it to the scenegraph as static geo } } staticGeo.Build(); // Prepares the static geometry to be rendered }
public void StaticGeometry() { Quad(); staticGeometry = mSceneMgr.CreateStaticGeometry("staticQuads"); for (int i = 0; i < 200; i++) { for (int j = 0; j < 200; j++) { cubeEntity = mSceneMgr.CreateEntity("Quad"); staticGeometry.AddEntity(cubeEntity, new Vector3(i * 5, j * 5, 0)); } } staticGeometry.Build(); }
/// <summary> /// This method creates 4000 quads and attaches them to the scenegraph as static geometry /// </summary> public void StaticGeometry() { Quad(); staticGeo = mSceneMgr.CreateStaticGeometry("staticQuads"); // Initializes the static geometry container for(int i=0; i<200; i++) for (int j = 0; j < 200; j++) { manualObjEntity = mSceneMgr.CreateEntity("Quad"); // Loads the quad in an entity staticGeo.AddEntity(manualObjEntity, new Vector3(i * 5, j * 5, 0)); // adds it to the scenegraph as static geo } staticGeo.Build(); // Prepares the static geometry to be rendered }
/// <summary> /// initialize the scene /// </summary> private void InitializeScene() { //create scene mgr sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC); // Every viewport has a camera associated with it. // The second number is a z-order. Higher z-order viewports // are rendered on top (in the case of multiple viewports). Camera cam = sceneMgr.CreateCamera("cam"); root.AutoCreatedWindow.AddViewport(cam, 0); Viewport vp = root.AutoCreatedWindow.GetViewport(0); vp.BackgroundColour = ColourValue.Black; // have the frustum set the aspect ratio automatically cam.AutoAspectRatio = true; Vector3 position = new Vector3(0.0f, 0.0f, 0.0f); Quaternion orientation = Quaternion.IDENTITY; // In Ogre, an entity is a renderable object. An entity must be attached // to a scene node, however, in order to be rendered. Every entity (really, // every object in Ogre) must be assigned a unique name. shipCam = new ArcballCamera(cam); shipCam.Radius = 250.0f; shipCam.Target = sceneMgr.RootSceneNode; Light l = sceneMgr.CreateLight("point1"); l.DiffuseColour = new ColourValue(1.0f, 1.0f, 1.0f); l.Position = Vector3.UNIT_Y * 100.0f; l.CastShadows = true; l.Type = Light.LightTypes.LT_POINT; sceneMgr.SetSkyBox(true, "Space", 5000); grid = sceneMgr.CreateStaticGeometry("grid"); float radius = 100.0f; Entity cube; const int NUM_CUBES_HALF_WIDTH = 2; for (int i = -NUM_CUBES_HALF_WIDTH; i < NUM_CUBES_HALF_WIDTH; ++i) { for (int j = -NUM_CUBES_HALF_WIDTH; j < NUM_CUBES_HALF_WIDTH; ++j) { for (int k = -NUM_CUBES_HALF_WIDTH; k < NUM_CUBES_HALF_WIDTH; ++k) { if (i != 0) { cube = sceneMgr.CreateEntity("cube-" + i + "-" + j + "-" + k, SceneManager.PrefabType.PT_CUBE); grid.AddEntity(cube, new Vector3(i, j, k) * radius * 10); } } } } grid.Build(); shipMgr = new ShipManager(this); }
/// <summary> /// initialize the scene /// </summary> private void InitializeScene() { //create scene mgr sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC); // Every viewport has a camera associated with it. // The second number is a z-order. Higher z-order viewports // are rendered on top (in the case of multiple viewports). Camera cam = sceneMgr.CreateCamera("cam"); root.AutoCreatedWindow.AddViewport(cam, 0); Viewport vp = root.AutoCreatedWindow.GetViewport(0); vp.BackgroundColour = ColourValue.Black; // have the frustum set the aspect ratio automatically cam.AutoAspectRatio = true; Vector3 position = new Vector3(0.0f, 0.0f, 0.0f); Quaternion orientation = Quaternion.IDENTITY; // In Ogre, an entity is a renderable object. An entity must be attached // to a scene node, however, in order to be rendered. Every entity (really, // every object in Ogre) must be assigned a unique name. shipCam = new ArcballCamera(cam); shipCam.Radius = 250.0f; shipCam.Target = sceneMgr.RootSceneNode; Light l = sceneMgr.CreateLight("point1"); l.DiffuseColour = new ColourValue(1.0f, 1.0f, 1.0f); l.Position = Vector3.UNIT_Y * 100.0f; l.CastShadows = true; l.Type = Light.LightTypes.LT_POINT; sceneMgr.SetSkyBox(true, "Space", 5000); grid = sceneMgr.CreateStaticGeometry("grid"); float radius = 100.0f; Entity cube; const int NUM_CUBES_HALF_WIDTH = 2; for (int i = -NUM_CUBES_HALF_WIDTH; i < NUM_CUBES_HALF_WIDTH; ++i) for (int j = -NUM_CUBES_HALF_WIDTH; j < NUM_CUBES_HALF_WIDTH; ++j) for (int k = -NUM_CUBES_HALF_WIDTH; k < NUM_CUBES_HALF_WIDTH; ++k) { if (i != 0) { cube = sceneMgr.CreateEntity("cube-" + i + "-" + j + "-" + k, SceneManager.PrefabType.PT_CUBE); grid.AddEntity(cube, new Vector3(i, j, k) * radius * 10); } } grid.Build(); shipMgr = new ShipManager(this); }
public void CreateScene() { scene.SetSkyBox(true, "Examples/SpaceSkyBox"); SetupLighting(); Plane plane = new Plane(); plane.normal = Vector3.UNIT_Y; plane.d = 0; MeshManager.Singleton.CreatePlane("MyPlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, 14500, 14500, 10, 10, true, 1, 50, 50, Vector3.UNIT_Z); Entity planeEnt = scene.CreateEntity("plane", "MyPlane"); planeEnt.SetMaterialName("Examples/GrassFloor"); planeEnt.CastShadows = false; scene.RootSceneNode.CreateChildSceneNode().AttachObject(planeEnt); Vector3 minV = new Vector3(-2000, 0, -2000); Vector3 maxV = new Vector3(2000, 0, 2000); CreateGrassMesh(); Entity e = scene.CreateEntity("1", GRASS_MESH_NAME); StaticGeometry s = scene.CreateStaticGeometry("bing");//, 1); s.RegionDimensions = new Vector3(1000, 1000, 1000); s.Origin = new Vector3(-500, 500, -500); //Set the region origin so the centre is at 0 world for (int x = -1950; x < 1950; x += 150) { for (int z = -1950; z < 1950; z += 150) { Vector3 pos = new Vector3(x + Math.RangeRandom(-25, 25), 0, z + Math.RangeRandom(-25, 25)); Quaternion orientation = new Quaternion(); orientation.FromAngleAxis(Math.RangeRandom(0, 359), Vector3.UNIT_Y); Vector3 scale = new Vector3(1, Math.RangeRandom(0.85f, 1.15f), 1); s.AddEntity(e, pos, orientation, scale); } } s.Build(); StaticGeom = s; //Mesh mesh = MeshManager.Singleton.Load("ogrehead.mesh", ResourceGroupManager.DefaultResourceGroupName); //short src, dest; //if (!mesh.SuggestTangentVectorBuildParams( VertexElementSemantic.VES_POSITION, out src, out dest)) { // mesh.BuildTangentVectors( VertexElementSemantic.VES_POSITION,src, dest); //} //e = scene.CreateEntity("head", "ogrehead.mesh"); //e.SetMaterialName("Examples/OffsetMapping/Specular"); //HeadNode = scene.RootSceneNode.CreateChildSceneNode(); //HeadNode.AttachObject(e); //HeadNode.Scale = new Vector3(7, 7, 7); //HeadNode.Position = new Vector3(0, 200, 0); //if (e.GetSubEntity(0).NormalizeNormals == false) { // LogManager.Singleton.LogMessage("aie aie aie"); //} Root.Singleton.RenderSystem.SetNormaliseNormals(true); //camera.Move(new Vector3(0, 350, 0)); }