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; }
protected void InitLights(ColourValue c1, ColourValue c2) { Billboard lightbillboard; BillboardSet lightbillboardset = sceneMgr.CreateBillboardSet(name + "_lights", 1); lightbillboardset.MaterialName = "Effects/Flare"; if (!EngineConfig.LowDetails) { lightbillboard = lightbillboardset.CreateBillboard(-9.2f, 12.5f, -5.1f - 47.5f, c1); lightbillboard.SetDimensions(2, 2); Light light = sceneMgr.CreateLight(name + "_light1"); light.Type = Light.LightTypes.LT_POINT; light.SetAttenuation(30.0f, 0.0f, 1.0f, 0.00f); light.DiffuseColour = new ColourValue(0.5f, 0.0f, 0.0f); light.SpecularColour = new ColourValue(0.05f, 0.05f, 0.05f); light.CastShadows = true; SceneNode lightNode = mainNode.CreateChildSceneNode(new Vector3(-9.2f, 12.5f, -4.0f - 5.1f - 47.5f)); lightNode.AttachObject(light); } lightbillboard = lightbillboardset.CreateBillboard(-10.7f, 12.3f, 12.6f - 47.5f, c2); lightbillboard.SetDimensions(2, 2); mainNode.AttachObject(lightbillboardset); //sceneMgr.ShowBoundingBoxes = true; }
public Billboard(Vector3 position, BillboardSet owner) : this(OgrePINVOKE.new_Billboard__SWIG_2(Vector3.getCPtr(position), BillboardSet.getCPtr(owner)), true) { if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } }
private void Init() { var cache = Application.ResourceCache; barTex = cache.GetTexture2D("Textures/Bargraph.png"); barFont = cache.GetFont("Fonts/OpenSans-SemiBold.ttf"); graphRoot = new UIElement(); graphRoot.SetStyleAuto(null); graphRoot.LayoutMode = LayoutMode.Free; panel = Node.CreateComponent <UIComponent>(); panel.Material.SetTechnique(0, cache.GetTechnique("Techniques/DiffUnlitAlpha.xml")); panel.Root.LayoutMode = LayoutMode.Free; panel.Root.HorizontalAlignment = HorizontalAlignment.Center; panel.Root.VerticalAlignment = VerticalAlignment.Center; panel.Root.AddChild(graphRoot); billboards = Node.CreateComponent <BillboardSet>(); billboards.NumBillboards = 1; billboards.Material = panel.Material; var billboard = billboards.GetBillboardSafe(0); billboard.Enabled = false; billboards.Commit(); }
public BillboardParticleRenderer() { billboardSet = new BillboardSet("", 0, true); billboardSet.SetBillboardsInWorldSpace(true); // TODO: Is this the right way to do this? RegisterParsers(); }
public void _notifyOwner(BillboardSet owner) { OgrePINVOKE.Billboard__notifyOwner(swigCPtr, BillboardSet.getCPtr(owner)); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } }
public DecayableBillboard(BillboardSet billboardSet, Vector3 position, Vector2 dimension, float timeToLive) { this.BillboardSet = billboardSet; Billboard = BillboardSet.CreateBillboard(position); Billboard.TexcoordRect = new FloatRect(0, 0, 1, 1); this.Dimension = dimension; this.TimeToLive = timeToLive; this.Alive = true; }
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; }
private void Init() { var cache = Application.ResourceCache; label = new Text() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; label.SetColor(new Color(1.0f, 1.0f, 1.0f)); label.SetFont(cache.GetFont("Fonts/OpenSans-Bold.ttf"), 20); background = new BorderImage() { //Texture = cache.GetTexture2D("Textures/UI.png"), //ImageRect = new IntRect(48, 0, 64, 16), //Border = new IntRect(4, 4, 4, 4), Texture = cache.GetTexture2D("Textures/Panel.png"), ImageRect = new IntRect(0, 0, 64, 64), Border = new IntRect(30, 30, 30, 30), BlendMode = BlendMode.Alpha, }; panel = Node.CreateComponent <UIComponent>(); panel.Material.SetTechnique(0, cache.GetTechnique("Techniques/DiffUnlitAlpha.xml")); panel.Root.LayoutMode = LayoutMode.Free; panel.Root.HorizontalAlignment = HorizontalAlignment.Center; panel.Root.VerticalAlignment = VerticalAlignment.Center; panel.Root.AddChild(background); panel.Root.AddChild(label); billboards = Node.CreateComponent <BillboardSet>(); billboards.NumBillboards = 1; billboards.Material = panel.Material; Node.Position = Position; var billboard = billboards.GetBillboardSafe(0); billboard.Enabled = false; billboards.Commit(); /* * var node = Node.CreateChild(); * node.Position = new Vector3(0.0f, 2.0f, 0.0f); * node.Scale = new Vector3(2.0f, 2.0f, 2.0f); */ /* * var box = node.CreateComponent<StaticModel>(); * box.Model = cache.GetModel("Models/Box.mdl"); * //box.Material = Material.FromImage("Textures/StoneDiffuse.dds"); */ }
protected void InitLight(SceneNode parent, ColourValue c1, Vector3 localPosition, Vector2 size) { Billboard lightbillboard; BillboardSet lightbillboardset = sceneMgr.CreateBillboardSet(parent.Name + "_lights" + c1.ToString() + "_" + localPosition.ToString(), 1); lightbillboardset.MaterialName = "Effects/Flare"; lightbillboard = lightbillboardset.CreateBillboard(localPosition, c1); lightbillboard.SetDimensions(size.x, size.y); parent.AttachObject(lightbillboardset); }
public void UpdateBillState(SceneNode node) { BillboardSet en = node.GetAttachedObject(0) as BillboardSet; for (int i = 0; i < modelEntry.广告牌.Count; i++) { if (modelEntry.广告牌[i].实体名 == en.Name) { BillBoardstruct modelentry = modelEntry.广告牌[i]; modelentry.位置 = node.Position; break; } } }
private void Init() { var cache = Application.ResourceCache; billboards = Node.CreateComponent <BillboardSet>(); billboards.NumBillboards = 1; billboards.Material = cache.GetMaterial("Materials/Sprite.xml").Clone(); Node.Position = Position; var billboard = billboards.GetBillboardSafe(0); billboard.Position = Vector3.Zero; billboard.Size = new Vector2(0.1f, 0.1f); billboard.Enabled = true; billboards.Commit(); }
void AddToEntity(IEntity entity, Vector3 offset, Vector2 size) { billboardSet = entity.Node.CreateComponent <BillboardSet>(); billboardSet.FaceCameraMode = FaceCameraMode.RotateXyz; billboardSet.NumBillboards = 1; billboardSet.Sorted = false; billboardSet.Material = material; billboardSet.Scaled = false; var billboard = billboardSet.GetBillboardSafe(0); billboard.Position = offset; billboard.Rotation = 0; billboard.Size = size; billboard.Uv = new Rect(new Vector2(0, 0), new Vector2(1, 1)); billboard.Enabled = true; }
protected void InitLightFlare(ColourValue c1, Vector3 localPosition, Vector2 scale) { lightBillboardSet = sceneMgr.CreateBillboardSet("EnemyInstallation" + tileID + "_lightflare", 1); lightBillboardSet.MaterialName = "Effects/Flare"; lightBillboard = lightBillboardSet.CreateBillboard(localPosition, c1); lightBillboard.SetDimensions(scale.x, scale.y); installationNode.AttachObject(lightBillboardSet); light = sceneMgr.CreateLight("EnemyInstallation" + tileID + "_light"); light.Type = Light.LightTypes.LT_POINT; light.SetAttenuation(25.0f, 0.0f, 1.0f, 0.00f); light.DiffuseColour = c1; light.SpecularColour = new ColourValue(0.05f, 0.05f, 0.05f); light.CastShadows = false; SceneNode lightNode = installationNode.CreateChildSceneNode(localPosition); lightNode.AttachObject(light); }
public void Dispose() { this.billboardSet.DetachFromParent(); this.sceneMgr.DestroyBillboardSet(this.billboardSet); this.billboardSet.Dispose(); this.billboardSet = null; this.sceneMgr = null; this.material.Unload(); MaterialManager.Singleton.Remove(this.material.Handle); this.material.Dispose(); this.material = null; this.texture.Unload(); TextureManager.Singleton.Remove(this.texture.Handle); this.texture.Dispose(); this.texture = null; GC.SuppressFinalize(this); }
protected override void dispose(bool disposeManagedResources) { if (!IsDisposed) { if (disposeManagedResources) { if (this.billboardSet != null) { if (!this.billboardSet.IsDisposed) { this.billboardSet.Dispose(); } this.billboardSet = null; } this.attribParsers.Clear(); } } base.dispose(disposeManagedResources); }
public void RemoveBill(SceneNode node) { if (node == null) { return; } BillboardSet en = node.GetAttachedObject(0) as BillboardSet; if (en == null) { return; } for (int i = 0; i < modelEntry.广告牌.Count; i++) { if (modelEntry.广告牌[i].实体名 == en.Name) { modelEntry.广告牌.RemoveAt(i); break; } } }
void AddToEntity(IEntity entity, Vector3 offset, Vector2 size) { billboardSet = null; foreach (var component in entity.GetComponents <BillboardSet>()) { if (component.Material == entity.Player.Insignia.HealthBarMat) { billboardSet = component; billboardIndex = billboardSet.NumBillboards; billboardSet.NumBillboards = billboardSet.NumBillboards + 1; } } if (billboardSet == null) { billboardSet = entity.CreateComponent <BillboardSet>(); billboardSet.FaceCameraMode = FaceCameraMode.RotateXyz; billboardSet.NumBillboards = 1; billboardSet.Sorted = false; billboardSet.Material = entity.Player.Insignia.HealthBarMat; billboardSet.Scaled = false; //NOTE: BILLBOARD DRAW DISTANCE billboardSet.DrawDistance = 50; billboardIndex = 0; } var billboard = billboardSet.GetBillboardSafe(billboardIndex); billboard.Position = offset; billboard.Rotation = 0; billboard.Size = size; billboard.Enabled = true; }
/// <summary> /// Creates the element in the world. It automatically /// sets up the mesh and the node.</summary> protected virtual void Initialise(RenderQueueGroupID renderGroup, string materialName, Vec3 scale) { mBillboardSet = SceneManager.Instance.CreateBillboardSet(2); mBillboardSet.CastShadows = false; mBillboardSet.RenderQueueGroup = renderGroup; mBillboardSet.MaterialName = materialName; mBillboardSet.DefaultSize = new Vec2(1, 1); // Attaches the mesh on a node if (mBillboardSet.ParentSceneNode == null) { mNode = new SceneNode(); mNode.Attach(mBillboardSet); } else mNode = mBillboardSet.ParentSceneNode; // Sets up the node (Position, Scale and Rotation) mBillboardSet.CreateBillboard(Vec3.Zero); mNode.Position = Vec3.Zero; mNode.Scale = scale; mMainLight = SceneManager.Instance.CreateLight(); mMainLight.Type = RenderLightType.Directional; mMainLight.AllowStaticLighting = false; mMainLight.CastShadows = true; mMainLight.Position = new Vec3(0, 0, 150); }
/// <summary> /// /// </summary> /// <param name="mgr"></param> /// <param name="rootSceneNode"></param> /// <param name="method"></param> public StaticBillboardSet(SceneManager mgr, SceneNode rootSceneNode, BillboardMethod method) { mSceneMgr = mgr; mRenderMethod = method; mVisible = true; mFadeEnabled = false; mBBOrigin = BillboardOrigin.Center; //Fall back to Compatible if vertex shaders are not available if (mRenderMethod == BillboardMethod.Accelerated) { RenderSystemCapabilities caps = Root.Singleton.RenderSystem.Capabilities; if (!caps.HasCapability(Capabilities.VertexPrograms)) mRenderMethod = BillboardMethod.Compatible; } mNode = rootSceneNode.CreateChildSceneNode(); mEntityName = GetUniqueID("SBSEntity"); if (mRenderMethod == BillboardMethod.Accelerated) { //Accelerated billboard method mEntity = null; mUFactor = 1.0f; mVFactor = 1.0f; //Load vertex shader to align billboards to face the camera (if not loaded already) if (++mSelfInstances == 1) { //First shader, simple camera-alignment HighLevelGpuProgram vertexShader = (HighLevelGpuProgram)HighLevelGpuProgramManager.Instance.GetByName("Sprite_vp"); if (vertexShader == null) { string vertexProg = string.Empty; vertexProg = "void Sprite_vp( \n" + " float4 position : POSITION, \n" + " float3 normal : NORMAL, \n" + " float4 color : COLOR, \n" + " float2 uv : TEXCOORD0, \n" + " out float4 oPosition : POSITION, \n" + " out float2 oUv : TEXCOORD0, \n" + " out float4 oColor : COLOR, \n" + " out float4 oFog : FOG, \n" + " uniform float4x4 worldViewProj, \n" + " uniform float uScroll, \n" + " uniform float vScroll, \n" + " uniform float4 preRotatedQuad[4] ) \n" + "{ \n" + //Face the camera " float4 vCenter = float4( position.x, position.y, position.z, 1.0f ); \n" + " float4 vScale = float4( normal.x, normal.y, normal.x, 1.0f ); \n" + " oPosition = mul( worldViewProj, vCenter + (preRotatedQuad[normal.z] * vScale) ); \n" + //Color " oColor = color; \n" + //UV Scroll " oUv = uv; \n" + " oUv.x += uScroll; \n" + " oUv.y += vScroll; \n" + //Fog " oFog.x = oPosition.z; \n" + "}"; vertexShader = HighLevelGpuProgramManager.Instance.CreateProgram( "Sprite_vp", ResourceGroupManager.DefaultResourceGroupName, "cg", GpuProgramType.Vertex); vertexShader.Source = vertexProg; vertexShader.SetParam("profiles", "vs_1_1 arbvp1"); vertexShader.SetParam("entry_point", "Sprite_vp"); vertexShader.Load(); } //Second shader, camera alignment and distance based fading HighLevelGpuProgram vertexShader2 = (HighLevelGpuProgram)HighLevelGpuProgramManager.Instance.GetByName("SpriteFade_vp"); if (vertexShader2 == null) { string vertexProg2 = string.Empty; vertexProg2 = "void SpriteFade_vp( \n" + " float4 position : POSITION, \n" + " float3 normal : NORMAL, \n" + " float4 color : COLOR, \n" + " float2 uv : TEXCOORD0, \n" + " out float4 oPosition : POSITION, \n" + " out float2 oUv : TEXCOORD0, \n" + " out float4 oColor : COLOR, \n" + " out float4 oFog : FOG, \n" + " uniform float4x4 worldViewProj, \n" + " uniform float3 camPos, \n" + " uniform float fadeGap, \n" + " uniform float invisibleDist, \n" + " uniform float uScroll, \n" + " uniform float vScroll, \n" + " uniform float4 preRotatedQuad[4] ) \n" + "{ \n" + //Face the camera " float4 vCenter = float4( position.x, position.y, position.z, 1.0f ); \n" + " float4 vScale = float4( normal.x, normal.y, normal.x, 1.0f ); \n" + " oPosition = mul( worldViewProj, vCenter + (preRotatedQuad[normal.z] * vScale) ); \n" + " oColor.rgb = color.rgb; \n" + //Fade out in the distance " float dist = distance(camPos.xz, position.xz); \n" + " oColor.a = (invisibleDist - dist) / fadeGap; \n" + //UV scroll " oUv = uv; \n" + " oUv.x += uScroll; \n" + " oUv.y += vScroll; \n" + //Fog " oFog.x = oPosition.z; \n" + "}"; vertexShader2 = HighLevelGpuProgramManager.Instance.CreateProgram( "SpriteFade_vp", ResourceGroupManager.DefaultResourceGroupName, "cg", GpuProgramType.Vertex); vertexShader2.Source = vertexProg2; vertexShader2.SetParam("profiles", "vs_1_1 arbvp1"); vertexShader2.SetParam("entry_point", "SpriteFade_vp"); vertexShader2.Load(); } } } else { //Compatible billboard method mFallbackSet = mSceneMgr.CreateBillboardSet(GetUniqueID("SBS"), 100); mNode.AttachObject(mFallbackSet); } }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="owner"></param> public Billboard(Vector3 position, BillboardSet owner) { this.Position = position; this.ParentSet = owner; this.Color = ColorEx.White; }
public BillboardParticleRenderer() : base() { this.billboardSet = new BillboardSet(string.Empty, 0, true); this.billboardSet.SetBillboardsInWorldSpace(true); }
protected override MovableObject _createInstance( string name, NamedParameterList param ) { // may have parameters bool externalData = false; int poolSize = 0; if ( param != null ) { if ( param.ContainsKey( "poolSize" ) ) { poolSize = Convert.ToInt32( param[ "poolSize" ] ); } if ( param.ContainsKey( "externalData" ) ) { externalData = Convert.ToBoolean( param[ "externalData" ] ); } } BillboardSet bSet; if ( poolSize > 0 ) { bSet = new BillboardSet( name, poolSize, externalData ); } else { bSet = new BillboardSet( name, 0 ); } bSet.MovableType = TypeName; return bSet; }
protected override void CreateScene() { // set some ambient light scene.AmbientLight = new ColorEx(1, 0.1f, 0.1f, 0.1f); // set a basic skybox scene.SetSkyBox(true, "Skybox/Space", 5000.0f); // create the ogre head Entity ogre = scene.CreateEntity("OgreHead", "ogrehead.mesh"); // attach the ogre to the scene scene.RootSceneNode.AttachObject(ogre); // create nodes for the billboard sets redYellowLightsNode = scene.RootSceneNode.CreateChildSceneNode(); greenBlueLightsNode = scene.RootSceneNode.CreateChildSceneNode(); // create a billboard set for creating billboards redYellowLights = scene.CreateBillboardSet("RedYellowLights", 20); redYellowLights.MaterialName = "Particles/Flare"; redYellowLightsNode.AttachObject(redYellowLights); greenBlueLights = scene.CreateBillboardSet("GreenBlueLights", 20); greenBlueLights.MaterialName = "Particles/Flare"; greenBlueLightsNode.AttachObject(greenBlueLights); // red light billboard in off set Vector3 redLightPos = new Vector3(78, -8, -70); redLightBoard = redYellowLights.CreateBillboard(redLightPos, ColorEx.Black); // yellow light billboard in off set Vector3 yellowLightPos = new Vector3(-4.5f, 30, -80); yellowLightBoard = redYellowLights.CreateBillboard(yellowLightPos, ColorEx.Black); // blue light billboard in off set Vector3 blueLightPos = new Vector3(-90, -8, -70); blueLightBoard = greenBlueLights.CreateBillboard(blueLightPos, ColorEx.Black); // green light billboard in off set Vector3 greenLightPos = new Vector3(50, 70, 80); greenLightBoard = greenBlueLights.CreateBillboard(greenLightPos, ColorEx.Black); // red light in off state redLight = scene.CreateLight("RedLight"); redLight.Position = redLightPos; redLight.Type = LightType.Point; redLight.Diffuse = ColorEx.Black; redYellowLightsNode.AttachObject(redLight); // yellow light in off state yellowLight = scene.CreateLight("YellowLight"); yellowLight.Type = LightType.Point; yellowLight.Position = yellowLightPos; yellowLight.Diffuse = ColorEx.Black; redYellowLightsNode.AttachObject(yellowLight); // green light in off state greenLight = scene.CreateLight("GreenLight"); greenLight.Type = LightType.Point; greenLight.Position = greenLightPos; greenLight.Diffuse = ColorEx.Black; greenBlueLightsNode.AttachObject(greenLight); // blue light in off state blueLight = scene.CreateLight("BlueLight"); blueLight.Type = LightType.Point; blueLight.Position = blueLightPos; blueLight.Diffuse = ColorEx.Black; greenBlueLightsNode.AttachObject(blueLight); // create controller function redLightFlasher = new LightFlasherControllerValue(redLight, redLightBoard, ColorEx.Red); yellowLightFlasher = new LightFlasherControllerValue(yellowLight, yellowLightBoard, ColorEx.Yellow); greenLightFlasher = new LightFlasherControllerValue(greenLight, greenLightBoard, ColorEx.Green); blueLightFlasher = new LightFlasherControllerValue(blueLight, blueLightBoard, ColorEx.Blue); // set up the controller value and function for flashing redLightFunc = new WaveformControllerFunction(WaveformType.Sine, 0, 0.5f, 0, 1); yellowLightFunc = new WaveformControllerFunction(WaveformType.Triangle, 0, 0.25f, 0, 1); greenLightFunc = new WaveformControllerFunction(WaveformType.Sine, 0, 0.25f, 0.5f, 1); blueLightFunc = new WaveformControllerFunction(WaveformType.Sine, 0, 0.75f, 0.5f, 1); // set up the controllers ControllerManager.Instance.CreateController(redLightFlasher, redLightFunc); ControllerManager.Instance.CreateController(yellowLightFlasher, yellowLightFunc); ControllerManager.Instance.CreateController(greenLightFlasher, greenLightFunc); ControllerManager.Instance.CreateController(blueLightFlasher, blueLightFunc); }
public override void Dispose() { base.Dispose(); if(mMainLight != null) mMainLight.Dispose(); if (mBillboardSet != null) mBillboardSet.Dispose(); mMainLight = null; mBillboardSet = null; }
protected void CreateRibbons() { viewport.BackgroundColor = ColorEx.Black; float scale = 100f; scene.AmbientLight = new ColorEx(0.5f, 0.5f, 0.5f); //scene.SetSkyBox(true, "Examples/SpaceSkyBox", 20f * oneMeter); Vector3 dir = new Vector3(-1f, -1f, 0.5f); dir.Normalize(); Light light1 = scene.CreateLight("light1"); light1.Type = LightType.Directional; light1.Direction = dir; // Create a barrel for the ribbons to fly through Entity barrel = scene.CreateEntity("barrel", "barrel.mesh"); SceneNode barrelNode = scene.RootSceneNode.CreateChildSceneNode(); barrelNode.ScaleFactor = 5f * Vector3.UnitScale; barrelNode.AttachObject(barrel); RibbonTrail trail = new RibbonTrail("DemoTrail", "numberOfChains", 2, "maxElementsPerChain", 80); trail.MaterialName = "Examples/LightRibbonTrail"; trail.TrailLength = scale * 400f; scene.RootSceneNode.CreateChildSceneNode().AttachObject(trail); // Create 3 nodes for trail to follow SceneNode animNode = scene.RootSceneNode.CreateChildSceneNode(); animNode.Position = scale * new Vector3(50f, 30f, 0); Animation anim = scene.CreateAnimation("an1", 14); anim.InterpolationMode = InterpolationMode.Spline; NodeAnimationTrack track = anim.CreateNodeTrack(1, animNode); TransformKeyFrame kf = track.CreateNodeKeyFrame(0); kf.Translate = scale * new Vector3(50f, 30f, 0f); kf = track.CreateNodeKeyFrame(2); kf.Translate = scale * new Vector3(100f, -30f, 0f); kf = track.CreateNodeKeyFrame(4); kf.Translate = scale * new Vector3(120f, -100f, 150f); kf = track.CreateNodeKeyFrame(6); kf.Translate = scale * new Vector3(30f, -100f, 50f); kf = track.CreateNodeKeyFrame(8); kf.Translate = scale * new Vector3(-50f, 30f, -50f); kf = track.CreateNodeKeyFrame(10); kf.Translate = scale * new Vector3(-150f, -20f, -100f); kf = track.CreateNodeKeyFrame(12); kf.Translate = scale * new Vector3(-50f, -30f, 0f); kf = track.CreateNodeKeyFrame(14); kf.Translate = scale * new Vector3(50f, 30f, 0f); AnimationState animState = scene.CreateAnimationState("an1"); //animState.Enabled = true; animStateList = new List <AnimationState>(); animStateList.Add(animState); trail.SetInitialColor(0, 1.0f, 0.8f, 0f, 1.0f); trail.SetColorChange(0, 0.5f, 0.5f, 0.5f, 0.5f); trail.SetInitialWidth(0, scale * 5f); trail.AddNode(animNode); // Add light Light light2 = scene.CreateLight("light2"); light2.Diffuse = trail.GetInitialColor(0); animNode.AttachObject(light2); // Add billboard BillboardSet bbs = scene.CreateBillboardSet("bb", 1); bbs.CreateBillboard(Vector3.Zero, trail.GetInitialColor(0)); bbs.MaterialName = "flare"; animNode.AttachObject(bbs); animNode = scene.RootSceneNode.CreateChildSceneNode(); animNode.Position = scale * new Vector3(-50f, 100f, 0f); anim = scene.CreateAnimation("an2", 10); anim.InterpolationMode = InterpolationMode.Spline; track = anim.CreateNodeTrack(1, animNode); kf = track.CreateNodeKeyFrame(0); kf.Translate = scale * new Vector3(-50f, 100f, 0f); kf = track.CreateNodeKeyFrame(2); kf.Translate = scale * new Vector3(-100f, 150f, -30f); kf = track.CreateNodeKeyFrame(4); kf.Translate = scale * new Vector3(-200f, 0f, 40f); kf = track.CreateNodeKeyFrame(6); kf.Translate = scale * new Vector3(0f, -150f, 70f); kf = track.CreateNodeKeyFrame(8); kf.Translate = scale * new Vector3(50f, 0f, 30f); kf = track.CreateNodeKeyFrame(10); kf.Translate = scale * new Vector3(-50f, 100f, 0f); animState = scene.CreateAnimationState("an2"); //animState.setEnabled(true); animStateList.Add(animState); trail.SetInitialColor(1, 0.0f, 1.0f, 0.4f, 1.0f); trail.SetColorChange(1, 0.5f, 0.5f, 0.5f, 0.5f); trail.SetInitialWidth(1, scale * 5f); trail.AddNode(animNode); // Add light Light light3 = scene.CreateLight("l3"); light3.Diffuse = trail.GetInitialColor(1); animNode.AttachObject(light3); // Add billboard bbs = scene.CreateBillboardSet("bb2", 1); bbs.CreateBillboard(Vector3.Zero, trail.GetInitialColor(1)); bbs.MaterialName = "flare"; animNode.AttachObject(bbs); }
void SetupTrailLights() { sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f); Vector3 dir = new Vector3(-1, -1, 0.5f); dir.Normalise(); Light l = sceneMgr.CreateLight("light1"); l.Type = Light.LightTypes.LT_DIRECTIONAL; l.Direction = dir; NameValuePairList pairList = new NameValuePairList(); pairList["numberOfChains"] = "2"; pairList["maxElements"] = "80"; RibbonTrail trail = (RibbonTrail)( sceneMgr.CreateMovableObject("1", "RibbonTrail", pairList)); trail.MaterialName = "Examples/LightRibbonTrail"; trail.TrailLength = 400; sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(trail); // Create 3 nodes for trail to follow SceneNode animNode = sceneMgr.RootSceneNode.CreateChildSceneNode(); animNode.Position = new Vector3(50, 30, 0); Animation anim = sceneMgr.CreateAnimation("an1", 14); anim.SetInterpolationMode(Animation.InterpolationMode.IM_SPLINE); NodeAnimationTrack track = anim.CreateNodeTrack(1, animNode); TransformKeyFrame kf = track.CreateNodeKeyFrame(0); kf.Translate = new Vector3(50, 30, 0); kf = track.CreateNodeKeyFrame(2); kf.Translate = new Vector3(100, -30, 0); kf = track.CreateNodeKeyFrame(4); kf.Translate = new Vector3(120, -100, 150); kf = track.CreateNodeKeyFrame(6); kf.Translate = new Vector3(30, -100, 50); kf = track.CreateNodeKeyFrame(8); kf.Translate = new Vector3(-50, 30, -50); kf = track.CreateNodeKeyFrame(10); kf.Translate = new Vector3(-150, -20, -100); kf = track.CreateNodeKeyFrame(12); kf.Translate = new Vector3(-50, -30, 0); kf = track.CreateNodeKeyFrame(14); kf.Translate = new Vector3(50, 30, 0); AnimationState animState = sceneMgr.CreateAnimationState("an1"); animState.Enabled = true; mAnimStateList.Add(animState); trail.SetInitialColour(0, 1.0f, 0.8f, 0); trail.SetColourChange(0, 0.5f, 0.5f, 0.5f, 0.5f); trail.SetInitialWidth(0, 5); trail.AddNode(animNode); // Add light Light l2 = sceneMgr.CreateLight("l2"); l2.DiffuseColour = (trail.GetInitialColour(0)); animNode.AttachObject(l2); // Add billboard BillboardSet bbs = sceneMgr.CreateBillboardSet("bb", 1); bbs.CreateBillboard(Vector3.ZERO, trail.GetInitialColour(0)); bbs.MaterialName = "Examples/Flare"; animNode.AttachObject(bbs); animNode = sceneMgr.RootSceneNode.CreateChildSceneNode(); animNode.Position = new Vector3(-50, 100, 0); anim = sceneMgr.CreateAnimation("an2", 10); anim.SetInterpolationMode(Animation.InterpolationMode.IM_SPLINE); track = anim.CreateNodeTrack(1, animNode); kf = track.CreateNodeKeyFrame(0); kf.Translate = new Vector3(-50, 100, 0); kf = track.CreateNodeKeyFrame(2); kf.Translate = new Vector3(-100, 150, -30); kf = track.CreateNodeKeyFrame(4); kf.Translate = new Vector3(-200, 0, 40); kf = track.CreateNodeKeyFrame(6); kf.Translate = new Vector3(0, -150, 70); kf = track.CreateNodeKeyFrame(8); kf.Translate = new Vector3(50, 0, 30); kf = track.CreateNodeKeyFrame(10); kf.Translate = new Vector3(-50, 100, 0); animState = sceneMgr.CreateAnimationState("an2"); animState.Enabled = true; mAnimStateList.Add(animState); trail.SetInitialColour(1, 0.0f, 1.0f, 0.4f); trail.SetColourChange(1, 0.5f, 0.5f, 0.5f, 0.5f); trail.SetInitialWidth(1, 5); trail.AddNode(animNode); // Add light l2 = sceneMgr.CreateLight("l3"); l2.DiffuseColour = trail.GetInitialColour(1); animNode.AttachObject(l2); // Add billboard bbs = sceneMgr.CreateBillboardSet("bb2", 1); bbs.CreateBillboard(Vector3.ZERO, trail.GetInitialColour(1)); bbs.MaterialName = "Examples/Flare"; animNode.AttachObject(bbs); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BillboardSet obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
private void SetupLighting() { scene.AmbientLight = new ColorEx(0.2f, 0.2f, 0.2f); Light = scene.CreateLight("Light2"); Light.DiffuseColour = MinLightColour; Light.SetAttenuation(8000, 1, 0.0005f, 0); Light.SpecularColour = new ColorEx(1, 1, 1); LightNode = scene.RootSceneNode.CreateChildSceneNode("MovingLightNode"); LightNode.AttachObject(Light); //create billboard set BillboardSet bbs = scene.CreateBillboardSet("lightbbs", 1); bbs.SetMaterialName("Examples/Flare"); Billboard bb = bbs.CreateBillboard(new Vector3(0, 0, 0), MinLightColour); LightNode.AttachObject(bbs); mLightController = new LightGrassWibbler(Light, bb, MinLightColour, this.MaxLightColour, MinFlareSize, MaxFlareSize); // create controller, after this is will get updated on its own //WaveformControllerFunction func = new WaveformControllerFunction(WaveformType.Sine, 0.0f, 0.5f); //ControllerManager.Instance.CreateController(val, func); LightNode.Position = new Vector3(300, 250, -300); Animation anim = scene.CreateAnimation("LightTrack", 20); //Spline it for nce curves anim.SetInterpolationMode(Animation.InterpolationMode.IM_SPLINE);// = Mogre.Animation.InterpolationMode.IM_SPLINE; //create a srtack to animte the camera's node NodeAnimationTrack track = anim.CreateNodeTrack(0, LightNode); //setup keyframes TransformKeyFrame key = track.CreateNodeKeyFrame(0); key.Translate = new Vector3(300, 550, -300); key = track.CreateNodeKeyFrame(2); //B key.Translate = new Vector3(150, 600, -250); key = track.CreateNodeKeyFrame(4); //C key.Translate = new Vector3(-150, 650, -100); key = track.CreateNodeKeyFrame(6); //D key.Translate = new Vector3(-400, 500, -200); key = track.CreateNodeKeyFrame(8); //E key.Translate = new Vector3(-200, 500, -400); key = track.CreateNodeKeyFrame(10); //F key.Translate = new Vector3(-100, 450, -200); key = track.CreateNodeKeyFrame(12); //G key.Translate = new Vector3(-100, 400, 180); key = track.CreateNodeKeyFrame(14); //H key.Translate = new Vector3(0, 250, 600); key = track.CreateNodeKeyFrame(16); //I key.Translate = new Vector3(100, 650, 100); key = track.CreateNodeKeyFrame(18); //J key.Translate = new Vector3(250, 600, 0); key = track.CreateNodeKeyFrame(20); //K == A key.Translate = new Vector3(300, 550, -300); // Create a new animation state to track this AnimState = scene.CreateAnimationState("LightTrack"); AnimState.Enabled = true; }
protected override void CreateScene() { // set ambient light off // scene.AmbientLight = new ColorEx(.5f, .5f, .5f); scene.AmbientLight = ColorEx.Black; // TODO: Check based on caps int currentAtheneMaterial = 0; // fixed light, dim if (showSunlight) { sunLight = scene.CreateLight("SunLight"); sunLight.Type = LightType.Directional; sunLight.Position = new Vector3(1000, 1250, 500); sunLight.SetSpotlightRange(30, 50); Vector3 dir = -sunLight.Position; dir.Normalize(); sunLight.Direction = dir; sunLight.Diffuse = new ColorEx(0.65f, 0.65f, 0.68f); sunLight.Specular = new ColorEx(0.9f, 0.9f, 1); } // point light, movable, reddish light = scene.CreateLight("Light2"); light.Diffuse = minLightColor; light.Specular = ColorEx.White; light.SetAttenuation(8000, 1, .0005f, 0); // create light node lightNode = scene.RootSceneNode.CreateChildSceneNode("MovingLightNode"); lightNode.AttachObject(light); // create billboard set BillboardSet bbs = scene.CreateBillboardSet("LightBBS", 1); bbs.MaterialName = "Examples/Flare"; Billboard bb = bbs.CreateBillboard(Vector3.Zero, minLightColor); // attach to the scene lightNode.AttachObject(bbs); // create controller, after this is will get updated on its own WaveformControllerFunction func = new WaveformControllerFunction(WaveformType.Sine, 0.75f, 0.5f); LightWibbler val = new LightWibbler(light, bb, minLightColor, maxLightColor, minFlareSize, maxFlareSize); ControllerManager.Instance.CreateController(val, func); lightNode.Position = new Vector3(300, 250, -300); // create a track for the light Animation anim = scene.CreateAnimation("LightTrack", 20); // spline it for nice curves anim.InterpolationMode = InterpolationMode.Spline; // create a track to animate the camera's node AnimationTrack track = anim.CreateNodeTrack(0, lightNode); // setup keyframes AddKey(track, 0, new Vector3(300, 250, -300)); AddKey(track, 2, new Vector3(150, 300, -250)); AddKey(track, 4, new Vector3(-150, 350, -100)); AddKey(track, 6, new Vector3(-400, 200, -200)); AddKey(track, 8, new Vector3(-200, 200, -400)); AddKey(track, 10, new Vector3(-100, 150, -200)); AddKey(track, 12, new Vector3(-100, 75, 180)); AddKey(track, 14, new Vector3(0, 250, 300)); AddKey(track, 16, new Vector3(100, 350, 100)); AddKey(track, 18, new Vector3(250, 300, 0)); AddKey(track, 20, new Vector3(300, 250, -300)); // create a new animation state to track this animState = scene.CreateAnimationState("LightTrack"); animState.IsEnabled = true; // Make light node look at origin, this is for when we // change the moving light to a spotlight lightNode.SetAutoTracking(true, scene.RootSceneNode); // lightSphereNode = scene.RootSceneNode.CreateChildSceneNode(); // lightSphere = scene.CreateEntity("LightSphere", "tiny_cube.mesh"); // lightSphereNode.AttachObject(lightSphere); // lightSphereNode.Position = new Vector3(300, 260, -300); // // create a track for the light sphere // Animation animSphere = scene.CreateAnimation("LightSphereTrack", 20); // // spline it for nice curves // animSphere.InterpolationMode = InterpolationMode.Spline; // // create a track to animate the camera's node // AnimationTrack trackSphere = animSphere.CreateTrack(0, lightSphereNode); // // setup keyframes // for (int i = 0; i <= 10; i++) { // Vector3 v = track.KeyFrames[i].Translate; // v.y += 10; // key = trackSphere.CreateKeyFrame(i * 2); // key.Translate = v; // } // // create a new animation state to track this // animSphereState = scene.CreateAnimationState("LightSphereTrack"); // animSphereState.IsEnabled = true; // // Make light node look at origin, this is for when we // // change the moving light to a spotlight // lightSphereNode.SetAutoTracking(true, scene.RootSceneNode); Mesh mesh = MeshManager.Instance.Load("athene.mesh"); short srcIdx, destIdx; // the athene mesh requires tangent vectors if (!mesh.SuggestTangentVectorBuildParams(out srcIdx, out destIdx)) { mesh.BuildTangentVectors(srcIdx, destIdx); } SceneNode node; //= scene.RootSceneNode.CreateChildSceneNode(); // athene = scene.CreateEntity("Athene", "athene.mesh"); // athene.MaterialName = atheneMaterials[currentAtheneMaterial]; // node.AttachObject(athene); // node.Translate(new Vector3(0, -20, 0)); // node.Yaw(90); Entity ent = null; node = scene.RootSceneNode.CreateChildSceneNode(); ent = scene.CreateEntity("Column1", "column.mesh"); ent.MaterialName = "Examples/Rockwall"; node.AttachObject(ent); node.Translate(new Vector3(200, 0, -200)); node = scene.RootSceneNode.CreateChildSceneNode(); ent = scene.CreateEntity("Column2", "column.mesh"); ent.MaterialName = "Examples/Rockwall"; node.AttachObject(ent); node.Translate(new Vector3(200, 0, 200)); node = scene.RootSceneNode.CreateChildSceneNode(); ent = scene.CreateEntity("Column3", "column.mesh"); ent.MaterialName = "Examples/Rockwall"; node.AttachObject(ent); node.Translate(new Vector3(-200, 0, -200)); node = scene.RootSceneNode.CreateChildSceneNode(); ent = scene.CreateEntity("Column4", "column.mesh"); ent.MaterialName = "Examples/Rockwall"; node.AttachObject(ent); node.Translate(new Vector3(-200, 0, 200)); scene.SetSkyBox(true, "Skybox/Stormy", 3000); Plane plane = new Plane(Vector3.UnitY, -100); MeshManager.Instance.CreatePlane( "MyPlane", plane, 1500, 1500, 20, 20, true, 1, 5, 5, Vector3.UnitZ); Entity planeEnt = scene.CreateEntity("Plane", "MyPlane"); planeEnt.MaterialName = "Examples/Rockwall"; planeEnt.CastShadows = false; scene.RootSceneNode.CreateChildSceneNode().AttachObject(planeEnt); if (Root.Instance.RenderSystem.Name.StartsWith("Axiom Direct")) { // In D3D, use a 1024x1024 shadow texture scene.SetShadowTextureSettings(1024, 2, PixelFormat.L16); } else { // Use 512x512 texture in GL since we can't go higher than the window res scene.SetShadowTextureSettings(512, 2, PixelFormat.L16); } // scene.ShadowColor = new ColorEx(0.5f, 0.5f, 0.5f); scene.ShadowColor = ColorEx.Black; scene.ShadowFarDistance = 1000f; // in case infinite far distance is not supported camera.Far = 100000; debugTextDelay = int.MaxValue; scene.ShadowTechnique = shadowTechniques[currentShadowTechnique]; ApplyShadowTechnique(); }
/// <summary> /// /// </summary> /// <param name="mgr"></param> /// <param name="rootSceneNode"></param> /// <param name="method"></param> public StaticBillboardSet(SceneManager mgr, SceneNode rootSceneNode, BillboardMethod method) { mSceneMgr = mgr; mRenderMethod = method; mVisible = true; mFadeEnabled = false; mBBOrigin = BillboardOrigin.Center; //Fall back to Compatible if vertex shaders are not available if (mRenderMethod == BillboardMethod.Accelerated) { RenderSystemCapabilities caps = Root.Singleton.RenderSystem.Capabilities; if (!caps.HasCapability(Capabilities.VertexPrograms)) { mRenderMethod = BillboardMethod.Compatible; } } mNode = rootSceneNode.CreateChildSceneNode(); mEntityName = GetUniqueID("SBSEntity"); if (mRenderMethod == BillboardMethod.Accelerated) { //Accelerated billboard method mEntity = null; mUFactor = 1.0f; mVFactor = 1.0f; //Load vertex shader to align billboards to face the camera (if not loaded already) if (++mSelfInstances == 1) { //First shader, simple camera-alignment HighLevelGpuProgram vertexShader = (HighLevelGpuProgram)HighLevelGpuProgramManager.Instance.GetByName("Sprite_vp"); if (vertexShader == null) { string vertexProg = string.Empty; vertexProg = "void Sprite_vp( \n"+ " float4 position : POSITION, \n"+ " float3 normal : NORMAL, \n"+ " float4 color : COLOR, \n"+ " float2 uv : TEXCOORD0, \n"+ " out float4 oPosition : POSITION, \n"+ " out float2 oUv : TEXCOORD0, \n"+ " out float4 oColor : COLOR, \n"+ " out float4 oFog : FOG, \n"+ " uniform float4x4 worldViewProj, \n"+ " uniform float uScroll, \n"+ " uniform float vScroll, \n"+ " uniform float4 preRotatedQuad[4] ) \n"+ "{ \n"+ //Face the camera " float4 vCenter = float4( position.x, position.y, position.z, 1.0f ); \n"+ " float4 vScale = float4( normal.x, normal.y, normal.x, 1.0f ); \n"+ " oPosition = mul( worldViewProj, vCenter + (preRotatedQuad[normal.z] * vScale) ); \n"+ //Color " oColor = color; \n"+ //UV Scroll " oUv = uv; \n"+ " oUv.x += uScroll; \n"+ " oUv.y += vScroll; \n"+ //Fog " oFog.x = oPosition.z; \n"+ "}"; vertexShader = HighLevelGpuProgramManager.Instance.CreateProgram( "Sprite_vp", ResourceGroupManager.DefaultResourceGroupName, "cg", GpuProgramType.Vertex); vertexShader.Source = vertexProg; vertexShader.SetParam("profiles", "vs_1_1 arbvp1"); vertexShader.SetParam("entry_point", "Sprite_vp"); vertexShader.Load(); } //Second shader, camera alignment and distance based fading HighLevelGpuProgram vertexShader2 = (HighLevelGpuProgram)HighLevelGpuProgramManager.Instance.GetByName("SpriteFade_vp"); if (vertexShader2 == null) { string vertexProg2 = string.Empty; vertexProg2 = "void SpriteFade_vp( \n"+ " float4 position : POSITION, \n"+ " float3 normal : NORMAL, \n"+ " float4 color : COLOR, \n"+ " float2 uv : TEXCOORD0, \n"+ " out float4 oPosition : POSITION, \n"+ " out float2 oUv : TEXCOORD0, \n"+ " out float4 oColor : COLOR, \n"+ " out float4 oFog : FOG, \n"+ " uniform float4x4 worldViewProj, \n"+ " uniform float3 camPos, \n"+ " uniform float fadeGap, \n"+ " uniform float invisibleDist, \n" + " uniform float uScroll, \n"+ " uniform float vScroll, \n"+ " uniform float4 preRotatedQuad[4] ) \n"+ "{ \n"+ //Face the camera " float4 vCenter = float4( position.x, position.y, position.z, 1.0f ); \n"+ " float4 vScale = float4( normal.x, normal.y, normal.x, 1.0f ); \n"+ " oPosition = mul( worldViewProj, vCenter + (preRotatedQuad[normal.z] * vScale) ); \n"+ " oColor.rgb = color.rgb; \n"+ //Fade out in the distance " float dist = distance(camPos.xz, position.xz); \n"+ " oColor.a = (invisibleDist - dist) / fadeGap; \n"+ //UV scroll " oUv = uv; \n"+ " oUv.x += uScroll; \n"+ " oUv.y += vScroll; \n"+ //Fog " oFog.x = oPosition.z; \n"+ "}"; vertexShader2 = HighLevelGpuProgramManager.Instance.CreateProgram( "SpriteFade_vp", ResourceGroupManager.DefaultResourceGroupName, "cg", GpuProgramType.Vertex); vertexShader2.Source = vertexProg2; vertexShader2.SetParam("profiles", "vs_1_1 arbvp1"); vertexShader2.SetParam("entry_point", "SpriteFade_vp"); vertexShader2.Load(); } } } else { //Compatible billboard method mFallbackSet = mSceneMgr.CreateBillboardSet(GetUniqueID("SBS"), 100); mNode.AttachObject(mFallbackSet); } }
void setupLighting() { /****/ // Set ambient light mSceneManager.SetAmbientLight(Converter.GetColor(0.2f, 0.2f, 0.2f)); // Point light, movable, reddish mLight = mSceneManager.CreateLight("Light2"); mLight.SetDiffuseColour(mMinLightColour); mLight.SetSpecularColour(1.0f, 1.0f, 1.0f); mLight.SetAttenuation(8000.0f, 1.0f, 0.0005f, 0.0f); // Create light node mLightNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode("MovingLightNode"); mLightNode.AttachObject(mLight); // create billboard set BillboardSet bbs = mSceneManager.CreateBillboardSet("lightbbs", 1); bbs.SetMaterialName("Examples/Flare"); Billboard bb = bbs.CreateBillboard(0, 0, 0, mMinLightColour); // attach mLightNode.AttachObject(bbs); // create controller, after this is will get updated on its own mWFCF = new WaveformControllerFunction(WaveformType.Sine, 0.0f, 0.5f); mCFFPtr = new ControllerFunctionFloatPtr(mWFCF); mLightWibbler = new LightWibbler(mLight, bb, mMinLightColour, mMaxLightColour, mMinFlareSize, mMaxFlareSize); mCVFPtr = new ControllerValueFloatPtr(mLightWibbler.mCVFH); ControllerManager contMgr = ControllerManager.GetSingleton(); mLightCtlFlt = contMgr.CreateController(contMgr.GetFrameTimeSource(), mCVFPtr, mCFFPtr); mLightNode.SetPosition(new Vector3(300, 250, -300)); // Create a track for the light Animation anim = mSceneManager.CreateAnimation("LightTrack", 20.0f); // Spline it for nice curves anim.SetInterpolationMode(Animation.InterpolationMode.Spline); // Create a track to animate the camera's node NodeAnimationTrack track = anim.CreateNodeTrack(0, mLightNode); // Setup keyframes TransformKeyFrame key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(0.0f)).Handle, false); // A startposition key.SetTranslate(new Vector3(300.0f, 550.0f, -300.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(2.0f)).Handle, false); //B key.SetTranslate(new Vector3(150.0f, 600.0f, -250.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(4.0f)).Handle, false); //C key.SetTranslate(new Vector3(-150.0f, 650.0f, -100.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(6.0f)).Handle, false); //D key.SetTranslate(new Vector3(-400.0f, 500.0f, -200.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(8.0f)).Handle, false); //E key.SetTranslate(new Vector3(-200.0f, 500.0f, -400.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(10.0f)).Handle, false); //F key.SetTranslate(new Vector3(-100.0f, 450.0f, -200.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(12.0f)).Handle, false); //G key.SetTranslate(new Vector3(-100.0f, 400.0f, 180.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(14.0f)).Handle, false); //H key.SetTranslate(new Vector3(0.0f, 250.0f, 600.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(16.0f)).Handle, false); //I key.SetTranslate(new Vector3(100.0f, 650.0f, 100.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(18.0f)).Handle, false); //J key.SetTranslate(new Vector3(250.0f, 600.0f, 0.0f)); key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(20.0f)).Handle, false); //K == A key.SetTranslate(new Vector3(300.0f, 550.0f, -300.0f)); // Create a new animation state to track this mAnimState = mSceneManager.CreateAnimationState("LightTrack"); mAnimState.SetEnabled(true); /****/ }
// Just override the mandatory create scene method protected override void CreateScene() { RAND = new Random(0); // najak: use a time-based seed GuiMgr = OverlayElementManager.Instance; scene.AmbientLight = new ColorEx(0.75f, 0.75f, 0.75f); // default Ambient Light // Customize Controls - speed up camera and slow down the input update rate this.camSpeed = 5.0f; inputInterval = inputTimer = 0.02f; // Create water mesh and entity, and attach to sceneNode waterMesh = new WaterMesh("WaterMesh", PLANE_SIZE, CMPLX); waterEntity = scene.CreateEntity("WaterEntity", "WaterMesh"); SceneNode waterNode = scene.RootSceneNode.CreateChildSceneNode(); waterNode.AttachObject(waterEntity); // Add Ogre head, give it it's own node headNode = waterNode.CreateChildSceneNode(); Entity ent = scene.CreateEntity("head", "ogrehead.mesh"); headNode.AttachObject(ent); // Create the camera node, set its position & attach camera camera.Yaw(-45f); camera.Move(new Vector3(1500f, 700f, PLANE_SIZE + 700f)); camera.LookAt(new Vector3(PLANE_SIZE / 2f, 300f, PLANE_SIZE / 2f)); camera.SetAutoTracking(false, headNode); // Autotrack the head, but it isn't working right //scene.SetFog(FogMode.Exp, ColorEx.White, 0.000020f); // add Fog for fun, cuz we can // show overlay waterOverlay = (Overlay)OverlayManager.Instance.GetByName("Example/WaterOverlay"); waterOverlay.Show(); // Create Rain Emitter, but default Rain to OFF particleSystem = ParticleSystemManager.Instance.CreateSystem("rain", "Examples/Water/Rain"); particleEmitter = particleSystem.GetEmitter(0); particleEmitter.EmissionRate = 0f; // Attach Rain Emitter to SceneNode, and place it 3000f above the water surface SceneNode rNode = scene.RootSceneNode.CreateChildSceneNode(); rNode.Translate(new Vector3(PLANE_SIZE / 2.0f, 3000, PLANE_SIZE / 2.0f)); rNode.AttachObject(particleSystem); particleSystem.FastForward(20); // Fastforward rain to make it look natural // It can't be set in .particle file, and we need it ;) particleSystem.BillboardOrigin = BillboardOrigin.BottomCenter; // Set Lighting lightNode = scene.RootSceneNode.CreateChildSceneNode(); lightSet = scene.CreateBillboardSet("Lights", 20); lightSet.MaterialName = "Particles/Flare"; lightNode.AttachObject(lightSet); SetLighting("Ambient"); // Add Lights - added by Najak to show lighted Water conditions - cool! #region STUBBED LIGHT ANIMATION // Create a new animation state to track this // TODO: Light Animation not working. //this.animState = scene.CreateAnimationState("WaterLight"); //this.animState.Time = 0f; //this.animState.IsEnabled = false; // set up spline animation of light node. Create random Spline Animation anim = scene.CreateAnimation("WaterLight", 20); NodeAnimationTrack track = anim.CreateNodeTrack(0, this.lightNode); TransformKeyFrame key = (TransformKeyFrame)track.CreateKeyFrame(0); for (int ff = 1; ff <= 19; ff++) { key = (TransformKeyFrame)track.CreateKeyFrame(ff); Random rand = new Random(0); Vector3 lpos = new Vector3( (float)rand.NextDouble() % (int)PLANE_SIZE, //- PLANE_SIZE/2, (float)rand.NextDouble() % 300 + 100, (float)rand.NextDouble() % (int)PLANE_SIZE); //- PLANE_SIZE/2 key.Translate = lpos; } key = (TransformKeyFrame)track.CreateKeyFrame(20); #endregion STUBBED LIGHT ANIMATION // Initialize the Materials/Demo UpdateMaterial(); UpdateInfoParamC(); UpdateInfoParamD(); UpdateInfoParamU(); UpdateInfoParamT(); UpdateInfoNormals(); UpdateInfoHeadDepth(); UpdateInfoSkyBox(); UpdateInfoHeadSpeed(); UpdateInfoLights(); UpdateInfoTracking(); // Init Head Animation: Load adds[] elements - Ogre head animation adds[0] = 0.3f; adds[1] = -1.6f; adds[2] = 1.1f; adds[3] = 0.5f; sines[0] = 0; sines[1] = 100; sines[2] = 200; sines[3] = 300; } // end CreateScene()
/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="owner"></param> /// <param name="color"></param> public Billboard(Vector3 position, BillboardSet owner, ColorEx color) { this.Color = color; this.Position = position; this.ParentSet = owner; }
/// <summary> /// Internal method for notifying a billboard of it's owner. /// </summary> /// <param name="owner"></param> internal void NotifyOwner(BillboardSet owner) { ParentSet = owner; }
/// <summary> /// Buduje testow¹ scenê /// </summary> public override void CreateScene() { //float cameraDistance = 50.0f; // mgr.LoadWorldGeometry("Terrain.xml"); //sceneMgr.AmbientLight = ColourValue.Black; ; //; new ColourValue(1.0f, 1.0f, 1.0f); // Set the material sceneMgr.SetSkyBox(true, "Skybox/Morning", 5000); sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f); // create a default point light Light light = sceneMgr.CreateLight("MainLight"); light.Type = Light.LightTypes.LT_DIRECTIONAL; light.Position = new Vector3(0, 1000, 0); light.Direction = new Vector3(0, -5, 0); light.DiffuseColour = new ColourValue(1.0f, 1.0f, 1.0f); light.SpecularColour = new ColourValue(0.05f, 0.05f, 0.05f); // OCEAN Plane plane = new Plane(); plane.normal = Vector3.UNIT_Y; plane.d = 0; MeshManager.Singleton.CreatePlane("OceanPlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, 5000, 5000, 10, 10, true, 1, 10, 10, Vector3.UNIT_Z); Entity ocean = sceneMgr.CreateEntity("Ocean", "OceanPlane"); ocean.SetMaterialName("Ocean2_HLSL"); ocean.CastShadows = false; sceneMgr.RootSceneNode.AttachObject(ocean); // OCEAN ViewHelper.AttachAxes(sceneMgr, sceneMgr.RootSceneNode, 0.001f); // CARRIER Entity carrier2 = minimapMgr.CreateEntity("Carrier", "Carrier.mesh"); Entity carrier = sceneMgr.CreateEntity("Carrier", "Carrier.mesh"); Entity carrierAerial1 = sceneMgr.CreateEntity("CarrierAerial1", "Aerial1.mesh"); Entity carrierAerial2 = sceneMgr.CreateEntity("CarrierAerial2", "Aerial2.mesh"); Entity lWaterTrail = sceneMgr.CreateEntity("LWaterTrail", "TwoSidedPlane.mesh"); lWaterTrail.CastShadows = false; lWaterTrail.SetMaterialName("Effects/WaterTrail"); Entity rWaterTrail = sceneMgr.CreateEntity("RWaterTrail", "TwoSidedPlane.mesh"); rWaterTrail.CastShadows = false; rWaterTrail.SetMaterialName("Effects/WaterTrail"); carrierNode = sceneMgr.RootSceneNode.CreateChildSceneNode("Carrier"); carrierNode.AttachObject(carrier); carrierAerial1Node = carrierNode.CreateChildSceneNode("carrierAerial1Node", new Vector3(-8.6f, 9.1f, 5.7f)); carrierAerial1Node.AttachObject(carrierAerial1); carrierAerial2Node = carrierNode.CreateChildSceneNode("carrierAerial2Node", new Vector3(-10.7f, 4.0f, 12.6f)); carrierAerial2Node.AttachObject(carrierAerial2); lCarrierWaterTrailNode = carrierNode.CreateChildSceneNode("lCarrierWaterTrailNode", new Vector3(-4.6f, -4.8f, -40.0f)); lCarrierWaterTrailNode.AttachObject(lWaterTrail); lCarrierWaterTrailNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Math.HALF_PI); lCarrierWaterTrailNode.Scale(2.0f, 1f, 1.5f); rCarrierWaterTrailNode = carrierNode.CreateChildSceneNode("rCarrierWaterTrailNode", new Vector3(4.6f, -4.8f, -40.0f)); rCarrierWaterTrailNode.AttachObject(rWaterTrail); rCarrierWaterTrailNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Math.HALF_PI); rCarrierWaterTrailNode.Scale(2.0f, 1f, 1.5f); carrierNode.Translate(new Vector3(100, 5, 0)); carrierNode.SetDirection(Vector3.UNIT_X); // CARRIER // ISLAND1 /* Entity island = sceneMgr.CreateEntity("Island1", "Island3.mesh"); * * islandNode = sceneMgr.RootSceneNode.CreateChildSceneNode("Island1"); * islandNode.AttachObject(island); * islandNode.Translate(new Vector3(-100, 1.35f, 0)); * islandNode.SetDirection(Vector3.UNIT_X);*/ // ISLAND2 /* Entity island2 = sceneMgr.CreateEntity("Island2", "Island2.mesh"); * * island2Node = sceneMgr.RootSceneNode.CreateChildSceneNode("Island2"); * island2Node.AttachObject(island2); * island2Node.Translate(new Vector3(-170, -0.35f, 0)); * island2Node.SetDirection(Vector3.UNIT_X);*/ // ISLAND3 Entity island3 = sceneMgr.CreateEntity("Island3", "Island5.mesh"); island3Node = sceneMgr.RootSceneNode.CreateChildSceneNode("Island3"); island3Node.AttachObject(island3); island3Node.Translate(new Vector3(-460, 1.35f, 0)); island3Node.SetDirection(Vector3.UNIT_X); // ISLAND4 Entity island6 = sceneMgr.CreateEntity("Island6", "Island6.mesh"); islandNode = sceneMgr.RootSceneNode.CreateChildSceneNode("Island6"); islandNode.AttachObject(island6); islandNode.Translate(new Vector3(-200, 5.35f, 0)); islandNode.SetDirection(Vector3.UNIT_X); float rot, xpos, zpos, ypos; // WOODEN BUNKER INSTALLATION gunEmplacementNode = islandNode.CreateChildSceneNode("GunEmplacement", new Vector3(0.0f, 1.1f, 5.0f)); Entity sandbags = sceneMgr.CreateEntity("Sandbags", "Sandbags.mesh"); gunEmplacementNode.AttachObject(sandbags); woodenBunkerNode = gunEmplacementNode.CreateChildSceneNode("WoodenBunkerNode", new Vector3(0, 0.0f, 4.0f)); Entity woodenBunker = sceneMgr.CreateEntity("WoodenBunker", "Bunker.mesh"); // woodenBunker.SetMaterialName("Concrete"); // aby by³ betonowy woodenBunkerNode.AttachObject(woodenBunker); Entity flakBase = sceneMgr.CreateEntity("FlakBase", "FlakBase.mesh"); gunEmplacementNode.AttachObject(flakBase); flakBarrel = sceneMgr.CreateEntity("FlakBarrel", "FlakBarrel.mesh"); flakBarrelNode = gunEmplacementNode.CreateChildSceneNode("FlakBarrelNode", new Vector3(0, 0.5f, 0)); flakBarrelNode.AttachObject(flakBarrel); // WOODEN BUNKER INSTALLATION // PALM TREES SceneNode palmNode; Entity palm; for (int i = 0; i < 150; i++) { palm = sceneMgr.CreateEntity("Palm" + i, "PalmTree.mesh"); rot = Math.RangeRandom(-90.0f, 90.0f); zpos = Math.RangeRandom(-200.0f, 200.0f); xpos = Math.RangeRandom(-10.0f, 10.0f); ypos = Math.RangeRandom(0.1f, 0.3f); palmNode = islandNode.CreateChildSceneNode("PalmNode" + i, new Vector3(xpos, ypos, zpos)); palmNode.Rotate(Vector3.UNIT_Y, rot); palmNode.Scale(1, Math.RangeRandom(0.9f, 1.1f), 1); palmNode.AttachObject(palm); } //islandNode.Scale(2.0f, 2.0f, 2.0f); // PALM TREES // JAPAN FLAG Entity japanFlag = sceneMgr.CreateEntity("JapanFlag", "JapanFlag.mesh"); japanFlagNode = islandNode.CreateChildSceneNode("JapanFlagNode", new Vector3(0, 1, -5)); japanFlagNode.Rotate(Vector3.UNIT_Y, Math.PI); japanFlagNode.AttachObject(japanFlag); japanFlagState = japanFlag.GetAnimationState("idle"); japanFlagState.Enabled = true; japanFlagState.Loop = true; // JAPAN FLAG // TENT - just for fun // ??? Entity tent = sceneMgr.CreateEntity("Tent", "Barracks.mesh"); tentNode = islandNode.CreateChildSceneNode("TentNode", new Vector3(0, 1, 17)); tentNode.AttachObject(tent); // TENT // SOLDIERS SceneNode soldierNode; Entity soldier; soldiersState = new AnimationState[15]; for (int i = 0; i < soldiersState.Length; i++) { soldier = sceneMgr.CreateEntity("Soldier" + i, "Soldier.mesh"); if (i % 3 == 0) { soldier.SetMaterialName("General"); } rot = Math.RangeRandom(-30.0f, 30.0f); zpos = Math.RangeRandom(-10.0f, 20.0f); xpos = Math.RangeRandom(-0.0f, 1.0f); ypos = 0.8f; soldierNode = SceneMgr.RootSceneNode.CreateChildSceneNode("SoldierNode" + i, new Vector3(xpos, ypos, zpos)); soldierNode.Rotate(Vector3.UNIT_Y, rot); soldierNode.AttachObject(soldier); switch (i % 3) { case 0: soldiersState[i] = soldier.GetAnimationState("run"); break; case 1: soldiersState[i] = soldier.GetAnimationState("die1"); break; case 2: soldiersState[i] = soldier.GetAnimationState("die2"); break; } soldiersState[i].Loop = true; soldiersState[i].Enabled = true; } //islandNode.Scale(0.7f, 0.7f, 0.7f); // SOLDIERS /*d * BillboardSet skies = SceneManager.CreateBillboardSet("Sky",1); * skies.MaterialName = "Skyplane/Morning"; * Billboard sky = skies.CreateBillboard(new Vector3(0.0f, 0.0f, -100.0f)); * SceneManager.RootSceneNode.AttachObject(skies); */ ////////////////////////////////////////////////////// // A6M /* * a6m = sceneMgr.CreateEntity("A6M", "A6M.mesh"); * a6mNode = sceneMgr.RootSceneNode.CreateChildSceneNode("EnemyNode"); * a6mNode.AttachObject(a6m); * * * // AIRSCREW * enemyAirscrewNode = a6mNode.CreateChildSceneNode("EnemyAirscrew", new Vector3(0.0f, 0.0f, -5.70f)); * * Entity enemyAirscrew = sceneMgr.CreateEntity("EnemyAirscrew", "Airscrew.mesh"); * enemyAirscrew.SetMaterialName("A6M/Airscrew"); * enemyAirscrew.CastShadows = false; * enemyAirscrewNode.AttachObject(enemyAirscrew); * // AIRSCREW * * * a6mNode.LookAt(Vector3.NEGATIVE_UNIT_X, Node.TransformSpace.TS_WORLD); * * * a6mNode.Scale(new Vector3(0.5f, 0.5f, 0.5f)); * a6mNode.Position = new Vector3(0, 13.0f, 0); * ViewHelper.AttachAxes(sceneMgr, a6mNode, 1.5f); */ // A6M ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// // P47 p47 = sceneMgr.CreateEntity("P47Body", "P47Body.mesh"); playerNode = sceneMgr.RootSceneNode.CreateChildSceneNode("PlayerNode", new Vector3(350, 0, 0)); p47OuterNode = playerNode.CreateChildSceneNode("OuterNode"); p47InnerNode = p47OuterNode.CreateChildSceneNode("InnerNode"); p47InnerNode.AttachObject(p47); p47OuterNode.Scale(new Vector3(0.5f, 0.5f, 0.5f)); p47OuterNode.LookAt(Vector3.NEGATIVE_UNIT_X, Node.TransformSpace.TS_WORLD); // SMOKE ParticleSystem smokeSystem = sceneMgr.CreateParticleSystem("SmokeSystem", "Smokes/Smoke"); SceneNode smokeNode = playerNode.CreateChildSceneNode("Smoke", new Vector3(0.0f, 0.0f, 3.0f)); smokeSystem.GetEmitter(0).Direction = new Vector3(0.0f, 0.0f, 1.0f); smokeNode.AttachObject(smokeSystem); // SMOKE // ANIMATION // p47AnimationState = p47.GetAnimationState("manual"); // p47AnimationState.Loop = true; // p47AnimationState.Enabled = true; // ANIMATION // BLADE bladeNode = p47InnerNode.CreateChildSceneNode("Blade", new Vector3(0.0f, 0.0f, -7.0f)); Entity p47Blade = sceneMgr.CreateEntity("Blade", "P47Blade.mesh"); bladeNode.AttachObject(p47Blade); p47Blade.Visible = false; // tylko kiedy niskie obroty // BLADE // AIRSCREW Entity airscrew = sceneMgr.CreateEntity("Airscrew", "Airscrew.mesh"); airscrew.CastShadows = false; bladeNode.AttachObject(airscrew); // AIRSCREW // GUNHIT Entity lGunHit = sceneMgr.CreateEntity("LGunHit", "TwoSidedPlane.mesh"); lGunHit.CastShadows = false; lGunHit.SetMaterialName("Effects/GunHit"); Entity rGunHit = sceneMgr.CreateEntity("RGunHit", "TwoSidedPlane.mesh"); rGunHit.CastShadows = false; rGunHit.SetMaterialName("Effects/GunHit"); lGunHitNode = p47InnerNode.CreateChildSceneNode("lGunHitNode", new Vector3(-4.0f, -0.5f, -4.2f)); lGunHitNode.AttachObject(lGunHit); lGunHitNode.Rotate(Vector3.NEGATIVE_UNIT_Z, Math.HALF_PI); lGunHitNode.Scale(0.5f, 0.5f, 0.7f); rGunHitNode = p47InnerNode.CreateChildSceneNode("rGunHitNode", new Vector3(4.0f, -0.5f, -4.2f)); rGunHitNode.AttachObject(rGunHit); rGunHitNode.Rotate(Vector3.NEGATIVE_UNIT_Z, Math.HALF_PI); rGunHitNode.Scale(0.5f, 0.5f, 0.7f); // GUNHIT // WHEELS lWheelNode = p47InnerNode.CreateChildSceneNode("LeftWheel", new Vector3(-3.0f, -1.6f, -2.3f), new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X)); Entity lWheel = sceneMgr.CreateEntity("lWheel", "Wheel.mesh"); lWheelNode.AttachObject(lWheel); rWheelNode = p47InnerNode.CreateChildSceneNode("RightWheel", new Vector3(3.0f, -1.6f, -2.3f), new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X)); rWheelNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Math.DegreesToRadians(180)); Entity rWheel = sceneMgr.CreateEntity("rWheel", "Wheel.mesh"); rWheelNode.AttachObject(rWheel); rearWheelNode = p47OuterNode.CreateChildSceneNode("RearWheel", new Vector3(0.0f, -0.6f, 5.3f), new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X)); // rearWheelNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Mogre.Math.DegreesToRadians(180)); Entity rearWheel = sceneMgr.CreateEntity("rearWheele", "Wheel.mesh"); rearWheelNode.AttachObject(rearWheel); rearWheelNode.Scale(0.7f, 0.7f, 0.7f); // WHEELS // ViewHelper.AttachAxes(sceneMgr, p47InnerNode, 1.5f); playerNode.Position = new Vector3(0, 10.0f, 0); // p47Animation = new PlaneAnimationManager(0, new PlayerPlaneViewnew Wof.Model.Level.Planes.Plane(),this,playerNode,); // p47Animation.enableAll(); // p47Animation.switchTo(PlaneAnimationManager.AnimationType.IDLE); // p47Animation.Enabled = false; // CAMERA cameraNode = playerNode.CreateChildSceneNode("Camera"); cameraNode.AttachObject(camera); cameraNode.Translate(new Vector3(0, 0, 100)); // sceneMgr.RootSceneNode.AttachObject(camera); // P47 ////////////////// // CHMURY BillboardSet clouds1 = sceneMgr.CreateBillboardSet("Clouds1"); clouds1.MaterialName = "Effects/Cloud1"; for (int i = -11; i < 11; i += 2) { Billboard cloud1 = (Billboard)clouds1.CreateBillboard(i * 10, 100 + Math.RangeRandom(-50, 50), -500); cloud1.SetDimensions(200 + Math.RangeRandom(-i, i), 100 + Math.RangeRandom(-i, 0)); cloud1.Rotation = Math.DegreesToRadians(Math.RangeRandom(5, 5)); } sceneMgr.RootSceneNode.AttachObject(clouds1); BillboardSet clouds2 = sceneMgr.CreateBillboardSet("Clouds2"); clouds2.MaterialName = "Effects/Cloud2"; for (int i = -10; i < 10; i += 2) { Billboard cloud2 = clouds2.CreateBillboard(i * 100, 100 + Math.RangeRandom(-50, 50), -500); cloud2.SetDimensions(200 + Math.RangeRandom(-i, i), 100 + Math.RangeRandom(-i, 0)); cloud2.Rotation = Math.DegreesToRadians(Math.RangeRandom(5, 5)); } sceneMgr.RootSceneNode.AttachObject(clouds2); }