private void InitializeNode() { _entity = _parentSceneManager.CreateEntity(_name, _meshName); _node = _parentNode.CreateChildSceneNode(_nodeName); _node.AttachObject(_entity); }
public void StartBackground(string value, params object[] param) { var sceneManager = param[0] as SceneManager; MaterialManager.Singleton.Remove("Background"); MaterialPtr material = MaterialManager.Singleton.Create("Background", "General"); material.GetTechnique(0).GetPass(0).CreateTextureUnitState(value); material.GetTechnique(0).GetPass(0).DepthCheckEnabled = false; material.GetTechnique(0).GetPass(0).DepthWriteEnabled = false; material.GetTechnique(0).GetPass(0).LightingEnabled = false; Rectangle2D rect = new Rectangle2D(true); rect.SetCorners(-1.0f, 1.0f, 1.0f, -1.0f); rect.SetMaterial("Background"); rect.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_BACKGROUND; AxisAlignedBox aab = new AxisAlignedBox(); aab.SetInfinite(); rect.BoundingBox = aab; SceneNode node = sceneManager.RootSceneNode.CreateChildSceneNode(Guid.NewGuid().ToString()); node.AttachObject(rect); }
protected void setupVideo() { mCubeSceneNode = mSceneManager.RootSceneNode.CreateChildSceneNode("CubeNode", new Vector3(0f, 0f, 0f)); // Create knot objects so we can see movement // mCubeEntity = mSceneManager.CreateEntity("CubeShape", SceneManager.PrefabType.PT_CUBE); mCubeEntity = mSceneManager.CreateEntity("CubeShape", SceneManager.PrefabType.PT_PLANE); mCubeSceneNode.AttachObject(mCubeEntity); mCubeSceneNode.Scale(1.5f, 1.5f, 1.5f); mvideoWidth = 1024; mvideoHeight = 768; setTextureDimensions(false); setupVideoGraphicsObject(); Thread lRenderVideoThread = new Thread(new ThreadStart(renderVideoThread)); lRenderVideoThread.Start(); cam = new Capture(Configuration.getConfiguration().TrainingVideoFile, "Test String", mParentWindow, false, new VideoUserOptions(), null); cam.VideoBufferReceivedEvent += new Capture.OnVideoBufferReceivedEvent(OnVideoBufferReceivedEvent); cam.Start(); }
/// <summary> /// /// </summary> /// <param name="sceneMgr"></param> private void SetupBody(SceneManager sceneMgr) { // create main model bodyNode = sceneMgr.RootSceneNode.CreateChildSceneNode(Axiom.Math.Vector3.UnitY * CharHeight); bodyEnt = sceneMgr.CreateEntity("SinbadBody", "Sinbad.mesh"); bodyNode.AttachObject(bodyEnt); // create swords and attach to sheath sword1 = sceneMgr.CreateEntity("SinbadSword1", "Sword.mesh"); sword2 = sceneMgr.CreateEntity("SinbadSword2", "Sword.mesh"); bodyEnt.AttachObjectToBone("Sheath.L", sword1); bodyEnt.AttachObjectToBone("Sheath.R", sword2); // create a couple of ribbon trails for the swords, just for fun NamedParameterList paras = new NamedParameterList(); paras["numberOfChains"] = "2"; paras["maxElements"] = "80"; swordTrail = (RibbonTrail)sceneMgr.CreateMovableObject("SinbadRibbon", "RibbonTrail", paras); swordTrail.MaterialName = "Examples/LightRibbonTrail"; swordTrail.TrailLength = 20; swordTrail.IsVisible = false; sceneMgr.RootSceneNode.AttachObject(swordTrail); for (int i = 0; i < 2; i++) { swordTrail.SetInitialColor(i, new ColorEx(1, 0.8f, 0)); swordTrail.SetColorChange(i, new ColorEx(0.75f, 0.25f, 0.25f, 0.25f)); swordTrail.SetWidthChange(i, 1); swordTrail.SetInitialWidth(i, 0.5f); } keyDirection = Axiom.Math.Vector3.Zero; verticalVelocity = 0; }
public void CreateScene(SceneManager sm) { sun = sm.CreateLight("Sun"); sun.Type = Light.LightTypes.LT_POINT; sun.Position = new Vector3(0, 1000, 100); sun.Direction = new Vector3(0, -1, 0.5f); sun.DiffuseColour = new ColourValue(0.98f, 0.95f, 0.9f); sun.SpecularColour = ColourValue.White; sun.CastShadows = true; sun.PowerScale = 5.0f; ambient = sm.CreateLight("ambient"); ambient.Type = Light.LightTypes.LT_DIRECTIONAL; ambient.Position = new Vector3(0, 2000, 0); ambient.Direction = new Vector3(0, -1, 0); ambient.DiffuseColour = new ColourValue(0.01f, 0.05f, 0.1f); ambient.SpecularColour = ColourValue.Black; ambient.CastShadows = false; sm.RootSceneNode.AttachObject(sun); sm.RootSceneNode.AttachObject(ambient); rainSystem = sm.CreateParticleSystem("Rain", "Weather/Rain"); particleNode = sm.GetSceneNode("focalPoint").CreateChildSceneNode("Weather"); particleNode.AttachObject(rainSystem); particleNode.Translate(new Vector3(0, 600, 0)); }
protected override void CreateScene() { viewport.BackgroundColor = ColorEx.White; scene.AmbientLight = new ColorEx(0.5f, 0.5f, 0.5f); Light light = scene.CreateLight("MainLight"); light.Position = new Vector3(20, 80, 50); light.Diffuse = ColorEx.Blue; scene.LoadWorldGeometry("Terrain.xml"); scene.SetFog(FogMode.Exp2, ColorEx.White, .008f, 0, 250); // water plane setup Plane waterPlane = new Plane(Vector3.UnitY, 1.5f); MeshManager.Instance.CreatePlane( "WaterPlane", waterPlane, 2800, 2800, 20, 20, true, 1, 10, 10, Vector3.UnitZ); Entity waterEntity = scene.CreateEntity("Water", "WaterPlane"); waterEntity.MaterialName = "Terrain/WaterPlane"; waterNode = scene.RootSceneNode.CreateChildSceneNode("WaterNode"); waterNode.AttachObject(waterEntity); waterNode.Translate(new Vector3(1000, 0, 1000)); }
public override void CreateScene() { // Set ambient light and fog sceneMgr.AmbientLight = new ColourValue(0, 0, 0); sceneMgr.SetFog(FogMode.FOG_LINEAR, skyColor, 0, 150, 300); // Create sun-light Light light = sceneMgr.CreateLight("Sun"); light.Type = Light.LightTypes.LT_POINT; light.Position = new Vector3(150, 100, 150); sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE; sceneMgr.ShadowFarDistance = 100; sceneMgr.ShadowColour = new ColourValue(0.7f, 0.7f, 0.7f); sceneMgr.SetShadowTextureSize(512); // Ground Plane ground = new Plane(Vector3.UNIT_Y, 1); MeshManager.Singleton.CreatePlane("groundPlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, ground, 500, 500, 20, 20, true, 1, 1, 1, Vector3.UNIT_Z); Entity groundEnt = sceneMgr.CreateEntity("groundPlaneEntity", "groundPlane"); groundEnt.CastShadows = true; groundEnt.SetMaterialName("BoxMaterial/Ground"); planeNode = sceneMgr.RootSceneNode.CreateChildSceneNode(); planeNode.AttachObject(groundEnt); physics = new Physics(sceneMgr); }
public WayPoint() { _Orientation = Quaternion.IDENTITY; _DisplayNameOffset = new Vector3(0, 0.2f, 0); Entity = Engine.Singleton.SceneManager.CreateEntity("Spawn.mesh"); Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode(); Node.AttachObject(Entity); ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld, Node, Quaternion.IDENTITY, 0.1f, Engine.Singleton.GetUniqueBodyId()); Vector3 inertia, offset; collision.CalculateInertialMatrix(out inertia, out offset); Inertia = inertia; Body = new Body(Engine.Singleton.NewtonWorld, collision, true); Body.AttachNode(Node); Body.SetMassMatrix(0, inertia * 0); Body.ForceCallback += BodyForceCallback; Body.UserData = this; Body.MaterialGroupID = Engine.Singleton.MaterialManager.WaypointMaterialID; //Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID; collision.Dispose(); }
public MovableText(string name, SceneManager sceneMgr, SceneNode node, Size size) { this.texture = TextureManager.Singleton.CreateManual( name + "Texture", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, (uint)size.Width, (uint)size.Height, 0, PixelFormat.PF_A8R8G8B8); this.material = MaterialManager.Singleton.Create(name + "Material", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); this.material.GetTechnique(0).GetPass(0).CreateTextureUnitState(this.texture.Name); this.material.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA); this.material.SetDepthCheckEnabled(false); this.billboardSet = sceneMgr.CreateBillboardSet(); this.billboardSet.SetMaterialName(this.material.Name); this.billboardSet.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY; this.billboard = this.billboardSet.CreateBillboard(Vector3.ZERO); this.billboard.SetDimensions(size.Width, size.Height); this.billboard.Colour = ColourValue.ZERO; node.AttachObject(this.billboardSet); this.sceneMgr = sceneMgr; this.size = size; }
/************************************************************************/ /* create a simple object just consisting of a scenenode with a mesh */ /************************************************************************/ internal SceneNode CreateSimpleObject(string _name, string _mesh) { // if scene manager already has an object with the requested name, fail to create it again if (mSceneMgr.HasEntity(_name) || mSceneMgr.HasSceneNode(_name)) { return(null); } // create entity and scenenode for the object Entity entity; try { // try to create entity from mesh entity = mSceneMgr.CreateEntity(_name, _mesh); } catch { // failed to create entity return(null); } // add entity to scenenode SceneNode node = mSceneMgr.CreateSceneNode(_name); // connect entity to the scenenode node.AttachObject(entity); // return the created object return(node); }
public override void CreateScene() { Vector4 green = new Vector4(0.0f, 1.0f, 0.0f, 1.0f); Vector4 red = new Vector4(1.0f, 0.0f, 0.0f, 1.0f); Lines3Dv2 lines3d = new Lines3Dv2(); lines3d.AddPoint(-10, 10, 0); lines3d.AddPoint(0, 5, 0); lines3d.AddPoint(8, 3, 0); lines3d.AddPoint(0, 10, 0); SceneNode node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Lines3DNode_1"); node1.AttachObject(lines3d.CreateNode("Lines3d_1", base.sceneMgr, true, 1, green)); Lines3Dv2 lines3d_2 = new Lines3Dv2(); lines3d_2.AddPoint(3, 3, 0); lines3d_2.AddPoint(8, 8, 0); lines3d_2.AddPoint(3 + 5, 3, 0); lines3d_2.AddPoint(5, 3, 0); SceneNode node2 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Lines3DNode_2"); node2.AttachObject(lines3d_2.CreateNode("Lines3d_2", base.sceneMgr, false, 1, red)); }
public void CreateScene() { //ManualObject manual = _root.SceneManager.CreateManualObject("TEST"); _entity = _root.SceneManager.CreateEntity("CubeBrowser", PrefabEntity.Cube); _sceneNode = Root.Instance.SceneManager.RootSceneNode.CreateChildSceneNode(); _sceneNode.AttachObject(_entity); //_sceneNode.Yaw(45); _sceneNode.Position = new Vector3(0, 0, -300); _sceneNode.Scale = new Vector3(5, 4, 4); TextureUtil.CreateDynamicTextureAndMaterial( "CBDynamicTexture", "CBDynamicMaterial", _browserWidth, _browserHeight, out _texture, out _material); _entity.MaterialName = "CBDynamicMaterial"; Core.BrowserManager.BrowserRenderEvent += new BrowserRenderEventHandler(BrowserManager_BrowserRenderEvent); _browserId = Core.BrowserManager.CreateBrowser("http://www.google.com.au", _browserWidth, _browserHeight); CreateOverlay(); }
/// <summary> // The material is attached to the powerup mesh. The model is positioned randomly in the scene and PhysObj attached here /// </summary> protected override void LoadModel() //The class should override the LoadModel method from PowerUp { //load the geometry for the power up and the scene graph nodes base.LoadModel(); shieldPickUpEntity = mSceneMgr.CreateEntity("shield.mesh"); //timePickUpEntity.SetMaterialName("HeartHMD"); shieldPickUpEntity.SetMaterialName("shieldPickup"); shieldPickUpNode = mSceneMgr.CreateSceneNode(); shieldPickUpNode.Scale(new Vector3(0.1f, 0.1f, 0.1f)); shieldPickUpNode.SetPosition(Mogre.Math.RangeRandom(-450, 450), 150, Mogre.Math.RangeRandom(-450, 450)); shieldPickUpNode.Position -= new Vector3(0f, -8f, 0f); shieldPickUpNode.AttachObject(shieldPickUpEntity); mSceneMgr.RootSceneNode.AddChild(shieldPickUpNode); shieldPickUpEntity.GetMesh().BuildEdgeList(); physObj = new PhysObj(9f, "ShieldPickUp", 0.1f, 0.3f, 20f); physObj.SceneNode = shieldPickUpNode; physObj.Position = shieldPickUpNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); }
public void DisplayIndicator() { wasDisplayed = true; if (!EngineConfig.DisplayingMinimap) { return; } hudOverlay = OverlayManager.Singleton.GetByName("Wof/HUD"); // HUD hud = sceneMgr.CreateEntity("HUD", "HUD.mesh"); hud.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY; hudNode = new SceneNode(sceneMgr); hudNode.SetScale(UnitConverter.xscale(viewport) * 0.01505f, 0.0155f, 0.01f); hudNode.AttachObject(hud); hudNode.Position = new Vector3(-0.01f, -0.408f, -1f); hudNode.GetMaterial().SetDepthCheckEnabled(false); // ARROW fuelArrow = sceneMgr.CreateEntity("FuelArrow", "Arrow.mesh"); fuelArrow.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY; fuelArrowNode = new SceneNode(sceneMgr); fuelArrowNode.SetScale(0.16f, 0.16f, 0.16f); fuelArrowNode.AttachObject(fuelArrow); fuelArrowNode.Position = new Vector3(UnitConverter.xscale(viewport) * -0.214f, -0.255f, -0.7f); fuelArrowNode.GetMaterial().SetDepthCheckEnabled(false); // ARROW oilArrow = sceneMgr.CreateEntity("OilArrow", "Arrow.mesh"); oilArrow.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY; oilArrowNode = new SceneNode(sceneMgr); oilArrowNode.SetScale(0.16f, 0.16f, 0.16f); oilArrowNode.AttachObject(oilArrow); oilArrowNode.Position = new Vector3(UnitConverter.xscale(viewport) * 0.214f, -0.255f, -0.7f); oilArrowNode.GetMaterial().SetDepthCheckEnabled(false); hudOverlay.Add3D(fuelArrowNode); hudOverlay.Add3D(oilArrowNode); hudOverlay.Add3D(hudNode); hudOverlay.ZOrder = 1; hudOverlay.Show(); CreateAmmoContainer(); CreateAmmoTypeContainer(); CreateLivesContainer(); CreateScoreContainer(); CreateHighscoreContainer(); CreateInfoContainer(); UpdateWheelState(gameScreen.CurrentLevel.UserPlane.WheelsState); }
public Entity ConnectTwoVertex(Vector3 vertexPos1, Vector3 vertexPos2) { Vector3 vect = vertexPos1 - vertexPos2; Vector3 edgePos = new Vector3( (vertexPos1.x - vertexPos2.x) / 2, (vertexPos1.y - vertexPos2.y) / 2, (vertexPos1.z - vertexPos2.z) / 2 ); Entity visualAIMeshLineEnt = scm.CreateEntity("AIMESH_LINE_ENT_" + aimesh.AIMeshEdges.Count, "marker_line.mesh"); SceneNode visualAIMeshLineSceneNode = scm.RootSceneNode.CreateChildSceneNode("AIMESH_LINE_SCENENODE_" + aimesh.AIMeshEdges.Count); visualAIMeshLineSceneNode.AttachObject(visualAIMeshLineEnt); visualAIMeshLineSceneNode.Position = edgePos; Quaternion oritentation = visualAIMeshLineSceneNode.Orientation; Vector3 vect2 = oritentation * Vector3.UNIT_Z; Vector3 axis = vect.CrossProduct(vect2); vect.Normalise(); vect2.Normalise(); Radian angle = Mogre.Math.ACos(vect.DotProduct(vect2)); Quaternion rotate = new Quaternion(angle, axis); visualAIMeshLineSceneNode.Rotate(rotate); return(visualAIMeshLineEnt); }
public SceneNode Create(SceneManager sceneManager) { ent = sceneManager.CreateEntity("VEHICLE-" + vehicle.Name + "-TURRENT-" + Guid.NewGuid().ToString()); entNode = vehicle.Mesh.EntityNode.CreateChildSceneNode(); entNode.AttachObject(ent); return(entNode); }
private float _timeSinceLastFrameLastUpdate; // Time value passed to the last call of the method "Update" #endregion Fields #region Constructors public CameraControlSystem(SceneManager sceneManager, string name, Camera camera = null, bool reCalcOnTargetMoving = true) { _sceneMgr = sceneManager; _name = name; _targetNode = null; _targetNodeListener = null; _recalcOnTargetMoving = reCalcOnTargetMoving; _currentCameraMode = null; _cameraNode = _sceneMgr.RootSceneNode.CreateChildSceneNode(_name + "SceneNode"); if (camera == null) { _camera = _sceneMgr.CreateCamera(_name); _isOwnCamera = true; } else { _camera = camera; _isOwnCamera = false; } //Reset to default parameters _camera.Position = Vector3.ZERO; _camera.Orientation = Quaternion.IDENTITY; // ... and attach the Ogre camera to the camera node _cameraNode.AttachObject(_camera); _cameraModes = new Dictionary<string, CameraMode>(); }
/// <summary> /// This method initializes the ground mesh and its node /// </summary> private void CreateGround() { GroundPlane(); groundNode = mSceneMgr.CreateSceneNode(); groundNode.AttachObject(groundEntity); mSceneMgr.RootSceneNode.AddChild(groundNode); }
/// <summary> /// Create character body /// </summary> /// <returns>success return True, fail return False</returns> private bool setupBody(Mogre.Vector3 initPosition) { try { if (!string.IsNullOrEmpty(charaMeshName)) { bodyNode = sceneMgr.RootSceneNode.CreateChildSceneNode(Mogre.Vector3.UNIT_Y * CHAR_HEIGHT * initPosition.y); bodyEnt = sceneMgr.CreateEntity(Guid.NewGuid().ToString(), charaMeshName); bodyNode.AttachObject(bodyEnt); bodyNode.SetPosition(initPosition.x, bodyNode.Position.y, initPosition.z); keyDirection = Mogre.Vector3.ZERO; verticalVelocity = 0; lastPosition = initPosition; return(true); } else { return(false); } } catch (Exception ex) { GameManager.Instance.log.LogMessage("Engine Error: " + ex.Message); return(false); } }
public override void CreateScene() { const uint constantColor = 123; SceneNode node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial03Node1"); SceneNode node2 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial03Node2"); ManualObject manualObj1 = sceneMgr.CreateManualObject("Tutorial03Object1"); ManualObject manualObj2 = sceneMgr.CreateManualObject("Tutorial03Object2"); /* star outer inner */ /* x y Points radius radius */ /* ===== ===== ====== ====== ====== */ ManualObject.ManualObjectSection objSection; objSection = DrawStar(manualObj1, -10.0f, -10.0f, 5, 50.0f, 20.0f); objSection.SetCustomParameter(constantColor, new Vector4(0.0f, 1.0f, 0.0f, 1.0f));// Green objSection = DrawStar(manualObj2, 94.0f, 10.0f, 5, 50.0f, 20.0f); objSection.SetCustomParameter(constantColor, new Vector4(1.0f, 0.0f, 0.0f, 1.0f)); // Red node1.AttachObject(manualObj1); node2.AttachObject(manualObj2); MovableText text1 = new MovableText("text1", this.sceneMgr, node1, new Size(128, 32)); text1.SetText("Node 1!", new System.Drawing.Font(FontFamily.GenericSansSerif, 16, FontStyle.Regular, GraphicsUnit.Pixel), Color.Green); text1.Offset = new Vector3(-10.0f + 25f, -10.0f + 25f, 5.0f); MovableText text2 = new MovableText("text2", this.sceneMgr, node2, new Size(128, 32)); text2.SetText("Node 2!", new System.Drawing.Font(FontFamily.GenericSerif, 16, FontStyle.Regular, GraphicsUnit.Pixel), Color.Red); text2.Offset = new Vector3(94.0f + 25f, 10.0f + 25f, 5.0f); }
public override void CreateScene() { SceneNode node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial01Node"); theObj = CreateNode("Tutorial01Object", base.sceneMgr, false); node1.AttachObject(theObj); }
private void AddCube() { double d = 0.1 + 0.2 * rnd.NextDouble(); Mogre.Vector3 pos = new Mogre.Vector3((float)(-10 * d), (float)d, 0);; for (int j = 0; j < 10; j++) { float tempy = pos.y; pos.x += 2 * (float)(d - physx.Parameters.SkinWidth); pos.z += 1f * (float)(d + physx.Parameters.SkinWidth); for (int i = 0; i < 1 + j; i++) { var ad = new ActorDesc(new BodyDesc(), 10, new BoxShapeDesc(new Mogre.Vector3((float)d, (float)d, (float)d))); ad.GlobalPosition = new Mogre.Vector3(pos.x, pos.y, pos.z); pos.y += 2 * (float)(d - physx.Parameters.SkinWidth); var a = scene.CreateActor(ad); cubeActors.Add(a); string id = "MaunalObject_" + Guid.NewGuid().ToString(); string cubeName = "CUSTOME_CUBE_" + Guid.NewGuid().ToString(); createCube(cubeName, ad.GlobalPosition, d); Entity mo = m_pSceneMgr.CreateEntity(id, cubeName); SceneNode moSceneNode = m_pSceneMgr.RootSceneNode.CreateChildSceneNode(); moSceneNode.AttachObject(mo); cubes.Add(mo); } pos.y = tempy; } return; }
void CreateExtraLights() { _lightRootNode = _sceneManager.RootSceneNode.CreateChildSceneNode(); //Create 7 more lights for (var i = 0; i < 7; ++i) { SceneNode lightNode = _lightRootNode.CreateChildSceneNode(); Light light = _sceneManager.CreateLight(); light.Name = "Extra Point Light"; lightNode.AttachObject(light); light.Type = Light.LightTypes.LT_POINT; light.SetAttenuation(1000.0f, 1.0f, 0.0f, 1.0f); light.SetDiffuseColour( _randomizer.Next(255) / 255.0f * 0.25f, _randomizer.Next(255) / 255.0f * 0.25f, _randomizer.Next(255) / 255.0f * 0.25f); lightNode.Position = new Vector3( ((float)_randomizer.NextDouble() * 2.0f - 1.0f) * 60.0f, ((float)_randomizer.NextDouble() * 2.0f - 1.0f) * 10.0f, ((float)_randomizer.NextDouble() * 2.0f - 1.0f) * 60.0f); } }
private void Load() { gemEntity = mSceneMgr.CreateEntity("gem.Mesh"); gemNode = mSceneMgr.CreateSceneNode(); gemNode.AttachObject(gemEntity); mSceneMgr.RootSceneNode.AddChild(gemNode); }
private void start_pu() { //puSystem = new MParticleUniverse.ParticleSystem("RedStar", "Spatial/RedStar"); //puSystem = MParticleUniverse.ParticleSystem.CreateParticleSystem("RedStar", "Spatial/RedStar"); //puSystem.SetSceneManager(mgr); puSystem = puManager.CreateParticleSystem("RedStar", "Spatial/RedStar", mgr); //Flare/mp_sun puScene = mgr.RootSceneNode.CreateChildSceneNode("puScene"); puScene.AttachObject(puSystem); puSystem.KeepLocal = true; Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); puSystem.Scale = scale; puSystem.Start(); //MParticleUniverse.ParticleSystem puCenterSystem = puManager.CreateParticleSystem("RedStarLocal", "Spatial/RedStar", mgr); //Flare/mp_sun //SceneNode puCenterScene = mgr.RootSceneNode.CreateChildSceneNode("puCenterScene"); //puCenterScene.AttachObject(puCenterSystem); //puCenterSystem.IsKeepLocal = true; //puCenterSystem.Start(); MParticleUniverse.ParticleSystem pump_starfieldSystem = puManager.CreateParticleSystem("mp_starfield", "Flare/mp_starfield", mgr); SceneNode pump_starfieldScene = mgr.RootSceneNode.CreateChildSceneNode("pump_starfieldScene"); pump_starfieldScene.AttachObject(pump_starfieldSystem); pump_starfieldSystem.Start(); }
public SmoothCamera(String pName, SceneManager pSceneManager, MovingObject pTarget, Int32 pFramesBehind) : base(pName, pSceneManager) { Node = pSceneManager.RootSceneNode.CreateChildSceneNode(); Node.Position = cameraOffset; Node.AttachObject(this); x = new List <double>(pFramesBehind); y = new List <double>(pFramesBehind); dx = new List <double>(pFramesBehind); dy = new List <double>(pFramesBehind); framesBehind = Math.Max(1, pFramesBehind); target = pTarget; for (var i = 0; i < pFramesBehind; i++) { x.Add(pTarget.Position.x); y.Add(pTarget.Position.y); dx.Add(0); dy.Add(0); } x.Insert(0, pTarget.Position.x); y.Insert(0, pTarget.Position.y); dx.Insert(0, pTarget.Velocity.x); dy.Insert(0, pTarget.Velocity.y); isYawFixed = true; FixedYawAxis = Vector3.UnitZ; Near = 5; AutoAspectRatio = true; }
public override void CreateScene() { TexturePtr mTexture = TextureManager.Singleton.CreateManual("RenderArea", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, 512, 512, 0, PixelFormat.PF_R8G8B8, (int)TextureUsage.TU_RENDERTARGET); rttTex = mTexture.GetBuffer().GetRenderTarget(); rttTex.IsAutoUpdated = false; { // Create the camera Camera camera2 = sceneMgr.CreateCamera("PlayerCam2"); camera2.Position = new Vector3(0, 0, 3); camera2.LookAt(new Vector3(0.0f, 0.0f, 0.0f)); camera2.NearClipDistance = 1; Viewport v = rttTex.AddViewport(camera2); MaterialPtr mat = MaterialManager.Singleton.GetByName("CgTutorials/RenderToTexture_Material"); mat.GetTechnique(0).GetPass(0).GetTextureUnitState(0).SetTextureName("RenderArea"); v.BackgroundColour = new ColourValue(0.0f, 0.3f, 0.2f, 0.0f); //v.SetClearEveryFrame(false); //v.OverlaysEnabled = false; rttTex.PreRenderTargetUpdate += new RenderTargetListener.PreRenderTargetUpdateHandler(RenderArea_PreRenderTargetUpdate); rttTex.PostRenderTargetUpdate += new RenderTargetListener.PostRenderTargetUpdateHandler(RenderArea_PostRenderTargetUpdate); } node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("TutorialRender2TexNode1"); node2 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("TutorialRender2TexNode2"); manualObj1 = sceneMgr.CreateManualObject("TutorialRender2TexObject1"); manualObj2 = sceneMgr.CreateManualObject("TutorialRender2TexObject2"); node1.AttachObject(DrawTriangle1(manualObj1)); node2.AttachObject(DrawTriangle2(manualObj2)); }
protected void drawLine(SceneNode p_Node, string lineName, Vector3 p_Point1, Vector3 p_Point2) { // create material (colour) MaterialPtr moMaterial = MaterialManager.Singleton.Create(lineName, "debugger"); moMaterial.ReceiveShadows = false; moMaterial.GetTechnique(0).SetLightingEnabled(true); moMaterial.GetTechnique(0).GetPass(0).SetDiffuse(0, 0, 1, 0); moMaterial.GetTechnique(0).GetPass(0).SetAmbient(0, 0, 1); moMaterial.GetTechnique(0).GetPass(0).SetSelfIllumination(0, 0, 1); moMaterial.Dispose(); // dispose pointer, not the material // create line object ManualObject manOb = mSceneManager.CreateManualObject(lineName); manOb.Begin(lineName, RenderOperation.OperationTypes.OT_LINE_LIST); manOb.Position(p_Point1.x, p_Point1.y, p_Point1.z); manOb.Position(p_Point2.x, p_Point2.y, p_Point2.z); // ... maybe more points manOb.End(); // create SceneNode and attach the line // p_Node.Position = Vector3.ZERO; p_Node.AttachObject(manOb); }
public override void CreateSimNode() { enabled = true; state.SceneManager.DestroyEntity("SubNode"); state.SceneManager.DestroyLight("subLight"); Entity sub = state.SceneManager.CreateEntity("SubNode", @"MockSub.mesh"); var sceneNode = new SceneNode(state.SceneManager); sceneNode.AttachObject(sub); sceneNode.Yaw(Math.HALF_PI); SimNode = new SimNode(state.SceneManager.RootSceneNode, sceneNode); Light subLight = state.SceneManager.CreateLight("subLight"); subLight.Type = Light.LightTypes.LT_SPOTLIGHT; subLight.Direction = new Vector3(0, 0, -1); subLight.SpotlightOuterAngle = new Radian(0.4F); subLight.SpotlightInnerAngle = new Radian(0.2F); subLight.SpotlightFalloff = 100.0F; subLight.SetAttenuation(100, 0F, 0.0F, 0.01F); SimNode.SceneNode.AttachObject(subLight); SimNode.SceneNode.Position = new Vector3(0, 0, 20); }
public Described(DescribedProfile profile) { Profile = profile.Clone(); Activator = ""; Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName); Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode(); Entity.CastShadows = true; Node.AttachObject(Entity); ConvexCollision coll = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld, Node, Quaternion.IDENTITY, 0.1f, Engine.Singleton.GetUniqueBodyId()); Vector3 inertia = new Vector3(1, 1, 1), offset; coll.CalculateInertialMatrix(out inertia, out offset); Inertia = inertia; Body = new Body(Engine.Singleton.NewtonWorld, coll, true); Body.AttachNode(Node); Body.SetMassMatrix(Profile.Mass, Profile.Mass * inertia); Body.MaterialGroupID = Engine.Singleton.MaterialManager.DescribedMaterialID; Body.UserData = this; coll.Dispose(); Body.ForceCallback += BodyForceCallback; }
public void GenerateVisualAIMesh() { if (aimesh != null) { int index = 0; foreach (var vertexData in aimesh.AIMeshVertexData) { AIMeshVertex visualVertex = new AIMeshVertex(); visualVertex.Position = vertexData; Entity visualAIMeshVertexEnt = scm.CreateEntity("AIMESH_VERTEX_ENT_" + index, "marker_vertex.mesh"); SceneNode visualAIMeshVertexSceneNode = scm.RootSceneNode.CreateChildSceneNode("AIMESH_VERTEX_SCENENODE_" + index); visualAIMeshVertexSceneNode.AttachObject(visualAIMeshVertexEnt); visualAIMeshVertexSceneNode.Position = vertexData; visualAIMeshVertexEnt.QueryFlags = 1 << 0; visualAIMeshVertexEnt.Visible = true; visualVertex.Mesh = visualAIMeshVertexEnt; index++; } index = 0; foreach (var indexData in aimesh.AIMeshIndicsData) { int lastVertexNumber = -1; foreach (int vertexNumber in indexData.VertexNumber) { if (lastVertexNumber != -1) { Vector3 startVertexData = aimesh.AIMeshVertexData.ElementAt(lastVertexNumber - 1); Vector3 endVertexData = aimesh.AIMeshVertexData.ElementAt(vertexNumber - 1); Vector3 startToEndVect = new Vector3( endVertexData.x - startVertexData.x, endVertexData.y - startVertexData.y, endVertexData.z - startVertexData.z ); Vector3 centralVertexData = new Vector3( (startVertexData.x - endVertexData.x) / 2, (startVertexData.y - endVertexData.y) / 2, (startVertexData.z - endVertexData.z) / 2 ); AIMeshEdge visualEdge = new AIMeshEdge(); visualEdge.Position = centralVertexData; Entity visualAIMeshLineEnt = map.CreateEntityWithMaterial( "AIMESH_LINE_ENT_" + Guid.NewGuid().ToString(), "marker_line.mesh", "marker_line" ); SceneNode visualAIMeshLineSceneNode = scm.RootSceneNode.CreateChildSceneNode("AIMESH_LINE_SCENENODE_" + index); visualAIMeshLineSceneNode.AttachObject(visualAIMeshLineEnt); visualAIMeshLineSceneNode.Position = centralVertexData; Radian angle = Mogre.Math.ACos(startToEndVect.DotProduct(Vector3.UNIT_Z) / startToEndVect.Normalise()); visualAIMeshLineSceneNode.Rotate(Vector3.UNIT_Y, angle); visualEdge.Mesh = visualAIMeshLineEnt; } lastVertexNumber = vertexNumber; index++; } } } }
//public static void Main() //{ // new Tutorial().Go(); //} protected override void CreateScene() { physics = new Physics(); player = new Player(mSceneMgr); player.Model.SetPosition(new Vector3(50, 10, 100)); playerStats = new PlayerStats(); environment = new Environment(mSceneMgr, mWindow); cameraNode = mSceneMgr.CreateSceneNode(); cameraNode.AttachObject(mCamera); player.Model.GameNode.AddChild(cameraNode); inputsManager.PlayerController = (PlayerController)player.Controller; hudElement = new GameInterface(mSceneMgr, mWindow, playerStats); mSceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE; testGun = new BombDropper(mSceneMgr); blueGems = new List <BlueGem>(); blueGemsToRemove = new List <BlueGem>(); for (int i = 0; i < 5; i++) { BlueGem aBlueGem = new BlueGem(mSceneMgr, playerStats.Score); aBlueGem.SetPosition(new Vector3(Mogre.Math.RangeRandom(-500, 500), 10, Mogre.Math.RangeRandom(-500, 500))); blueGems.Add(aBlueGem); } redGems = new List <RedGem>(); redGemsToRemove = new List <RedGem>(); for (int i = 0; i < 5; i++) { RedGem aRedGem = new RedGem(mSceneMgr, playerStats.Score); aRedGem.SetPosition(new Vector3(Mogre.Math.RangeRandom(-500, 500), 10, Mogre.Math.RangeRandom(-500, 500))); redGems.Add(aRedGem); } shieldPU = new List <ShieldPU>(); shieldPUToRemove = new List <ShieldPU>(); for (int i = 0; i < 2; i++) { ShieldPU aShieldPU = new ShieldPU(mSceneMgr, playerStats.Shield); aShieldPU.SetPosition(new Vector3(Mogre.Math.RangeRandom(-500, 500), 10, Mogre.Math.RangeRandom(-500, 500))); shieldPU.Add(aShieldPU); } //robot1 = new Robot(mSceneMgr, playerStats.Lives); //robot1.InitialPosition(new Vector3(-300, 0, -200)); //robot2 = new Robot(mSceneMgr, playerStats.Lives); //robot2.InitialPosition(new Vector3(100, 0, 300)); //robot3 = new Robot(mSceneMgr, playerStats.Lives); //robot3.InitialPosition(new Vector3(-300, 0, 300)); physics.StartSimTimer(); }
public void SetGraphicsMesh(String meshFile) { m_GraphicsNode = Core.Singleton.m_SceneManager.RootSceneNode.CreateChildSceneNode(); m_GraphicsEntity = Core.Singleton.m_SceneManager.CreateEntity(meshFile); m_GraphicsNode.AttachObject(m_GraphicsEntity); m_GraphicsEntity.CastShadows = false; }
public SmoothFreeCamera(string name) : base(name) { TargetNode = LKernel.GetG<SceneManager>().RootSceneNode.CreateChildSceneNode(); TargetNode.SetFixedYawAxis(true); CameraNode.DetachObject(Camera); TargetNode.AttachObject(Camera); }
/// <summary> /// This metod loads a quad in an entity and attaches it to the scenegraph /// </summary> public void Load() { Quad(); manualObjEntity = mSceneMgr.CreateEntity("Quad_Endtity", "Quad"); // Creates a new entity which contains the geometry manualObjNode = mSceneMgr.CreateSceneNode("Quad_Node"); // Creates a new node for the scene graph manualObjNode.AttachObject(manualObjEntity); // Attaches the entity (geometry) to the node mSceneMgr.RootSceneNode.AddChild(manualObjNode); // Adds the node as child of the root of the scene graph }
public ForceBall(SceneManager sceneManager, MogreNewt.World physicsWorld, float tempSize, int own) { MogreNewt.ConvexCollision col; Mogre.Vector3 offset; Mogre.Vector3 inertia; unique++; // Create the visible mesh (no physics) ent = sceneManager.CreateEntity("forceball" + unique, "Sph.mesh"); sn = sceneManager.RootSceneNode.CreateChildSceneNode(); sn.AttachObject(ent); Console.WriteLine("end ball create"); size = tempSize; sn.SetScale(size, size, size); // Create the collision hull col = new MogreNewt.CollisionPrimitives.ConvexHull(physicsWorld, sn); col.calculateInertialMatrix(out inertia, out offset); // Create the physics body. This body is what you manipulate. The graphical Ogre scenenode is automatically synced with the physics body body = new MogreNewt.Body(physicsWorld, col); col.Dispose(); //body.setPositionOrientation(new Vector3(0, 10, 0), Quaternion.IDENTITY); body.attachToNode(sn); body.setContinuousCollisionMode(1); body.setMassMatrix(mass, mass * inertia); body.IsGravityEnabled = true; body.setUserData(this); trail = sceneManager.CreateParticleSystem("awesome" + StringConverter.ToString(unique), "Char/Smoke"); trail.CastShadows = true; trail.GetEmitter(0).EmissionRate = 100; sn.AttachObject(trail); Console.WriteLine("player stuff"); owner = own; Player tempP = (Player)Program.p1; colour = tempP.cv; }
public BillboardSystem(SceneManager sceneManager, SceneNode worldNode, string materialName, Mogre.BillboardType type, Vector2 defaultDimension, float defaultTimeToLive) { BillboardSet = sceneManager.CreateBillboardSet(); BillboardSet.SetMaterialName(materialName); BillboardSet.SetBillboardsInWorldSpace(true); BillboardSet.BillboardType = type; worldNode.AttachObject(BillboardSet); this.DefaultDimension = defaultDimension; this.DefaultTimeToLive = defaultTimeToLive; }
public Barrel(string meshName, float mass) { //tworzy grafike playera i podczepia mu kontroler, obsluguje animacje i uaktualnia kontroler m_HeadOffset = new Vector3(0, 0.1f, 0); //headoffset powinien byc chyba zmienny dla croucha itp m_Entity = Core.Singleton.SceneManager.CreateEntity(meshName); m_Node = Core.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode(); m_Node.AttachObject(m_Entity); m_Node.SetPosition(0f, 0f, 0f); SetPhysics(m_Entity, m_Node, mass); }
/// <summary> /// Initializes TargetPointer (gets unused name and creates SceneNode and Entity). /// Also stores a reference to targeted object. /// </summary> /// <param name="gameObject">The targeted object.</param> public TargetPointer(IGameObject gameObject) { this.gameObject = gameObject; this.position = gameObject.GetProperty<Vector3>(PropertyEnum.Position); string name = Game.IGameObjectCreator.GetUnusedName(typeName); entity = Game.SceneManager.CreateEntity(name, mesh); node = Game.SceneManager.RootSceneNode.CreateChildSceneNode(name + "Node", position.Value + liftingConst); node.Pitch(new Degree(180)); node.AttachObject(entity); }
public UniqueParticleSystem(SceneManager sceneManager, SceneNode worldNode, string templateName) { ParticleSystem = sceneManager.CreateParticleSystem("UniqueParticleSystem" + Guid.NewGuid().ToString(), templateName); ReferenceEmitters = ParticleSystem.GetParticleEmitterEnumerable().ToArray(); foreach (ParticleEmitter emitter in ReferenceEmitters) emitter.Enabled = false; ParticleQuotaPerEmitter = ParticleSystem.ParticleQuota; SceneNode = worldNode.CreateChildSceneNode(); SceneNode.AttachObject(ParticleSystem); }
public Barrel(string meshName, Vector3 v, float mass) { m_Entity = Core.Singleton.SceneManager.CreateEntity(meshName); m_Node = Core.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode(); m_Node.AttachObject(m_Entity); m_Node.Scale(0.1f, 0.1f, 0.1f); m_Node.Scale(new Vector3(0.3f, 0.3f, 0.3f)); // m_Node.Rotate(new Mogre.Quaternion(new Mogre.Radian(1.57f), new Mogre.Vector3(0f, 0f, 1f) )); m_Node.SetPosition(v.x, v.y, v.z); SetPhysics(m_Entity, m_Node, mass); }
public Elevator(string meshName, float mass, Vector3 v, bool flaga) { //tworzy grafike playera i podczepia mu kontroler, obsluguje animacje i uaktualnia kontroler m_HeadOffset = new Vector3(0, 0.1f, 0); //headoffset powinien byc chyba zmienny dla croucha itp m_Entity = Core.Singleton.SceneManager.CreateEntity(meshName); m_Node = Core.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode(); m_Node.AttachObject(m_Entity); m_Node.Rotate(new Mogre.Quaternion(new Mogre.Radian(Mogre.Math.RadiansToDegrees(20)), new Mogre.Vector3(0f, 1f, 0f))); m_Node.SetPosition(v.x, v.y, v.z); SetPhysics(m_Entity, m_Node, mass); }
public Stone(ref SceneManager mSceneMgr, Vector3 position) { name = count.ToString(); ent = mSceneMgr.CreateEntity("stone"+name, "ogrehead.mesh"); ent.CastShadows = true; isCarried = false; node = mSceneMgr.RootSceneNode.CreateChildSceneNode("stoneNode"+name); node.AttachObject(ent); node.Position = position; node.Scale(0.35f, 0.35f, 0.35f); count++; }
/// <summary> /// This method creates 1000 quads and attaches them to the scenegraph /// </summary> public void NonStaticGeometry() { Quad(); for (int i = 0; i < 100; i++) for (int j = 0; j < 100; j++) { manualObjEntity = mSceneMgr.CreateEntity("Quad"); manualObjNode = mSceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(i * 5, j * 5, 0)); manualObjNode.AttachObject(manualObjEntity); } }
public override void CreateScene() { sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE; sceneMgr.ShadowFarDistance = 1000; MovableObject.DefaultVisibilityFlags = 0x00000001; // Set ambient light sceneMgr.AmbientLight = new ColourValue(0.3f, 0.3f, 0.2f); Light l = sceneMgr.CreateLight("Light2"); Vector3 dir = new Vector3(-1, -1, 0); dir.Normalise(); l.Type = Light.LightTypes.LT_DIRECTIONAL; l.Direction = dir; l.SetDiffuseColour(1, 1, 0.8f); l.SetSpecularColour(1, 1, 1); Entity pEnt; // House pEnt = sceneMgr.CreateEntity("1", "tudorhouse.mesh"); SceneNode n1 = sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(350, 450, -200)); n1.AttachObject(pEnt); pEnt = sceneMgr.CreateEntity("2", "tudorhouse.mesh"); SceneNode n2 = sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(-350, 450, -200)); n2.AttachObject(pEnt); pEnt = sceneMgr.CreateEntity("3", "knot.mesh"); mSpinny = sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(0, 0, 300)); mSpinny.AttachObject(pEnt); pEnt.SetMaterialName("Examples/MorningCubeMap"); sceneMgr.SetSkyBox(true, "Examples/MorningSkyBox"); Plane plane; plane.normal = Vector3.UNIT_Y; plane.d = 100; MeshManager.Singleton.CreatePlane("Myplane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, 1500, 1500, 10, 10, true, 1, 5, 5, Vector3.UNIT_Z); Entity pPlaneEnt = sceneMgr.CreateEntity("plane", "Myplane"); pPlaneEnt.SetMaterialName("Examples/Rockwall"); pPlaneEnt.CastShadows = false; sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(pPlaneEnt); camera.SetPosition(-400, 50, 900); camera.LookAt(0, 80, 0); AddCompositors(); }
public ClientShip(World _w, SceneManager _mgr, SceneNode _parent, int _id, Vector3 _position, Quaternion _orientation) : base(_w, _id, _position, _orientation) { SceneNode parent = _mgr.RootSceneNode; if(_parent != null){ parent = _parent; } mesh = _mgr.CreateEntity(id.ToString(), "razor.mesh"); node = parent.CreateChildSceneNode(); node.AttachObject(mesh); body.attachToNode(node); }
//Public functions public void make() { unique++; Console.WriteLine("MAKING A MONSTYER"); //create a scene node, off the root scene node sn = Program.Instance.sceneManager.RootSceneNode.CreateChildSceneNode(); //Load the mesh into the entity ent = Program.Instance.sceneManager.CreateEntity("Monsta" + unique, "Player.mesh"); //Attach the Entity to the scene node sn.AttachObject(ent); sn.Position = new Vector3(0, 3, 0); update(); }
public Character(string meshName, float mass/*CharacterProfile profile*/, bool npc) { //tworzy grafike playera i podczepia mu kontroler, obsluguje animacje i uaktualnia kontroler m_HeadOffset = new Vector3(0, 0.8f, 0); //headoffset powinien byc chyba zmienny dla croucha itp m_Entity = Core.Singleton.SceneManager.CreateEntity(meshName); m_Node = Core.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode(); m_Node.AttachObject(m_Entity); if (npc) m_Control = new NpcController(m_Node, m_Entity, mass); else m_Control = new PlayerController(m_Node, m_Entity, mass); }
/// <summary> /// This method generates a plane in an Entity which will be used as a ground /// </summary> private void GroundPlane() { plane = new Plane(Vector3.UNIT_Y, 0); MeshPtr groundMeshPtr = MeshManager.Singleton.CreatePlane("ground", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, groundWidth, groundHeight, groundXSegs, groundZSegs, true, 1, uTiles, vTiles, Vector3.UNIT_Z); groundEntity = mSceneMgr.CreateEntity("ground"); groundNode = mSceneMgr.CreateSceneNode(); groundNode.AttachObject(groundEntity); mSceneMgr.RootSceneNode.AddChild(groundNode); groundEntity.SetMaterialName("Meteor"); }
public void SetCollisionMesh(String meshFile) { m_CollisionNode = Core.Singleton.m_SceneManager.RootSceneNode.CreateChildSceneNode(); m_CollisionEntity = Core.Singleton.m_SceneManager.CreateEntity(meshFile); m_CollisionNode.AttachObject(m_CollisionEntity); m_CollisionNode.SetVisible(false); MogreNewt.CollisionPrimitives.TreeCollisionSceneParser collision = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser( Core.Singleton.m_NewtonWorld); collision.ParseScene(m_CollisionNode, true, 1); m_Body = new Body(Core.Singleton.m_NewtonWorld, collision); collision.Dispose(); m_Body.AttachNode(m_CollisionNode); }
public ThirdPersonModel(Character character, SceneNode characterNode, string[] bodyEntityNames) : base(character) { BodyEntities = bodyEntityNames.Select(name => Character.World.Scene.CreateEntity(name)).ToArray(); BodyNode = characterNode.CreateChildSceneNode(); BodyNode.Yaw(MathHelper.Pi); WeaponSceneNode = BodyNode.CreateChildSceneNode(); WeaponCenterNode = WeaponSceneNode.CreateChildSceneNode(); foreach (Entity bodyEntity in BodyEntities) { BodyNode.AttachObject(bodyEntity); // To play multiple animations that does not affect each other, // blending mode cannot be average. if (bodyEntity.HasSkeleton) bodyEntity.Skeleton.BlendMode = SkeletonAnimationBlendMode.ANIMBLEND_CUMULATIVE; } WeaponCenterNode.Yaw(MathHelper.Pi); }
public Player(Vector3 oPos, Quaternion oOrent) { unique++; //create a scene node, off the root scene node sn = Program.Instance.sceneManager.RootSceneNode.CreateChildSceneNode(); //Load the mesh into the entity ent = Program.Instance.sceneManager.CreateEntity("playa" + unique, "PC_01.mesh"); //Attach the Entity to the scene node sn.AttachObject(ent); l = Program.Instance.sceneManager.CreateLight("Sun"); l.DiffuseColour = new ColourValue(0.9f, 0.6f, 0.2f); light_node = sn.CreateChildSceneNode(); light_node.AttachObject(l); light_node.Position = new Vector3(0, 0, -55); sn.Orientation = new Quaternion(new Degree(90), Vector3.UNIT_X); position = new Vector2(0, 0); isPlayer = true; }
public Character(CharacterProfile profile) { m_Profile = profile.Clone(); m_Orientation = Quaternion.IDENTITY; m_Entity = Core.Singleton.m_SceneManager.CreateEntity(m_Profile.m_MeshName); m_Node = Core.Singleton.m_SceneManager.RootSceneNode.CreateChildSceneNode(); m_Node.AttachObject(m_Entity); Vector3 scaledSize = m_Entity.BoundingBox.HalfSize * m_Profile.m_BodyScaleFactor; ConvexCollision collision = new MogreNewt.CollisionPrimitives.Capsule( Core.Singleton.m_NewtonWorld, System.Math.Min(scaledSize.x, scaledSize.z), scaledSize.y * 2, Vector3.UNIT_X.GetRotationTo(Vector3.UNIT_Y), Core.Singleton.GetUniqueBodyId()); Vector3 inertia, offset; collision.CalculateInertialMatrix(out inertia, out offset); inertia *= m_Profile.m_BodyMass; m_Body = new Body(Core.Singleton.m_NewtonWorld, collision, true); m_Body.AttachNode(m_Node); m_Body.SetMassMatrix(m_Profile.m_BodyMass, inertia); m_Body.AutoSleep = false; m_Body.Transformed += BodyTransformCallback; m_Body.ForceCallback += BodyForceCallback; Joint upVector = new MogreNewt.BasicJoints.UpVector( Core.Singleton.m_NewtonWorld, m_Body, Vector3.UNIT_Y); collision.Dispose(); }
protected void processPlane(XmlElement XMLNode, SceneNode pParent) { string name = getAttrib(XMLNode, "name"); float distance = getAttribReal(XMLNode, "distance"); float width = getAttribReal(XMLNode, "width"); float height = getAttribReal(XMLNode, "height"); int xSegments = (int)getAttribReal(XMLNode, "xSegments"); int ySegments = (int)getAttribReal(XMLNode, "ySegments"); int numTexCoordSets = (int)getAttribReal(XMLNode, "numTexCoordSets"); float uTile = getAttribReal(XMLNode, "uTile"); float vTile = getAttribReal(XMLNode, "vTile"); string material = getAttrib(XMLNode, "material"); bool normals = getAttribBool(XMLNode, "normals"); bool movablePlane = getAttribBool(XMLNode, "movablePlane"); bool castShadows = getAttribBool(XMLNode, "castShadows"); bool receiveShadows = getAttribBool(XMLNode, "receiveShadows"); Vector3 normal = Vector3.ZERO; XmlElement pElement = (XmlElement)XMLNode.SelectSingleNode("normal"); if (pElement != null) normal = parseVector3(pElement); Vector3 upVector = Vector3.UNIT_Y; pElement = (XmlElement)XMLNode.SelectSingleNode("upVector"); if (pElement != null) upVector = parseVector3(pElement); Plane pPlane = new Plane(normal, upVector); Entity pEntity = null; try { MeshPtr ptr = MeshManager.Singleton.CreatePlane(name, m_sGroupName, pPlane, width, height, xSegments, ySegments, normals, (ushort)numTexCoordSets, uTile, vTile, upVector); pEntity = mSceneMgr.CreateEntity(name, name); pParent.AttachObject(pEntity); } catch (Exception e) { LogManager.Singleton.LogMessage("[DotSceneLoader] Error loading an entity!" + e.Message); } }
protected void processLight(XmlElement XMLNode, SceneNode pParent) { // Process attributes String name = getAttrib(XMLNode, "name"); // Create the light Light pLight = mSceneMgr.CreateLight(name); if (pParent != null) pParent.AttachObject(pLight); String sValue = getAttrib(XMLNode, "type"); if (sValue == "point") pLight.Type = Light.LightTypes.LT_POINT; else if (sValue == "directional") pLight.Type = Light.LightTypes.LT_DIRECTIONAL; else if (sValue == "spotLight") pLight.Type = Light.LightTypes.LT_SPOTLIGHT; // only set if Lamp is Spotlight (Blender) bool castShadow = true; if (XMLNode.HasAttribute("castShadow")) { castShadow = getAttribBool(XMLNode, "castShadow", true); } else if (XMLNode.HasAttribute("castShadows")) { castShadow = getAttribBool(XMLNode, "castShadows", true); } pLight.CastShadows = castShadow; XmlElement pElement; // Process normal (?) pElement = (XmlElement)XMLNode.SelectSingleNode("normal"); if (pElement != null) pLight.Direction = parseVector3(pElement); // Process colourDiffuse (?) pElement = (XmlElement)XMLNode.SelectSingleNode("colourDiffuse"); if (pElement != null) pLight.DiffuseColour = parseColour(pElement); // Process colourSpecular (?) pElement = (XmlElement)XMLNode.SelectSingleNode("colourSpecular"); if (pElement != null) pLight.SpecularColour = parseColour(pElement); // Process lightRange (?) pElement = (XmlElement)XMLNode.SelectSingleNode("lightRange"); if (pElement != null) processLightRange(pElement, pLight); // Process lightAttenuation (?) pElement = (XmlElement)XMLNode.SelectSingleNode("lightAttenuation"); if (pElement != null) processLightAttenuation(pElement, pLight); }
protected void processEntity(XmlElement XMLNode, SceneNode pParent) { // Process attributes String name = getAttrib(XMLNode, "name"); String meshFile = getAttrib(XMLNode, "meshFile"); bool bstatic = getAttribBool(XMLNode, "static", false); if (bstatic) StaticObjects.Add(name); else DynamicObjects.Add(name); bool bvisible = getAttribBool(XMLNode, "visible", true); bool bcastshadows = getAttribBool(XMLNode, "castShadows", true); float brenderingDistance = getAttribReal(XMLNode, "renderingDistance", 0); // Create the entity Entity pEntity = null; try { MeshPtr mesh = MeshManager.Singleton.Load(meshFile, m_sGroupName); ushort src, dest; mesh.SuggestTangentVectorBuildParams(VertexElementSemantic.VES_TANGENT, out src, out dest); mesh.BuildTangentVectors(VertexElementSemantic.VES_TANGENT, src, dest); pEntity = mSceneMgr.CreateEntity(name, meshFile); pEntity.Visible = bvisible; pEntity.CastShadows = bcastshadows; pEntity.RenderingDistance = brenderingDistance; XmlElement pElement; // Process subentities (?) pElement = (XmlElement)XMLNode.SelectSingleNode("subentities"); if (pElement != null) { pElement = (XmlElement)pElement.FirstChild; while (pElement != null) { string mat = getAttrib(pElement, "materialName"); pEntity.SetMaterialName(mat); pElement = (XmlElement)pElement.NextSibling; } } pParent.AttachObject(pEntity); } catch (Exception e) { LogManager.Singleton.LogMessage("[DotSceneLoader] Error loading an entity!" + e.Message); } }