public virtual void Destroy(bool smoke, bool firePossibility, bool switchToDieAnimationState) { Vector3 windDirection = new Vector3(-0.35f, 1, 0); // dzieki temu dym nie zaslania obiektow gdy mamy kamere za samolotem if (installationEntity != null && switchToDieAnimationState && installationEntity.HasVertexAnimation) { animationState = installationEntity.GetAnimationState("die"); if (animationState != null) { animationState.Enabled = true; animationState.Loop = false; } } if (smoke) { smokeParticleSystem = EffectsManager.Singleton.Smoke(sceneMgr, installationNode, new Vector3(0, -1, 0), windDirection); } SetLightFlareVisibility(false); if (firePossibility && Math.RangeRandom(0.0f, 1.0f) > 0.8f) { EffectsManager.Singleton.Sprite(sceneMgr, InstallationNode, new Vector3(2, 2.4f, Math.RangeRandom(-4, 4)), new Vector2(5, 5), EffectsManager.EffectType.FIRE, true, 0); } }
public void OnShipDamaged(ShipState state) { float length = this.tileViews.Count * LevelTile.TileWidth; switch (state) { case ShipState.LightDamaged: { EffectsManager.Singleton.Smoke(sceneMgr, staticNode, Effects.EffectsManager.SmokeType.NORMAL, new Vector3(0, 6, -Mogre.Math.RangeRandom(0, length)), Vector3.UNIT_Y, new Vector2(15, 15)); EffectsManager.Singleton.Smoke(sceneMgr, staticNode, Effects.EffectsManager.SmokeType.LIGHTSMOKE, new Vector3(0, 6, -Mogre.Math.RangeRandom(0, length)), Vector3.UNIT_Y, new Vector2(3, 3)); } break; case ShipState.HeavyDamage: { for (uint i = 0; i < 6; i++) { EffectsManager.Singleton.Sprite(sceneMgr, staticNode, new Vector3(Math.RangeRandom(-3, 3), 8.0f, -Mogre.Math.RangeRandom(0, length)), new Vector2(Math.RangeRandom(5, 10), Math.RangeRandom(5, 10)), EffectsManager.EffectType.FIRE, true, i.ToString()); } } break; } }
public static void BubblesWaterAnimation(SceneManager sceneMgr, Vector3 pos, string baseName, int count, Vector2 range, Vector2 size) { Vector2 sizeRand; string name; for (uint i = 0; i < count; i++) { float h = Mogre.Math.RangeRandom(-20, -5); float angle = Mogre.Math.RangeRandom(-10, 10); Vector2 rand = ViewHelper.RandomVector2(range.x, range.y); Vector3 posView = new Vector3(pos.x + rand.x, pos.y + h, pos.z + rand.y); name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, EffectsManager.EffectType.BUBBLES, baseName + "_bubbles_" + i); NodeAnimation.NodeAnimation node = EffectsManager.Singleton.GetEffect(name); if (!EffectsManager.Singleton.EffectExists(name) || (node != null && node.Ended)) { sizeRand = size * Math.RangeRandom(0.9f, 1.1f); VisibilityNodeAnimation ani = EffectsManager.Singleton.RectangularEffect(sceneMgr, sceneMgr.RootSceneNode, baseName + "_bubbles_" + i, EffectsManager.EffectType.BUBBLES, posView, sizeRand, new Quaternion(new Radian(new Degree(90)), Vector3.UNIT_X) * new Quaternion(new Radian(new Degree(angle)), Vector3.UNIT_Y), false); ani.Duration = Mogre.Math.RangeRandom(ani.Duration, 2 * ani.Duration); ani.TimeScale = Mogre.Math.RangeRandom(0.5f, 1.5f); } } }
public override void animate() { if (!enabled) { return; } float power = 0; frameInit(); // percent, percentAfter, delta and enabled are now set if (!enabled) { // if frame init finished the animation FirstNode.SetPosition(initialPosition.x, initialPosition.y, initialPosition.z); } float amplitude = animationFunction(percentAfter * cycleLength.ValueRadians); startNewLoop = false; // Console.WriteLine("Amplitude: " + amplitude); foreach (SceneNode node in Nodes) { node.Translate(amplitude * Math.RangeRandom(-maxPower, maxPower), amplitude * Math.RangeRandom(-maxPower, maxPower), amplitude * Math.RangeRandom(-maxPower, maxPower)); } lastAmplitude = amplitude; }
public void rewindToRandom() { animationTime = Math.RangeRandom(0, duration); delta = 0; percent = getPercent(); percentAfter = 0; lastAmplitude = 0; timeSinceLastFrame = -1; }
private void initNonCollisionTreesCircle(SceneManager sceneMgr, SceneNode parent, float radius, float intensity, bool forceLowDetails) { int c = (int)Math.Abs(count); int count_l = (int)(c * 2 * intensity); for (int i = 0; i < count_l; i++) { initPalm2(sceneMgr, parent, new Vector3(Math.RangeRandom(-radius, radius), -0.5f, Math.RangeRandom(-radius, radius) - 25), forceLowDetails); } }
protected virtual void GunFireDo(Vector3 localPos, Vector2 expSize, float baseWidth) { Quaternion orient, trailOrient; orient = new Quaternion(-Math.HALF_PI, Vector3.UNIT_Y); trailOrient = new Quaternion(-Math.HALF_PI, Vector3.UNIT_Y); trailOrient *= new Quaternion(-Math.HALF_PI, Vector3.UNIT_X); EffectsManager.Singleton.RectangularEffect(sceneMgr, this.gunNode, "GunHit" + localPos, EffectsManager.EffectType.GUNHIT2, localPos, expSize, orient, false); float trailWidth = baseWidth * Math.RangeRandom(1.0f, 1.1f); string trailName = EffectsManager.BuildSpriteEffectName(this.gunNode, EffectsManager.EffectType.GUNTRAIL, "GunTrail" + localPos); bool showTrail = EffectsManager.Singleton.EffectEnded(trailName) || !EffectsManager.Singleton.EffectExists(trailName); showTrail |= (Math.RangeRandom(0.0f, 1.0f) > 0.95f); // czasem przerwij efekt i zacznij od poczatku showTrail = false; Vector3 trailBase = new Vector3(localPos.x, 0.0f, localPos.z - trailWidth * 0.5f); if (showTrail) { EffectsManager.Singleton.RectangularEffect(sceneMgr, this.gunNode, "GunTrail" + localPos, EffectsManager.EffectType.GUNTRAIL, trailBase - new Vector3(0, -1.0f, Math.RangeRandom(0.2f, 3.0f)), new Vector2(trailWidth, 1.2f), trailOrient, false); } orient *= new Quaternion(Math.HALF_PI, Vector3.UNIT_X); trailOrient *= new Quaternion(Math.HALF_PI, Vector3.UNIT_X); EffectsManager.Singleton.RectangularEffect(sceneMgr, this.gunNode, "GunHitTop" + localPos, EffectsManager.EffectType.GUNHIT2, localPos, expSize, orient, false); if (showTrail) { EffectsManager.Singleton.RectangularEffect(sceneMgr, this.gunNode, "GunTrailTop" + localPos, EffectsManager.EffectType.GUNTRAIL, trailBase - new Vector3(0, -1.0f, Math.RangeRandom(0.2f, 3.0f)), new Vector2(trailWidth, 1.2f), trailOrient, false); } }
public static SceneNode initPalm(SceneManager sceneMgr, SceneNode parent, Vector3 position, bool forceLowDetails, bool rayBasedY) { Entity palm; SceneNode palmNode; /* if(rayBasedY) * { * position = ViewHelper.GetVerticalRayIntersection(sceneMgr, parent, position); * }*/ int id = LevelView.PropCounter; if (EngineConfig.LowDetails || forceLowDetails) { palm = sceneMgr.CreateEntity("Palm" + id, "TwoSidedPlane.mesh"); palm.SetMaterialName("FakePalmTree"); } else { palm = sceneMgr.CreateEntity("Palm" + id, "PalmTree.mesh"); } palm.CastShadows = EngineConfig.ShadowsQuality > 0; palmNode = parent.CreateChildSceneNode("PalmNode" + LevelView.PropCounter, position); if (EngineConfig.LowDetails || forceLowDetails) { float angle = Math.RangeRandom(-Math.PI / 5, Math.PI / 5); palmNode.Yaw(Math.HALF_PI + angle); palmNode.Scale(0.5f, 1, 1); palmNode.Translate(new Vector3(0, 2.5f, 0)); palmNode.Pitch(-Math.HALF_PI); //palmNode.Pitch(Math.PI); Quaternion q = new Quaternion(new Radian(new Degree(20)), Vector3.UNIT_X); Quaternion q2 = new Quaternion(new Radian(new Degree(-20)), Vector3.UNIT_X); EffectsManager.Singleton.RectangularEffect(sceneMgr, parent, "0", EffectsManager.EffectType.PALMTOP1, position + new Vector3(0f, 4.0f, -0.0f), new Vector2(1.4f, 1.4f), q, true).FirstNode.Yaw(angle); EffectsManager.Singleton.RectangularEffect(sceneMgr, parent, "1", EffectsManager.EffectType.PALMTOP1, position + new Vector3(0f, 4.0f, -0.0f), new Vector2(1.4f, 1.4f), q2, true).FirstNode.Yaw(angle); } else { palmNode.Rotate(Vector3.UNIT_Y, Math.RangeRandom(0.0f, Math.PI)); palmNode.Scale(1, Math.RangeRandom(0.9f, 1.1f), 1); } palmNode.AttachObject(palm); return(palmNode); }
public override void updateTime(float timeSinceLastFrameUpdate) { base.updateTime(timeSinceLastFrameUpdate); BunkerTile bunkerTile = (BunkerTile)levelTile; float yaw = 0; float pitch = bunkerTile.Angle; if (bunkerTile is FlakBunkerTile) { FlakBunkerTile fbt = (bunkerTile as FlakBunkerTile); yaw = fbt.YAngle; if (fbt.Direction == Direction.Left) // jesli dzialko jest w polowie obrotu { pitch = Math.PI - pitch; } } rotateGun(pitch, yaw); if (bunkerTile.UsingReflector) { rotateReflector(bunkerTile.ReflectorAngle); if (bunkerTile.IsIlluminatedShot) { foreach (SceneNode n in reflectorSubNodes) { n.SetScale(54.0f, 1.0f, 14.0f); } } else { foreach (SceneNode n in reflectorSubNodes) { n.SetScale(24.0f, 1.0f, 10.0f); } } if ((bunkerTile.IsDestroyed && reflectorNode != null) && flickeringReflectorWhenDestroyed) { if (Math.RangeRandom(0.0f, 1.0f) > 0.9f) { reflectorNode.SetVisible(false); } if (Math.RangeRandom(0.0f, 1.0f) > 0.9f) { reflectorNode.SetVisible(true); } } } }
protected void WaterSplashes(int splashesCount, LevelTile tile) { Vector2 v = UnitConverter.LogicToWorldUnits(new PointD(Mathematics.IndexToPosition(tile.TileIndex), 1.5f)); string name; for (uint i = 0; i < splashesCount; i++) { Vector2 rand = ViewHelper.RandomVector2(8, 8); Vector3 posView = new Vector3(v.x + rand.x, v.y, 0 + rand.y); name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, EffectsManager.EffectType.SUBMERGE, tile.GetHashCode() + "_" + i); if (!EffectsManager.Singleton.EffectExists(name) || EffectsManager.Singleton.EffectEnded(name)) { EffectsManager.Singleton.RectangularEffect(sceneMgr, sceneMgr.RootSceneNode, tile.GetHashCode() + "_" + i, EffectsManager.EffectType.SUBMERGE, posView, new Vector2(25, 25), Quaternion.IDENTITY, false); } name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, EffectsManager.EffectType.WATERIMPACT1, "WaterImpact1_" + tile.GetHashCode() + "_" + i); if (!EffectsManager.Singleton.EffectExists(name)) { EffectsManager.Singleton.WaterImpact(sceneMgr, sceneMgr.RootSceneNode, posView, new Vector2(20, 32), false, tile.GetHashCode() + "_" + i); } EffectsManager.EffectType type; if (((uint)tile.GetHashCode() + i) % 2 == 0) { type = EffectsManager.EffectType.EXPLOSION2_SLOW; } else { type = EffectsManager.EffectType.EXPLOSION1_SLOW; } name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, type, (tile.GetHashCode() + i).ToString()); if (!EffectsManager.Singleton.EffectExists(name)) { if (Math.RangeRandom(0, 1) > 0.8f) { EffectsManager.Singleton.Sprite(sceneMgr, sceneMgr.RootSceneNode, posView + ViewHelper.UnsignedRandomVector3(0, 10, 0), new Vector2(15, 15) + ViewHelper.RandomVector2(5, 5), type, false, (tile.GetHashCode() + i).ToString()); } } } }
public override void updateTime(float timeSinceLastFrameUpdate) { base.updateTime(timeSinceLastFrameUpdate); // miganie swiatla if ((levelTile as BarrackTile).IsDestroyed) { if (Math.RangeRandom(0.0f, 1.0f) > 0.9f) { SetLightFlareVisibility(false); } if (Math.RangeRandom(0.0f, 1.0f) > 0.9f) { SetLightFlareVisibility(true); } } }
protected void prepareGunEffect(Vector3 gunPos, float baseWidth, string localName) { Quaternion orient, trailOrient; if (ammunitionNode == null) { ammunitionNode = sceneMgr.RootSceneNode.CreateChildSceneNode("AmmunitionNode" + ammunitionID, hiddenPosition); } orient = new Quaternion(-Math.HALF_PI, Vector3.UNIT_Y); trailOrient = new Quaternion(-Math.HALF_PI, Vector3.UNIT_Y); trailOrient *= new Quaternion(-Math.HALF_PI, Vector3.UNIT_X); float trailWidth = baseWidth * Math.RangeRandom(1.0f, 1.1f); Vector3 trailBase = new Vector3(gunPos.x, gunPos.y, gunPos.z); //animations.Add( EffectsManager.Singleton.RectangularEffect(sceneMgr, ammunitionNode, getLocalSpriteName(localName), EffectsManager.EffectType.GUNTRAIL, trailBase - new Vector3(0, 0, Math.RangeRandom(-0.5f, 0.5f)), new Vector2(trailWidth, 1.0f), trailOrient, true); //); orient *= new Quaternion(Math.HALF_PI, Vector3.UNIT_X); trailOrient *= new Quaternion(Math.HALF_PI, Vector3.UNIT_X); //animations.Add( EffectsManager.Singleton.RectangularEffect(sceneMgr, ammunitionNode, getLocalSpriteNameTop(localName), EffectsManager.EffectType.GUNTRAIL, trailBase - new Vector3(0, 0, Math.RangeRandom(0.5f, 2.0f)), new Vector2(trailWidth, 1.0f), trailOrient, true); //); }
private void initNonCollisionTreesDiamond(SceneManager sceneMgr1, SceneNode parent, float zMin, float zMax, float xMin, float xMax, float intensity, bool forceLowDetails) { int c = (int)Math.Abs(count); int count_l = (int)(c * 2 * intensity); for (int i = 0; i < count_l; i++) { float z = Math.RangeRandom(zMin, zMax); if (i % 10 == 1) //Co dziesiata palma jest z wieksza iloscia trojkatow { initPalm(sceneMgr1, parent, new Vector3(z, -0.5f, Math.RangeRandom(xMin, xMax)), forceLowDetails); } else { initPalm2(sceneMgr1, parent, new Vector3(z, -0.5f, Math.RangeRandom(xMin, xMax)), forceLowDetails); } } }
public static void SinkingWaterAnimation(SceneManager sceneMgr, Vector3 pos, string baseName, int count, Vector2 range, Vector2 size) { string name; Vector2 sizeRand; for (uint i = 0; i < count; i++) { Vector2 rand = ViewHelper.RandomVector2(range.x, range.y); Vector3 posView = new Vector3(pos.x + rand.x, pos.y, pos.z + rand.y); name = EffectsManager.BuildSpriteEffectName(sceneMgr.RootSceneNode, EffectsManager.EffectType.SUBMERGE, baseName + "_" + i); NodeAnimation.NodeAnimation node = EffectsManager.Singleton.GetEffect(name); if (!EffectsManager.Singleton.EffectExists(name) || (node != null && node.getPercent() > 0.6f)) { sizeRand = size * Math.RangeRandom(0.9f, 1.1f); VisibilityNodeAnimation ani = EffectsManager.Singleton.RectangularEffect(sceneMgr, sceneMgr.RootSceneNode, baseName + "_" + i, EffectsManager.EffectType.SUBMERGE, posView, sizeRand, Quaternion.IDENTITY, false); ani.Duration = Mogre.Math.RangeRandom(ani.Duration, 2 * ani.Duration); ani.TimeScale = Mogre.Math.RangeRandom(0.5f, 1.5f); } } }
public static Vector2 UnsignedRandomVector2(float rangeXY) { float r = Math.RangeRandom(0, rangeXY); return(new Vector2(r, r)); }
public static Vector2 UnsignedRandomVector2(float rangeX, float rangeY) { return(new Vector2(Math.RangeRandom(0, rangeX), Math.RangeRandom(0, rangeY))); }
public static Vector2 RandomVector2(float rangeXY) { float r = Math.RangeRandom(-rangeXY, rangeXY); return(new Vector2(r, r)); }
/// <summary> /// /// </summary> /// <param name="rangeX"></param> /// <param name="rangeY"></param> /// <returns></returns> public static Vector2 RandomVector2(float rangeX, float rangeY) { return(new Vector2(Math.RangeRandom(-rangeX, rangeX), Math.RangeRandom(-rangeY, rangeY))); }
public static Vector3 UnsignedRandomVector3(float rangeXYZ) { float r = Math.RangeRandom(0, rangeXYZ); return(new Vector3(r, r, r)); }
public static Vector3 UnsignedRandomVector3(float rangeX, float rangeY, float rangeZ) { return(new Vector3(Math.RangeRandom(0, rangeX), Math.RangeRandom(0, rangeY), Math.RangeRandom(0, rangeZ))); }
public static Vector3 RandomVector3(float rangeXYZ) { float r = Math.RangeRandom(-rangeXYZ, rangeXYZ); return(new Vector3(r, r, r)); }
public static Vector3 RandomVector3(float rangeX, float rangeY, float rangeZ) { return (new Vector3(Math.RangeRandom(-rangeX, rangeX), Math.RangeRandom(-rangeY, rangeY), Math.RangeRandom(-rangeZ, rangeZ))); }
protected void preInitOnScene() { soldierModel = sceneMgr.CreateEntity("Soldier" + soldierID.ToString(), "Soldier.mesh"); soldierNode = sceneMgr.RootSceneNode.CreateChildSceneNode("SoldierNode" + soldierID.ToString(), new Vector3(-1000000, -1000000, 0)); if (EngineConfig.SoundEnabled) { float rand = Math.RangeRandom(0.0f, 5.0f); if (rand >= 0 && rand < 1.0) { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_1, soldierNode, false, false); dieSound.SetBaseGain(3.5f); } else if (rand >= 1 && rand < 2.0) { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_2, soldierNode, false, false); dieSound.SetBaseGain(4.0f); } else if (rand >= 2 && rand < 3.0) { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_3, soldierNode, false, false); dieSound.SetBaseGain(3.0f); } else if (rand >= 3 && rand < 4.0) { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_4, soldierNode, false, false); dieSound.SetBaseGain(2.0f); } else { dieSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_SOLDIER_DIE_5, soldierNode, false, false); dieSound.SetBaseGain(2.0f); } dieSound.SetReferenceDistance(60); // make it a bit louder but dissapear faster // prepareToFireSound = SoundManager3D.Instance.CreateSoundEntity(SoundManager3D.C_MISSILE_LOCK, soldierNode, true, false); } soldierNode.AttachObject(soldierModel); soldierNode.Scale(1.3f, 1.35f, 1.3f); runAnimationState = soldierModel.GetAnimationState("run"); die1AnimationState = soldierModel.GetAnimationState("die1"); die2AnimationState = soldierModel.GetAnimationState("die2"); prepareToFireAnimationState = soldierModel.GetAnimationState("prepareToFire"); soldierNode.SetVisible(false); if (EngineConfig.DisplayingMinimap) { if (minimapItem == null) { minimapItem = new MinimapItem(soldierNode, framework.MinimapMgr, "Cube.mesh", new ColourValue(0.97f, 1.0f, 0.66f), soldierModel); minimapItem.ScaleOverride = new Vector2(4, 7); // stala wysokosc bunkra, niezale¿na od bounding box } minimapItem.Refresh(); minimapItem.Hide(); } }
/// <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); }
protected override void initOnScene() { BeginIslandTile tile; if (tileViews != null && tileViews.Count > 0 && tileViews[0].LevelTile is BeginIslandTile) { tile = (tileViews[0].LevelTile as BeginIslandTile); meshName = tile.MeshName; } if (meshName == null) { return; } float margin; staticNode = sceneMgr.CreateSceneNode(mainNode.Name + "Static"); if (!backgroundDummy) { count = tileViews.Count; margin = 4.5f; } else { margin = 0.3f; } float maxX = -((Math.Abs(count) - 1) * LevelView.TileWidth); float dummyYPosition = 0; string meshFilename; switch (meshName) { case "Island1": //5 //ISLAND1 initNonCollisionTreesDiamond(sceneMgr, staticNode, margin, 5, 0.7f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -margin, -5, 0.7f); break; case "Island1a": //5 //ISLAND1 initNonCollisionTreesDiamond(sceneMgr, staticNode, margin, 5, 0.7f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -margin, -5, 0.7f); break; case "IslandRound": //4 //ISLAND ROUND initNonCollisionTreesCircle(sceneMgr, staticNode, 15.0f, 1.3f); break; case "Island2": //6 //ISLAND2 initNonCollisionTreesDiamond(sceneMgr, staticNode, margin, 5, 0.7f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -margin, -5, 0.7f); break; case "Laguna": //7 //LAGUNA break; case "DoubleLaguna": //8 // DOUBLE LAGUNA initNonCollisionTreesDiamond(sceneMgr, staticNode, -5.5f, 0.0f, maxX * 0.1f, maxX, 0.6f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -1.5f, 30.0f, maxX * 0.00f, maxX * 0.15f, 0.6f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -1.5f, 30.0f, maxX * 0.85f, maxX * 1.00f, 0.6f); break; case "Island3": //9 //ISLAND3 initNonCollisionTreesDiamond(sceneMgr, staticNode, margin, 5, 0.7f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -margin, -5, 0.7f); break; case "Island12u": //12 //ISLAND12u initNonCollisionTreesDiamond(sceneMgr, staticNode, margin, 5, maxX / 4.0f, maxX / 2.0f, 0.5f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -margin, -5, maxX / 4.0f, maxX / 2.0f, 0.5f); break; case "Island4": //13 //ISLAND4 initNonCollisionTreesDiamond(sceneMgr, staticNode, margin, 5, 0.7f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -margin, -5, 0.7f); break; case "Island18u": //18 //ISLAND18u initNonCollisionTreesDiamond(sceneMgr, staticNode, 10, 14, maxX / 2.5f, maxX, 0.5f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -11, -13, maxX / 2.5f, maxX, 0.5f); // zwolnic pamiec EnemyFighterView epv = new EnemyFighterView(null, framework, staticNode); epv.PlaneNode.SetPosition(-3, 0.8f, -18 - 90); epv.PlaneNode.Yaw(new Radian(new Degree(60))); if (EngineConfig.DisplayingMinimap) { epv.MinimapItem.Hide(); } parkedPlanes.Add(epv); EnemyFighterView epv2 = new EnemyFighterView(null, framework, staticNode); epv2.PlaneNode.SetPosition(-3, 0.8f, -25 - 90); epv2.PlaneNode.Yaw(new Radian(new Degree(62))); if (EngineConfig.DisplayingMinimap) { epv2.MinimapItem.Hide(); } parkedPlanes.Add(epv2); initLampPosts(staticNode, -7, maxX * 0.55f, maxX * 0.95f, 12, new Radian(new Degree(0))); break; case "Island5": //24 //ISLAND5 if (backgroundDummy) { initNonCollisionTreesDiamond(sceneMgr, staticNode, 1, 15, 0.7f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -1, -15, 0.7f); } else { initNonCollisionTreesDiamond(sceneMgr, staticNode, margin, 15, 0.7f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -margin, -15, 0.7f); } break; case "Island6": //42 //ISLAND6 if (EngineConfig.LowDetails) { initNonCollisionTreesDiamond(sceneMgr, staticNode, 4.5f, 33, 0.5f); } else { initNonCollisionTreesDiamond(sceneMgr, staticNode, 4.5f, 33, 0.9f); } initNonCollisionTreesDiamond(sceneMgr, staticNode, -4.5f, -60, 0.5f); initNonCollisionTreesDiamond(sceneMgr, staticNode, -4.5f, -30, 0.5f); break; case "RadarDome": dummyYPosition = 21; break; } if (EngineConfig.LowDetails && MeshManager.Singleton.ResourceExists(meshName + "_low" + ViewHelper.C_MESH_EXT)) { meshFilename = "_low" + ViewHelper.C_MESH_EXT; } else { meshFilename = meshName + ViewHelper.C_MESH_EXT; } compositeModel = sceneMgr.CreateEntity(name, meshFilename); compositeModel.CastShadows = false;// EngineConfig.ShadowsQuality > 0; // compositeModel.SetMaterialName("Carrier"); // compositeModel.SetMaterialName("Carrier/Panels"); /* * Mogre.Plane mPlane = new Mogre.Plane(Vector3.UNIT_Y, new Vector3(0,Mogre.Math.RangeRandom(0,1) ,0)); * * MeshManager.Singleton.CreatePlane("Myplane"+this.GetHashCode(), * ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, mPlane, 1000,1000,50,50,true,1,5,5,Vector3.UNIT_Z); * * Entity pPlaneEnt = sceneMgr.CreateEntity( "plane"+this.GetHashCode(), "Myplane"+this.GetHashCode() ); * * compositeModel = pPlaneEnt; * compositeModel.SetMaterialName("Concrete"); */ try { if (LevelView.IsNightScene) { ViewHelper.ReplaceMaterial(compositeModel, "Island", "IslandNight"); } } catch (Exception) { } if (!backgroundDummy) { staticNode.Translate(new Vector3(UnitConverter.LogicToWorldUnits(firstTileIndex), 1.00f, 0)); staticNode.SetDirection(Vector3.UNIT_X); } else { float angle; if (meshName.Equals("Island6")) { float X = (islandCounter % 5 * 250) - 650; float Z = Math.RangeRandom(-4, 0) * 70; staticNode.Translate(new Vector3(-250 + Z, dummyYPosition, Math.RangeRandom(-120, 120) + X)); staticNode.SetDirection(Vector3.UNIT_X); angle = Math.RangeRandom(0, 2 * Math.PI); } else { staticNode.Translate(new Vector3(-450 + Math.RangeRandom(-150, 150), dummyYPosition, Math.RangeRandom(-200, 200))); staticNode.SetDirection(Vector3.UNIT_X); angle = Math.HALF_PI; } staticNode.Yaw(angle); } // StaticGeometry sg; staticNode.AttachObject(compositeModel); /* * if (sceneMgr.HasStaticGeometry(this.name + "_StaticGeometry")) * { * sceneMgr.DestroyStaticGeometry(this.name + "_StaticGeometry"); * } * sg = new StaticGeometry(sceneMgr, this.name + "_StaticGeometry"); * sg.Reset(); * Vector3 sgSize = compositeModel.BoundingBox.Size; * sg.RegionDimensions = sgSize; * sg.AddSceneNode(staticNode); * sg.Build(); */ // mainNode.SetDirection(Vector3.UNIT_X); // mainNode.Position = staticNode.Position; mainNode.AddChild(staticNode); // mainNode.AttachObject(compositeModel); // elementy na wyspie sa animowalne wiec nie beda w static geometry if (!backgroundDummy) { for (int i = 0; i < count; i++) { tileViews[i].initOnScene(staticNode, i + 1, count); } // minimapa if (EngineConfig.DisplayingMinimap) { minimapItem = new MinimapItem(staticNode, framework.MinimapMgr, "Cube.mesh", new ColourValue(1, 0.9137f, 0.29f), compositeModel); minimapItem.Entity.SetMaterialName("Minimap/Island"); minimapItem.ScaleOverride = new Vector2(count * 10.0f, 3); // stala wysokosc wyspy, niezale¿na od bounding box // minimapItem.MinimapNode.Translate(0,0,50); minimapItem.Refresh(); } } }