// Not used apparently public static void AddShotgun(MyProjectileAmmoDefinition ammoDefinition, MyEntity ignorePhysObject, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, bool groupStart, float thicknessMultiplier, MyEntity weapon, float frontBillboardSize, MyEntity ownerEntity = null, float projectileCountMultiplier = 1) { MyProjectile newProjectile = m_projectiles.Allocate(); if (newProjectile != null) { //newProjectile.Start( // ammoDefinition, // ignorePhysObject, // origin, // initialVelocity, // directionNormalized, // groupStart, // thicknessMultiplier, // 1, // weapon, // projectileCountMultiplier // ); // newProjectile.BlendByCameraDirection = true; // newProjectile.FrontBillboardMaterial = "ShotgunParticle"; // newProjectile.LengthMultiplier = 2; // newProjectile.FrontBillboardSize = frontBillboardSize; // newProjectile.OwnerEntity = ownerEntity != null ? ownerEntity : ignorePhysObject; } }
// Add new ship to the list public static MySmallShip Add(string displayName, MyMwcObjectBuilder_Ship objectBuilder) { MySmallShip newShip = m_hologramShips.Allocate(); if (newShip != null) { newShip.Init(displayName, objectBuilder); if (newShip.Physics.Enabled) { newShip.Physics.Enabled = false; } /* * newShip.Physics.Type = MyConstants.RIGIDBODY_TYPE_DEFAULT; * newShip.Physics.CollisionLayer = MyConstants.COLLISION_LAYER_UNCOLLIDABLE; */ newShip.IsHologram = true; // we dont want the hologram to have a light newShip.RemoveLight(); newShip.RemoveSubObjectLights(); newShip.Config.Engine.Level = 1; newShip.Config.ReflectorLight.Level = 1; newShip.GetReflectorProperties().CurrentBillboardLength = 40; newShip.GetReflectorProperties().CurrentBillboardThickness = 6; newShip.CastShadows = false; } return(newShip); }
public IDepthStencil CreateDepthStencil(string debugName, int width, int height, Format resourceFormat = Format.R32G8X24_Typeless, Format dsvFormat = Format.D32_Float_S8X24_UInt, Format srvDepthFormat = Format.R32_Float_X8X24_Typeless, Format srvStencilFormat = Format.X32_Typeless_G8X24_UInt, int samplesCount = 1, int samplesQuality = 0) { MyRenderProxy.Assert(width > 0); MyRenderProxy.Assert(height > 0); MyDepthStencil tex = m_objectsPool.Allocate(); tex.Init(debugName, width, height, resourceFormat, dsvFormat, srvDepthFormat, srvStencilFormat, samplesCount, samplesQuality); if (m_isDeviceInit) { try { tex.OnDeviceInit(); } catch (System.Exception ex) { IDepthStencil t = tex; DisposeTex(ref t); throw; } } return(tex); }
// Add new light to the list, but caller needs to start it using Start() method public static MyLight AddLight() { var result = m_preallocatedLights.Allocate(); result.ProxyId = MyDynamicAABBTree.NullNode; return(result); }
static void UpdateExplosionLines() { foreach (LinkedListNode <ExplosionLine> explosionLine in m_preallocatedExplosionLines) { explosionLine.Value.ActualTime += MyConstants.PHYSICS_STEP_SIZE_IN_MILLISECONDS; if (explosionLine.Value.ActualTime > explosionLine.Value.TotalTime) { m_preallocatedExplosionLines.MarkForDeallocate(explosionLine); continue; } explosionLine.Value.ActualDir = Vector3.Lerp(explosionLine.Value.StartDir, explosionLine.Value.EndDir, explosionLine.Value.ActualTime / (float)explosionLine.Value.TotalTime); } m_preallocatedExplosionLines.DeallocateAllMarked(); if (m_State == NuclearState.FADE_IN && MyMwcUtils.GetRandomFloat(0, 1) > 0.75f) { ExplosionLine line = m_preallocatedExplosionLines.Allocate(true); if (line != null) { line.TotalTime = 5000; line.ActualTime = 0; line.StartDir = MyMwcUtils.GetRandomVector3Normalized(); Vector3 rotDir = MyMwcUtils.GetRandomVector3Normalized(); Matrix rotMatrix = Matrix.CreateFromAxisAngle(rotDir, 0.3f); line.EndDir = Vector3.Transform(line.StartDir, rotMatrix); } } }
public static void Add(Vector3 position, Vector3 initialVelocity, Vector3 direction, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip ignoreMinerShip) { MyCannonShot newMissile = m_missiles.Allocate(); if (newMissile != null) { newMissile.Start(position, initialVelocity, direction, usedAmmo, ignoreMinerShip); } }
// Add new missile to the list public static MyMissile Add(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum type, Vector3 position, Vector3 initialVelocity, Vector3 direction, Vector3 relativePos, MyEntity ignoreMinerShip, MyEntity target, float customMaxDistance = 0, bool isDummy = false, bool isLightWeight = false) { MyMissile newMissile = m_missiles.Allocate(); if (newMissile != null) { newMissile.Start(type, position, initialVelocity, direction, relativePos, ignoreMinerShip, target, customMaxDistance, isDummy, isLightWeight); } return(newMissile); }
// Add new projectile to the list public static void Add(MyAmmoProperties ammoProperties, MyEntity ignorePhysObject, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, bool groupStart, float thicknessMultiplier, MyEntity weapon, MyEntity ownerEntity = null) { MyProjectile newProjectile = m_projectiles.Allocate(); if (newProjectile != null) { newProjectile.Start( ammoProperties, ignorePhysObject, origin, initialVelocity, directionNormalized, groupStart, thicknessMultiplier, weapon ); newProjectile.OwnerEntity = ownerEntity != null ? ownerEntity : ignorePhysObject; } }
public void Add(MyTriangle_Vertexes triangle, Vector3 normal, ref MyPlane rightPlane, ref MyPlane upPlane, float decalScale, float alpha, bool alphaBlendByAngle, ref BoundingSphere decalSphere) { float alpha0 = alpha; float alpha1 = alpha; float alpha2 = alpha; if (alphaBlendByAngle == true) { alpha0 *= GetAlphaByDistance(ref triangle.Vertex0, ref decalSphere); alpha1 *= GetAlphaByDistance(ref triangle.Vertex1, ref decalSphere); alpha2 *= GetAlphaByDistance(ref triangle.Vertex2, ref decalSphere); } if ((alpha0 <= 0.0f) && (alpha1 <= 0.0f) && (alpha2 <= 0.0f)) { // Decal would be totaly transparent so it doesn't make sense to draw it return; } MyCockpitGlassDecalTriangle decalTriangle = m_triangles.Allocate(); if (decalTriangle == null) { return; } decalTriangle.Position0 = triangle.Vertex0; decalTriangle.Position1 = triangle.Vertex1; decalTriangle.Position2 = triangle.Vertex2; // Texture coords decalTriangle.TexCoord0 = new Vector2( 0.5f + decalScale * MyUtils.GetDistanceFromPointToPlane(ref decalTriangle.Position0, ref rightPlane), 0.5f + decalScale * MyUtils.GetDistanceFromPointToPlane(ref decalTriangle.Position0, ref upPlane)); decalTriangle.TexCoord1 = new Vector2( 0.5f + decalScale * MyUtils.GetDistanceFromPointToPlane(ref decalTriangle.Position1, ref rightPlane), 0.5f + decalScale * MyUtils.GetDistanceFromPointToPlane(ref decalTriangle.Position1, ref upPlane)); decalTriangle.TexCoord2 = new Vector2( 0.5f + decalScale * MyUtils.GetDistanceFromPointToPlane(ref decalTriangle.Position2, ref rightPlane), 0.5f + decalScale * MyUtils.GetDistanceFromPointToPlane(ref decalTriangle.Position2, ref upPlane)); // Normal normal = MinerWars.CommonLIB.AppCode.Utils.MyMwcUtils.Normalize(normal); decalTriangle.Normal0 = normal; decalTriangle.Normal1 = normal; decalTriangle.Normal2 = normal; decalTriangle.Alpha012.X = alpha0; decalTriangle.Alpha012.Y = alpha1; decalTriangle.Alpha012.Z = alpha2; // Time created decalTriangle.CreatedTime = MyMinerGame.TotalGamePlayTimeInMilliseconds; }
public MySoundCue CreateCue(Cue xactCue, MySoundCuesEnum cueEnum, bool apply3d) { var cue = m_pool.Allocate(); if (cue == null) { throw new InvalidOperationException("Cue pool is empty!"); } cue.OnInit(xactCue, cueEnum); m_activeCues.Add(xactCue.NativePointer.ToInt64(), cue); return(new MySoundCue(cue.Cue, cueEnum, apply3d)); }
public static void CreateExplosionDebris(ref BoundingSphere explosionSphere, MyGroupMask groupMask, MyEntity entity, MyVoxelMap voxelMap, ref BoundingBox bb) { // Number of debris is random, but not more than size of the offset array float scaleMul = explosionSphere.Radius / 4.0f; GeneratePositions(bb); foreach (Vector3 positionInLocalSpace in m_positions) { var positionInWorldSpace = Vector3.Transform(positionInLocalSpace, entity.WorldMatrix); MyExplosionDebrisModel newObj = m_objectPool.Allocate(true); if (newObj == null) { continue; } // Check if new object won't intersect any existing triangle - because if yes, then it will decrease JLX performace a lot float randomNewScale = MyMwcUtils.GetRandomFloat(scaleMul / 4, scaleMul); var sphere = new BoundingSphere(positionInWorldSpace, newObj.m_modelLod0.BoundingSphere.Radius * randomNewScale); MyEntity myEntitiesGetIntersectionWithSphere = MyEntities.GetIntersectionWithSphere(ref sphere); if ((myEntitiesGetIntersectionWithSphere == null || myEntitiesGetIntersectionWithSphere == entity) && (voxelMap == null || !voxelMap.DoOverlapSphereTest(sphere.Radius, sphere.Center))) { if (Vector3.DistanceSquared(positionInWorldSpace, explosionSphere.Center) > MyMwcMathConstants.EPSILON_SQUARED) { newObj.Start(positionInWorldSpace, randomNewScale, groupMask, true); newObj.Physics.LinearVelocity = GetDirection(positionInWorldSpace, explosionSphere.Center) * MyExplosionsConstants.EXPLOSION_DEBRIS_SPEED; MyEntities.Add(newObj); if (MyExplosion.DEBUG_EXPLOSIONS) { m_debugVoxelSpheres.Add(sphere); } } } else { // Put back to object pool newObj.Close(); } } }
private void ProcessBeforeDraw(out int visibleCount) { ClearTexts(); visibleCount = 0; lock (m_lockObject) { for (int i = MAX_PRIORITY; i >= 0; --i) { List <MyHudNotificationBase> notifications; m_notificationsByPriority.TryGetValue(i, out notifications); if (notifications == null) { continue; } foreach (var notification in notifications) { if (!IsDrawn(notification)) { continue; } StringBuilder messageStringBuilder = m_textsPool.Allocate(); Debug.Assert(messageStringBuilder != null); messageStringBuilder.Append(notification.GetText()); Vector2 textSize = MyGuiManager.MeasureString(notification.Font, messageStringBuilder, MyGuiSandbox.GetDefaultTextScaleWithLanguage()); m_textSizes.Add(textSize); m_texts.Add(messageStringBuilder); ++visibleCount; if (visibleCount == MyNotificationConstants.MAX_DISPLAYED_NOTIFICATIONS_COUNT) { return; } } } } }
public IDepthStencil CreateDepthStencil(string debugName, int width, int height, Format resourceFormat = Format.R32G8X24_Typeless, Format dsvFormat = Format.D32_Float_S8X24_UInt, Format srvDepthFormat = Format.R32_Float_X8X24_Typeless, Format srvStencilFormat = Format.X32_Typeless_G8X24_UInt, int samplesCount = 1, int samplesQuality = 0) { MyDepthStencil tex = m_objectsPool.Allocate(); tex.Init(debugName, width, height, resourceFormat, dsvFormat, srvDepthFormat, srvStencilFormat, samplesCount, samplesQuality); if (m_isDeviceInit) { tex.OnDeviceInit(); } return(tex); }
public static MyAnimatedParticle AddAnimatedParticle() { return(m_animatedParticles.Allocate(true)); }
public static MyExplosionDebrisVoxel Allocate() { return(m_objectPool.Allocate(true)); }
// Add new explosion to the list, but caller needs to start it using Start() method public static MyExplosion AddExplosion() { return(m_explosions.Allocate()); }