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); } }
private void initNonCollisionTreesDiamond(SceneManager sceneMgr, SceneNode parent, float zMin, float zMax, float intensity, bool forceLowDetails) { int c = (int)Math.Abs(count); float max = -c * LevelView.TileWidth; initNonCollisionTreesDiamond(sceneMgr, parent, zMin, zMax, 0.1f * max, 0.9f * max, intensity, forceLowDetails); }
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; } }
private float animateArrestingWire(SceneNode arrestingWire, float targetWorldXPos) { float lastH; SceneNode lWire = (SceneNode)arrestingWire.GetChild(0); SceneNode rWire = (SceneNode)arrestingWire.GetChild(1); SceneNode temp; // fix zamienione nody if (rWire.Name.StartsWith(name + "_LArrestingWire")) { temp = lWire; lWire = rWire; rWire = temp; } lastH = lWire._getDerivedPosition().x - targetWorldXPos; Radian alpha = Math.ATan(lastH / (0.5f * arrestingWiresSpan)); // k¹t wychylenia kawalkow liny float length = lastH / Math.Sin(alpha); // dlugosc liny lWire.Orientation = new Quaternion(Math.HALF_PI, Vector3.UNIT_X); lWire.Orientation *= new Quaternion(Math.HALF_PI, Vector3.UNIT_Z); lWire.Orientation *= new Quaternion(alpha, Vector3.NEGATIVE_UNIT_Z); lWire.SetScale(1, length, 1); rWire.Orientation = new Quaternion(Math.HALF_PI, Vector3.UNIT_X); rWire.Orientation *= new Quaternion(Math.HALF_PI, Vector3.NEGATIVE_UNIT_Z); rWire.Orientation *= new Quaternion(alpha, Vector3.UNIT_Z); rWire.SetScale(1, length, 1); return(lastH); }
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); } } }
/// <summary> /// Zwiêksza odleg³oœæ punktu od punktu (0,0), nie zmieniaj¹c k¹ta nachylenia. /// </summary> /// <param name="length">D³ugoœæ o jak¹ ma byæ przesuniêty punkt.</param> public void Extend(float length) { //tworzê wektor o kierunku zgodnym z danym punktem i d³ugoœci¹ lenght PointD addVector = new PointD(Math.Cos(Angle) * length, Math.Sin(Angle) * length); Move(addVector); }
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 ResetWheels() { if (rWheelInnerNode == null || lWheelInnerNode == null) { return; } rWheelInnerNode.ResetOrientation(); lWheelInnerNode.ResetOrientation(); rearWheelInnerNode.ResetOrientation(); RotateNodeAnimation ra; animationMgr.switchTo(PlaneNodeAnimationManager.AnimationType.L_GEAR_UP); ra = (animationMgr.CurrentAnimation as RotateNodeAnimation); ra.MaxAngle = Math.Abs(ra.MaxAngle); animationMgr.switchTo(PlaneNodeAnimationManager.AnimationType.R_GEAR_UP); ra = (animationMgr.CurrentAnimation as RotateNodeAnimation); ra.MaxAngle = Math.Abs(ra.MaxAngle); animationMgr.switchTo(PlaneNodeAnimationManager.AnimationType.REAR_GEAR_UP); ra = (animationMgr.CurrentAnimation as RotateNodeAnimation); ra.MaxAngle = Math.Abs(ra.MaxAngle); }
public bool isDegenerate() { if (Math.Abs((p(1) - p(0)).CrossProduct(p(2) - p(0))) < 1e-4) { return(true); } return(false); }
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); } }
/// <summary> /// Czy hamowanie zosta³o zakoñczone /// </summary> private bool shouldStopReleasingPlane() { for (int i = 0; i < arrestingWiresH.Length; i++) { if (Math.Abs(arrestingWiresH[i]) > 0.01f) { return(false); } } return(true); }
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); } }
// //ORIGINAL LINE: bool operator ()(const Ogre::Vector2& one, const Ogre::Vector2& two) const //C++ TO C# CONVERTER TODO TASK: The () operator cannot be overloaded in C#: /// <summary> /// 是否相等???? /// </summary> /// <param name="one"></param> /// <param name="two"></param> /// <returns></returns> public static bool Operator(Vector2 one, Vector2 two) { if ((one - two).SquaredLength < 1e-6) { return(false); } if (Math.Abs(one.x - two.x) > 1e-3) { return(one.x < two.x); } return(one.y < two.y); }
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); }
private void activateClosestArrestingWires(PlaneView p) { float diff; for (int i = 0; i < arrestingWires.Count; i++) { diff = p.RearWheelInnerNode._getDerivedPosition().x - arrestingWires[i]._getDerivedPosition().x; if (Math.Abs(diff) < 0.5f && diff > 0 && !activeArrestingWires.Contains(arrestingWires[i])) { activeArrestingWires.Add(arrestingWires[i]); } } }
// * // * Builds a shape from control points // //----------------------------------------------------------------------- public Path realizePath() { Path helix = new Path(); float angleStep = Math.TWO_PI / (float)(mNumSegPath); float heightStep = mHeight / (float)(mNumSegPath); for (int i = 0; i < mNumRound * mNumSegPath; i++) { helix.addPoint(mRadius * Math.Cos(angleStep * i), heightStep * i, mRadius * Math.Sin(angleStep * i)); } return(helix); }
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); } } } }
/// Builds the shape public Shape realizeShape() { Radian alpha = Math.ACos((mLengthB * mLengthB + mLengthC * mLengthC - mLengthA * mLengthA) / (2 * mLengthB * mLengthC)); Shape s = new Shape(); s.addPoint(0.0f, 0.0f); s.addPoint(Math.Cos(alpha) * mLengthB, Math.Sin(alpha) * mLengthB); s.addPoint(mLengthC, 0.0f); s.close(); s.translate((Math.Cos(alpha) * mLengthB + mLengthC) / -3.0f, mLengthB / -3.0f); return(s); }
// * // * Equivalent of Ogre::Vector3::angleBetween, applied to Ogre::Vector2 // public static Radian angleBetween(Vector2 v1, Vector2 v2) { float lenProduct = v1.Length * v2.Length; // Divide by zero check if (lenProduct < 1e-6f) { lenProduct = 1e-6f; } float f = v1.DotProduct(v2) / lenProduct; f = Math_Clamp(f, -1.0f, 1.0f); return(Math.ACos(f)); }
public static Radian angleBetween(Vector3 v1, Vector3 dest) { float lenProduct = v1.Length * dest.Length; // Divide by zero check if (lenProduct < 1e-6f) { lenProduct = 1e-6f; } float f = v1.DotProduct(dest) / lenProduct; f = Clamp(f, (float)-1.0f, 1.0f); return(Math.ACos(f)); }
//-------------------------------------------------------------- public void modify() { if (mInputTriangleBuffer == null) { OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Input triangle buffer must be set", "__FUNCTION__"); } ; //for (List<TriangleBuffer.Vertex>.Enumerator it = mInputTriangleBuffer.getVertices().begin(); it != mInputTriangleBuffer.getVertices().end(); ++it) foreach (var it in mInputTriangleBuffer.getVertices()) { Vector3 v = it.mPosition.NormalisedCopy; Vector2 vxz = new Vector2(v.x, v.z); it.mUV.x = Utils.angleTo(Vector2.UNIT_X, vxz).ValueRadians / Math.TWO_PI; it.mUV.y = (Math.ATan(v.y / vxz.Length).ValueRadians + Math.HALF_PI) / Math.PI; } }
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()); } } } }
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); //); }
/// <summary> /// Obraca punkt o kat angle wzgledem punktu rotateCenter. /// </summary> /// <param name="rotateCenter">Srodek obrotu</param> /// <param name="angle">Kat o ktory, chcemy obrocic (podany w radianach).</param> /// <author>Emil</author> public void Rotate(PointD rotateCenter, float angle) { if (rotateCenter == this) { return; } //mX = (mX - rotateCenter.mX) * Math.Cos(angle) + rotateCenter.mX - (mY - rotateCenter.mY) * Math.Sin(angle); //mY = (mX - rotateCenter.mX) * Math.Sin(angle) + (mY - rotateCenter.mY) * Math.Cos(angle) + rotateCenter.mY; Move(-1 * rotateCenter); float oldX = mX, oldY = mY; mX = oldX * Math.Cos(angle) - oldY * Math.Sin(angle); mY = oldX * Math.Sin(angle) + oldY * Math.Cos(angle); Move(rotateCenter); }
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 override void initWheels() { lWheelNode = innerNode.CreateChildSceneNode(name + "_LeftWheel", new Vector3(-3.0f, -1.0f, -2.3f), new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X)); lWheelNode.Scale(0.9f, 0.9f, 0.9f); lWheelInnerNode = lWheelNode.CreateChildSceneNode(name + "_LeftWheelInner"); Entity lWheel = sceneMgr.CreateEntity(name + "_lWheel", "Wheel.mesh"); lWheelInnerNode.AttachObject(lWheel); rWheelNode = innerNode.CreateChildSceneNode(name + "_RightWheel", new Vector3(3.0f, -1.0f, -2.3f), new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X)); rWheelNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Math.DegreesToRadians(180)); rWheelNode.Scale(0.9f, 0.9f, 0.9f); rWheelInnerNode = rWheelNode.CreateChildSceneNode(name + "_RightWheelInner"); Entity rWheel = sceneMgr.CreateEntity(name + "_rWheel", "Wheel.mesh"); rWheelInnerNode.AttachObject(rWheel); rearWheelNode = innerNode.CreateChildSceneNode(name + "_RearWheel", new Vector3(0.0f, -0.2f, 5.3f), new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X)); // rearWheelNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Mogre.Math.DegreesToRadians(180)); rearWheelNode.Scale(0.7f, 0.7f, 0.7f); rearWheelInnerNode = rearWheelNode.CreateChildSceneNode(name + "_RearWheelInner"); Entity rearWheel = sceneMgr.CreateEntity(name + "_rearWheele", "Wheel.mesh"); rearWheelInnerNode.AttachObject(rearWheel); // retract landing gear if (this.plane != null && this.plane.WheelsState == WheelsState.In) { LWheelInnerNode.Roll(new Radian(new Degree(90))); RWheelInnerNode.Roll(new Radian(new Degree(90))); RearWheelInnerNode.Pitch(new Radian(new Degree(45))); // IMPORTANT: this should be also set in animation manager later on (MaxAngle *= -1 to change direction of wheel movement) } }
/// <summary> /// Returns which side of the plane that the given box lies on. /// The box is defined as centre/half-size pairs for effectively. /// </summary> /// <param name="centre">The centre of the box.</param> /// <param name="halfSize">The half-size of the box.</param> /// <returns> /// Positive if the box complete lies on the "positive side" of the plane, /// Negative if the box complete lies on the "negative side" of the plane, /// and Both if the box intersects the plane. /// </returns> public PlaneSide GetSide(Vector3 centre, Vector3 halfSize) { // Calculate the distance between box centre and the plane var dist = GetDistance(centre); // Calculate the maximise allows absolute distance for // the distance between box centre and plane var maxAbsDist = Math.Abs(this.Normal.DotProduct(halfSize)); if (dist < -maxAbsDist) { return(PlaneSide.NEGATIVE_SIDE); } if (dist > +maxAbsDist) { return(PlaneSide.POSITIVE_SIDE); } return(PlaneSide.NEGATIVE_SIDE | Mogre.Plane.Side.POSITIVE_SIDE); }
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); } } }