static void StartBillboards() { // Initialize LARGE billboards for (int x = 0; x < MySunWindConstants.LARGE_BILLBOARDS_SIZE.X; x++) { for (int y = 0; y < MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y; y++) { MySunWindBillboard billboard = m_largeBillboards[x][y]; Vector3 positionRandomDelta = new Vector3( MyUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_POSITION_DELTA_MIN, MySunWindConstants.LARGE_BILLBOARD_POSITION_DELTA_MAX), MyUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_POSITION_DELTA_MIN, MySunWindConstants.LARGE_BILLBOARD_POSITION_DELTA_MAX), MyUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_POSITION_DELTA_MIN, MySunWindConstants.LARGE_BILLBOARD_POSITION_DELTA_MAX)); Vector3 positionRelative = new Vector3( (x - MySunWindConstants.LARGE_BILLBOARDS_SIZE_HALF.X) * MySunWindConstants.LARGE_BILLBOARD_DISTANCE, (y - MySunWindConstants.LARGE_BILLBOARDS_SIZE_HALF.Y) * MySunWindConstants.LARGE_BILLBOARD_DISTANCE, (x - MySunWindConstants.LARGE_BILLBOARDS_SIZE_HALF.X) * MySunWindConstants.LARGE_BILLBOARD_DISTANCE * 0.2f); billboard.InitialAbsolutePosition = m_initialSunWindPosition + m_rightVector * (positionRandomDelta.X + positionRelative.X) + m_downVector * (positionRandomDelta.Y + positionRelative.Y) + -1 * m_directionFromSunNormalized * (positionRandomDelta.Z + positionRelative.Z); } } Vector3D initialPositionOnCameraLine = MySession.LocalCharacter == null ? Vector3D.Zero : MySession.LocalCharacter.Entity.WorldMatrix.Translation - m_directionFromSunNormalized * MySunWindConstants.SUN_WIND_LENGTH_HALF / 3; for (int x = 0; x < MySunWindConstants.SMALL_BILLBOARDS_SIZE.X; x++) { for (int y = 0; y < MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y; y++) { MySunWindBillboardSmall billboard = m_smallBillboards[x][y]; Vector2 positionRandomDelta = new Vector2( MyUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_POSITION_DELTA_MIN, MySunWindConstants.SMALL_BILLBOARD_POSITION_DELTA_MAX), MyUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_POSITION_DELTA_MIN, MySunWindConstants.SMALL_BILLBOARD_POSITION_DELTA_MAX)); Vector2 positionRelative = new Vector2( (x - MySunWindConstants.SMALL_BILLBOARDS_SIZE_HALF.X) * MySunWindConstants.SMALL_BILLBOARD_DISTANCE, (y - MySunWindConstants.SMALL_BILLBOARDS_SIZE_HALF.Y) * MySunWindConstants.SMALL_BILLBOARD_DISTANCE); billboard.InitialAbsolutePosition = initialPositionOnCameraLine + m_rightVector * (positionRandomDelta.X + positionRelative.X) + m_downVector * (positionRandomDelta.Y + positionRelative.Y); } } }
public override void LoadData() { MyLog.Default.WriteLine("MySunWind.LoadData() - START"); MyLog.Default.IncreaseIndent(); //MyRender.GetRenderProfiler().StartProfilingBlock("MySunwind::LoadContent"); m_intersectionLst = new List<Havok.HkBodyCollision>(); // Large billboards m_largeBillboards = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.X][]; for (int x = 0; x < MySunWindConstants.LARGE_BILLBOARDS_SIZE.X; x++) { m_largeBillboards[x] = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y]; for (int y = 0; y < MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y; y++) { m_largeBillboards[x][y] = new MySunWindBillboard(); MySunWindBillboard billboard = m_largeBillboards[x][y]; billboard.Radius = MyUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_RADIUS_MIN, MySunWindConstants.LARGE_BILLBOARD_RADIUS_MAX); billboard.InitialAngle = MyUtils.GetRandomRadian(); billboard.RotationSpeed = MyUtils.GetRandomSign() * MyUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_ROTATION_SPEED_MIN, MySunWindConstants.LARGE_BILLBOARD_ROTATION_SPEED_MAX); //billboard.Color = MySunWindConstants.BILLBOARD_COLOR; //billboard.Color.X = MyMwcUtils.GetRandomFloat(0.5f, 3); //billboard.Color.Y = MyMwcUtils.GetRandomFloat(0.5f, 2); //billboard.Color.Z = MyMwcUtils.GetRandomFloat(0.5f, 2); //billboard.Color.W = MyMwcUtils.GetRandomFloat(0.5f, 2); billboard.Color.X = MyUtils.GetRandomFloat(0.5f, 3); billboard.Color.Y = MyUtils.GetRandomFloat(0.5f, 1); billboard.Color.Z = MyUtils.GetRandomFloat(0.5f, 1); billboard.Color.W = MyUtils.GetRandomFloat(0.5f, 1); } } // Small billboards m_smallBillboards = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.X][]; for (int x = 0; x < MySunWindConstants.SMALL_BILLBOARDS_SIZE.X; x++) { m_smallBillboards[x] = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y]; for (int y = 0; y < MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y; y++) { m_smallBillboards[x][y] = new MySunWindBillboardSmall(); MySunWindBillboardSmall billboard = m_smallBillboards[x][y]; billboard.Radius = MyUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_RADIUS_MIN, MySunWindConstants.SMALL_BILLBOARD_RADIUS_MAX); billboard.InitialAngle = MyUtils.GetRandomRadian(); billboard.RotationSpeed = MyUtils.GetRandomSign() * MyUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_ROTATION_SPEED_MIN, MySunWindConstants.SMALL_BILLBOARD_ROTATION_SPEED_MAX); //billboard.Color = MySunWindConstants.BILLBOARD_COLOR; billboard.Color.X = MyUtils.GetRandomFloat(0.5f, 1); billboard.Color.Y = MyUtils.GetRandomFloat(0.2f, 0.5f); billboard.Color.Z = MyUtils.GetRandomFloat(0.2f, 0.5f); billboard.Color.W = MyUtils.GetRandomFloat(0.1f, 0.5f); billboard.TailBillboardsCount = MyUtils.GetRandomInt(MySunWindConstants.SMALL_BILLBOARD_TAIL_COUNT_MIN, MySunWindConstants.SMALL_BILLBOARD_TAIL_COUNT_MAX); billboard.TailBillboardsDistance = MyUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_TAIL_DISTANCE_MIN, MySunWindConstants.SMALL_BILLBOARD_TAIL_DISTANCE_MAX); billboard.RadiusScales = new float[billboard.TailBillboardsCount]; for (int i = 0; i < billboard.TailBillboardsCount; i++) { billboard.RadiusScales[i] = MyUtils.GetRandomFloat(0.7f, 1.0f); } } } MyLog.Default.DecreaseIndent(); MyLog.Default.WriteLine("MySunWind.LoadData() - END"); }
public override void LoadData() { MyLog.Default.WriteLine("MySunWind.LoadData() - START"); MyLog.Default.IncreaseIndent(); m_intersectionLst = new List <HkBodyCollision>(); m_largeBillboards = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.X][]; int index = 0; while (index < MySunWindConstants.LARGE_BILLBOARDS_SIZE.X) { m_largeBillboards[index] = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y]; int num2 = 0; while (true) { if (num2 >= MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y) { index++; break; } m_largeBillboards[index][num2] = new MySunWindBillboard(); MySunWindBillboard billboard1 = m_largeBillboards[index][num2]; billboard1.Radius = MyUtils.GetRandomFloat(20000f, 35000f); billboard1.InitialAngle = MyUtils.GetRandomRadian(); billboard1.RotationSpeed = MyUtils.GetRandomSign() * MyUtils.GetRandomFloat(0.5f, 1.2f); billboard1.Color.X = MyUtils.GetRandomFloat(0.5f, 3f); billboard1.Color.Y = MyUtils.GetRandomFloat(0.5f, 1f); billboard1.Color.Z = MyUtils.GetRandomFloat(0.5f, 1f); billboard1.Color.W = MyUtils.GetRandomFloat(0.5f, 1f); num2++; } } m_smallBillboards = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.X][]; int num3 = 0; while (num3 < MySunWindConstants.SMALL_BILLBOARDS_SIZE.X) { m_smallBillboards[num3] = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y]; int num4 = 0; while (true) { if (num4 >= MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y) { num3++; break; } m_smallBillboards[num3][num4] = new MySunWindBillboardSmall(); MySunWindBillboardSmall small = m_smallBillboards[num3][num4]; small.Radius = MyUtils.GetRandomFloat(250f, 500f); small.InitialAngle = MyUtils.GetRandomRadian(); small.RotationSpeed = MyUtils.GetRandomSign() * MyUtils.GetRandomFloat(1.4f, 3.5f); small.Color.X = MyUtils.GetRandomFloat(0.5f, 1f); small.Color.Y = MyUtils.GetRandomFloat(0.2f, 0.5f); small.Color.Z = MyUtils.GetRandomFloat(0.2f, 0.5f); small.Color.W = MyUtils.GetRandomFloat(0.1f, 0.5f); small.TailBillboardsCount = MyUtils.GetRandomInt(8, 14); small.TailBillboardsDistance = MyUtils.GetRandomFloat(300f, 450f); small.RadiusScales = new float[small.TailBillboardsCount]; int num5 = 0; while (true) { if (num5 >= small.TailBillboardsCount) { num4++; break; } small.RadiusScales[num5] = MyUtils.GetRandomFloat(0.7f, 1f); num5++; } } } MyLog.Default.DecreaseIndent(); MyLog.Default.WriteLine("MySunWind.LoadData() - END"); }
public override void LoadData() { MyLog.Default.WriteLine("MySunWind.LoadData() - START"); MyLog.Default.IncreaseIndent(); //MyRender.GetRenderProfiler().StartProfilingBlock("MySunwind::LoadContent"); m_intersectionLst = new List <Havok.HkBodyCollision>(); // Large billboards m_largeBillboards = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.X][]; for (int x = 0; x < MySunWindConstants.LARGE_BILLBOARDS_SIZE.X; x++) { m_largeBillboards[x] = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y]; for (int y = 0; y < MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y; y++) { m_largeBillboards[x][y] = new MySunWindBillboard(); MySunWindBillboard billboard = m_largeBillboards[x][y]; billboard.Radius = MyUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_RADIUS_MIN, MySunWindConstants.LARGE_BILLBOARD_RADIUS_MAX); billboard.InitialAngle = MyUtils.GetRandomRadian(); billboard.RotationSpeed = MyUtils.GetRandomSign() * MyUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_ROTATION_SPEED_MIN, MySunWindConstants.LARGE_BILLBOARD_ROTATION_SPEED_MAX); //billboard.Color = MySunWindConstants.BILLBOARD_COLOR; //billboard.Color.X = MyMwcUtils.GetRandomFloat(0.5f, 3); //billboard.Color.Y = MyMwcUtils.GetRandomFloat(0.5f, 2); //billboard.Color.Z = MyMwcUtils.GetRandomFloat(0.5f, 2); //billboard.Color.W = MyMwcUtils.GetRandomFloat(0.5f, 2); billboard.Color.X = MyUtils.GetRandomFloat(0.5f, 3); billboard.Color.Y = MyUtils.GetRandomFloat(0.5f, 1); billboard.Color.Z = MyUtils.GetRandomFloat(0.5f, 1); billboard.Color.W = MyUtils.GetRandomFloat(0.5f, 1); } } // Small billboards m_smallBillboards = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.X][]; for (int x = 0; x < MySunWindConstants.SMALL_BILLBOARDS_SIZE.X; x++) { m_smallBillboards[x] = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y]; for (int y = 0; y < MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y; y++) { m_smallBillboards[x][y] = new MySunWindBillboardSmall(); MySunWindBillboardSmall billboard = m_smallBillboards[x][y]; billboard.Radius = MyUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_RADIUS_MIN, MySunWindConstants.SMALL_BILLBOARD_RADIUS_MAX); billboard.InitialAngle = MyUtils.GetRandomRadian(); billboard.RotationSpeed = MyUtils.GetRandomSign() * MyUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_ROTATION_SPEED_MIN, MySunWindConstants.SMALL_BILLBOARD_ROTATION_SPEED_MAX); //billboard.Color = MySunWindConstants.BILLBOARD_COLOR; billboard.Color.X = MyUtils.GetRandomFloat(0.5f, 1); billboard.Color.Y = MyUtils.GetRandomFloat(0.2f, 0.5f); billboard.Color.Z = MyUtils.GetRandomFloat(0.2f, 0.5f); billboard.Color.W = MyUtils.GetRandomFloat(0.1f, 0.5f); billboard.TailBillboardsCount = MyUtils.GetRandomInt(MySunWindConstants.SMALL_BILLBOARD_TAIL_COUNT_MIN, MySunWindConstants.SMALL_BILLBOARD_TAIL_COUNT_MAX); billboard.TailBillboardsDistance = MyUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_TAIL_DISTANCE_MIN, MySunWindConstants.SMALL_BILLBOARD_TAIL_DISTANCE_MAX); billboard.RadiusScales = new float[billboard.TailBillboardsCount]; for (int i = 0; i < billboard.TailBillboardsCount; i++) { billboard.RadiusScales[i] = MyUtils.GetRandomFloat(0.7f, 1.0f); } } } MyLog.Default.DecreaseIndent(); MyLog.Default.WriteLine("MySunWind.LoadData() - END"); }
// This method doesn't really draw. It just creates billboards that are later drawn in MyParticles.Draw() public static void Draw() { if (IsActive == false) { return; } if (IsVisible == false) { return; } //float deltaTime = ((float)MyMinerGame.TotalGamePlayTimeInMilliseconds - (float)m_timeStarted) / 1000.0f; float traveledDistance = m_speed * m_deltaTime; Vector3 deltaPosition = m_directionFromSunNormalized * traveledDistance; // Draw LARGE billboards for (int x = 0; x < MySunWindConstants.LARGE_BILLBOARDS_SIZE.X; x++) { for (int y = 0; y < MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y; y++) { MySunWindBillboard billboard = m_largeBillboards[x][y]; Vector3 actualPosition = billboard.InitialAbsolutePosition + deltaPosition; float distanceToCamera; Vector3 campos = MyCamera.Position; Vector3.Distance(ref actualPosition, ref campos, out distanceToCamera); float alpha = 1 - MathHelper.Clamp(distanceToCamera / MySunWindConstants.LARGE_BILLBOARD_DISAPEAR_DISTANCE, 0, 1); float distanceToCenterOfSunWind; Vector3.Distance(ref actualPosition, ref campos, out distanceToCenterOfSunWind); if (distanceToCenterOfSunWind < MySunWindConstants.SWITCH_LARGE_AND_SMALL_BILLBOARD_RADIUS) { alpha *= MathHelper.Clamp(distanceToCamera / MySunWindConstants.SWITCH_LARGE_AND_SMALL_BILLBOARD_DISTANCE, 0, 1); } //billboard.Color *= alpha; MyTransparentGeometry.AddPointBillboard( MyTransparentMaterialEnum.Explosion, new Vector4(billboard.Color.X * alpha, billboard.Color.Y * alpha, billboard.Color.Z * alpha, alpha), actualPosition, billboard.Radius, billboard.InitialAngle + billboard.RotationSpeed * m_deltaTime); } } // Draw SMALL billboards //if (m_distanceToSunWind <= MySunWindConstants.SWITCH_LARGE_AND_SMALL_BILLBOARD_DISTANCE) //{ // if (m_smallBillboardsStarted == false) // { // StartSmallBillboards(); // m_smallBillboardsStarted = true; // } if (m_smallBillboardsStarted == true) { for (int x = 0; x < MySunWindConstants.SMALL_BILLBOARDS_SIZE.X; x++) { for (int y = 0; y < MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y; y++) { MySunWindBillboardSmall billboard = m_smallBillboards[x][y]; Vector3 actualPosition = billboard.InitialAbsolutePosition + deltaPosition; for (int z = 0; z < billboard.TailBillboardsCount; z++) { Vector3 tempPosition = actualPosition - m_directionFromSunNormalized * (z - billboard.TailBillboardsCount / 2) * billboard.TailBillboardsDistance; float distanceToCamera; Vector3 campos = MyCamera.Position; Vector3.Distance(ref tempPosition, ref campos, out distanceToCamera); //distanceToCamera = Math.Abs(Vector3.Dot(tempPosition - campos, m_directionFromSunNormalized)); float alpha = 1 - MathHelper.Clamp((distanceToCamera) / (MySunWindConstants.SWITCH_LARGE_AND_SMALL_BILLBOARD_DISTANCE_HALF), 0, 1); if (alpha > 0) { float distanceFromOrigin; Vector3.Distance(ref tempPosition, ref billboard.InitialAbsolutePosition, out distanceFromOrigin); if (distanceFromOrigin < billboard.MaxDistance) { MyTransparentGeometry.AddPointBillboard( MyTransparentMaterialEnum.Explosion, new Vector4(billboard.Color.X * alpha, billboard.Color.Y * alpha, billboard.Color.Z * alpha, billboard.Color.W * alpha), tempPosition, billboard.Radius * billboard.RadiusScales[z], billboard.InitialAngle + billboard.RotationSpeed * m_deltaTime); } } } } } } }