コード例 #1
0
        private float age_to_alpha(float x, float dx)
        {
            x = FMath.Abs(x - 0.5f);
            float num = 0.5f - dx;

            return(1f - FMath.Max(0f, (x - num) * (1f / dx)));
        }
コード例 #2
0
ファイル: ConvexPoly2.cs プロジェクト: weimingtom/Sakura
        public ConvexPoly2(Vector2[] points)
        {
            Vector2 vector = Math._00;

            this.Planes = new Plane2[points.Length];
            int num  = points.Length;
            int num2 = num - 1;
            int i    = 0;

            while (i < num)
            {
                Vector2 vector2 = points[num2];
                Vector2 vector3 = points[i];
                this.Planes[num2] = new Plane2(vector2, -Math.Perp(vector3 - vector2).Normalize());
                vector           += vector2;
                num2 = i++;
            }
            vector /= (float)points.Length;
            float num3 = 0f;

            for (num2 = 0; num2 != points.Length; num2++)
            {
                num3 = FMath.Max(num3, (points[num2] - vector).Length());
            }
            this.m_sphere = new Sphere2(vector, num3);
        }
コード例 #3
0
        public static DbvtAabbMm FromVec(VInt3 from, VInt3 to, DbvtAabbMm output)
        {
            DbvtAabbMm box = output;

            box.mi.x = FMath.Min(from.x, to.x); box.mi.y = FMath.Min(from.y, to.y); box.mi.z = FMath.Min(from.z, to.z);
            box.mx.x = FMath.Max(from.x, to.x); box.mx.y = FMath.Max(from.y, to.y); box.mx.z = FMath.Max(from.z, to.z);
            return(box);
        }
コード例 #4
0
        static VFixedPoint squareDistance(VInt3 p0, VInt3 dir, VFixedPoint t, VInt3 point)
        {
            VInt3       diff = point - p0;
            VFixedPoint fT   = VInt3.Dot(diff, dir);

            fT    = FMath.Min(FMath.Max(fT, VFixedPoint.Zero), t);
            diff -= dir * fT;
            return(diff.sqrMagnitude);
        }
コード例 #5
0
        public static bool getSphereDistance(BoxShape boxShape, VIntTransform m44T, VInt3 sphereCenter, VFixedPoint radius, out VInt3 normal, out VFixedPoint penetrationDepth)
        {
            VInt3       boxHalfExtent = boxShape.getHalfExtent();
            VFixedPoint boxMargin     = boxShape.getMargin();

            penetrationDepth = VFixedPoint.Zero;

            // convert the sphere position to the box's local space
            VInt3 sphereRelPos = m44T.InverseTransformPoint(sphereCenter);

            // Determine the closest point to the sphere center in the box
            VInt3 closestPoint = sphereRelPos;

            closestPoint.x = (FMath.Min(boxHalfExtent.x, closestPoint.x));
            closestPoint.x = (FMath.Max(-boxHalfExtent.x, closestPoint.x));
            closestPoint.y = (FMath.Min(boxHalfExtent.y, closestPoint.y));
            closestPoint.y = (FMath.Max(-boxHalfExtent.y, closestPoint.y));
            closestPoint.z = (FMath.Min(boxHalfExtent.z, closestPoint.z));
            closestPoint.z = (FMath.Max(-boxHalfExtent.z, closestPoint.z));

            VFixedPoint intersectionDist = radius + boxMargin;
            VFixedPoint contactDist      = intersectionDist;

            normal = sphereRelPos - closestPoint;

            //if there is no penetration, we are done
            VFixedPoint dist2 = normal.sqrMagnitude;

            if (dist2 > contactDist * contactDist)
            {
                return(false);
            }

            VFixedPoint distance;

            //special case if the sphere center is inside the box
            if (dist2 <= Globals.EPS)
            {
                distance = -getSpherePenetration(boxHalfExtent, sphereRelPos, ref closestPoint, out normal);
            }
            else //compute the penetration details
            {
                distance = normal.magnitude;
                normal  /= distance;
            }

            //	v3PointOnSphere = sphereRelPos - (normal * fRadius);
            penetrationDepth = distance - intersectionDist;

            VInt3 tmp = m44T.TransformDirection(normal);

            normal = tmp;

            return(true);
        }
コード例 #6
0
        public static void Merge(DbvtAabbMm a, DbvtAabbMm b, DbvtAabbMm r)
        {
            r.mi.x = FMath.Min(a.mi.x, b.mi.x);
            r.mx.x = FMath.Max(a.mx.x, b.mx.x);

            r.mi.y = FMath.Min(a.mi.y, b.mi.y);
            r.mx.y = FMath.Max(a.mx.y, b.mx.y);

            r.mi.z = FMath.Min(a.mi.z, b.mi.z);
            r.mx.z = FMath.Max(a.mx.z, b.mx.z);
        }
コード例 #7
0
ファイル: Sphere2.cs プロジェクト: weimingtom/Sakura
        public bool NegativeClipSegment(ref Vector2 A, ref Vector2 B)
        {
            Vector2 vector = B - A;
            float   num    = this.Radius * this.Radius;
            float   num2   = 1E-08f;
            bool    result;

            if (vector.LengthSquared() <= num2)
            {
                if ((A - this.Center).LengthSquared() >= num)
                {
                    result = false;
                    return(result);
                }
            }
            Vector2 vector2 = this.Center.ProjectOnLine(A, vector);
            float   num3    = (vector2 - this.Center).LengthSquared();

            if (num3 >= num)
            {
                result = false;
            }
            else
            {
                float   num4    = FMath.Sqrt(FMath.Max(0f, num - num3));
                Vector2 vector3 = vector.Normalize();
                Vector2 vector4 = vector2 - num4 * vector3;
                Vector2 vector5 = vector2 + num4 * vector3;
                if ((A - vector5).Dot(vector) >= 0f)
                {
                    result = false;
                }
                else if ((B - vector4).Dot(vector) <= 0f)
                {
                    result = false;
                }
                else
                {
                    if ((A - vector4).Dot(vector) < 0f)
                    {
                        A = vector4;
                    }
                    if ((B - vector5).Dot(vector) > 0f)
                    {
                        B = vector5;
                    }
                    result = true;
                }
            }
            return(result);
        }
コード例 #8
0
ファイル: SpriteRenderer.cs プロジェクト: weimingtom/Sakura
        public Bounds2 DrawTextDebug(string str, Vector2 bottom_left_start_pos, float char_height, bool draw = true, SpriteRenderer.ISpriteShader shader = null)
        {
            if (null == shader)
            {
                shader = this.m_default_font_shader;
            }
            float   num     = char_height / (float)EmbeddedDebugFontData.CharSizei.Y;
            Vector2 vector  = new Vector2(-1f, 1f);
            Vector2 vector2 = vector * num;
            TRS     tRS     = default(TRS);

            tRS.R = Math._10;
            tRS.S = EmbeddedDebugFontData.CharSizef * num;
            tRS.T = bottom_left_start_pos;
            Vector2 max = bottom_left_start_pos;
            float   x   = tRS.T.X;

            if (draw)
            {
                this.DefaultFontShader.SetUVTransform(ref Math.UV_TransformFlipV);
                this.BeginSprites(this.m_embedded_font_texture_info, this.DefaultFontShader, str.Length);
            }
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == '\n')
                {
                    tRS.T  -= new Vector2(0f, tRS.S.Y + vector2.Y);
                    tRS.T.X = x;
                }
                else
                {
                    if (draw)
                    {
                        int num2 = (int)(str[i] - ' ');
                        if (num2 < 0 || num2 >= EmbeddedDebugFontData.NumChars)
                        {
                            num2 = 31;
                        }
                        this.AddSprite(ref tRS, new Vector2i(num2, 0));
                    }
                    tRS.T += new Vector2(tRS.S.X + vector2.X, 0f);
                    max.X  = FMath.Max(tRS.T.X, max.X);
                    max.Y  = FMath.Min(tRS.T.Y, max.Y);
                }
            }
            if (draw)
            {
                this.EndSprites();
            }
            return(Bounds2.SafeBounds(bottom_left_start_pos + new Vector2(0f, tRS.S.Y), max));
        }
コード例 #9
0
        public static bool RayAabb2(VInt3 rayFrom,
                                    VInt3 rayTo,
                                    VInt3 aabbMin, VInt3 aabbMax,
                                    ref VFixedPoint tmin,
                                    ref VFixedPoint tmax
                                    )
        {
            VInt3       d     = rayTo - rayFrom;
            VFixedPoint tminf = VFixedPoint.Zero;
            VFixedPoint tmaxf = VFixedPoint.One;

            for (int i = 0; i < 3; i++)
            {
                bool isParallel = d[i].Abs() < Globals.EPS;
                if (isParallel)
                {
                    if ((rayFrom[i] < aabbMin[i] || rayFrom[i] > aabbMax[i]))
                    {
                        return(false);
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    VFixedPoint odd = VFixedPoint.One / d[i];
                    VFixedPoint t1  = (aabbMin[i] - rayFrom[i]) * odd;
                    VFixedPoint t2  = (aabbMax[i] - rayFrom[i]) * odd;
                    if (t1 > t2)
                    {
                        VFixedPoint tmp = t1;
                        t1 = t2;
                        t2 = tmp;
                    }

                    tminf = FMath.Max(tminf, t1);
                    tmaxf = FMath.Min(tmaxf, t2);
                }
            }

            tmin = tminf; tmax = tmaxf;
            return(!(tmin > tmax || tmin > VFixedPoint.One));
        }
コード例 #10
0
ファイル: DrawHelpers.cs プロジェクト: weimingtom/Sakura
 public void DrawRulers(Bounds2 bounds, float step_x, float step_y)
 {
     step_x = FMath.Max(step_x, 0f);
     step_y = FMath.Max(step_y, 0f);
     if (step_x >= 1.401298E-45f)
     {
         if (step_y >= 1.401298E-45f)
         {
             float x    = bounds.Min.X;
             float x2   = bounds.Max.X;
             float y    = bounds.Min.Y;
             float y2   = bounds.Max.Y;
             int   num  = (int)(x / step_x);
             int   num2 = (int)(x2 / step_x);
             int   num3 = (int)(y / step_y);
             int   num4 = (int)(y2 / step_y);
             this.ShaderPush();
             bool flag  = num2 - num + 1 < 1000;
             bool flag2 = num4 - num3 + 1 < 1000;
             this.ImmBegin((DrawMode)1, (uint)((flag ? ((num2 - num + 1) * 2) : 0) + (flag2 ? ((num4 - num3 + 1) * 2) : 0)));
             if (flag)
             {
                 for (int i = num; i <= num2; i++)
                 {
                     this.ImmVertex(new Vector2((float)i * step_x, y));
                     this.ImmVertex(new Vector2((float)i * step_x, y2));
                 }
             }
             if (flag2)
             {
                 for (int i = num3; i <= num4; i++)
                 {
                     this.ImmVertex(new Vector2(x, (float)i * step_y));
                     this.ImmVertex(new Vector2(x2, (float)i * step_y));
                 }
             }
             this.ImmEnd();
             this.ShaderPop();
         }
     }
 }
コード例 #11
0
ファイル: SpriteRenderer.cs プロジェクト: weimingtom/Sakura
        public Bounds2 DrawTextWithFontMap(string str, Vector2 bottom_left_start_pos, float char_height, bool draw, FontMap fontmap, SpriteRenderer.ISpriteShader shader)
        {
            float   num     = char_height / fontmap.CharPixelHeight;
            Vector2 vector  = new Vector2(1f, 1f);
            Vector2 vector2 = vector * num;
            Vector2 vector3 = bottom_left_start_pos;
            Vector2 max     = bottom_left_start_pos;
            float   x       = bottom_left_start_pos.X;

            if (draw)
            {
                shader.SetUVTransform(ref Math.UV_TransformFlipV);
                this.BeginSprites(new TextureInfo(fontmap.Texture), shader, str.Length);
            }
            for (int i = 0; i < str.Length; i++)
            {
                FontMap.CharData charData;
                if (str[i] == '\n')
                {
                    vector3  -= new Vector2(0f, char_height + vector2.Y);
                    vector3.X = x;
                }
                else if (fontmap.TryGetCharData(str[i], out charData))
                {
                    Vector2 vector4 = charData.PixelSize * num;
                    if (draw)
                    {
                        this.AddSprite(vector3, new Vector2(vector4.X, 0f), charData.UV);
                    }
                    vector3 += new Vector2(vector4.X + vector2.X, 0f);
                    max.X    = FMath.Max(vector3.X, max.X);
                    max.Y    = FMath.Min(vector3.Y, max.Y);
                }
            }
            if (draw)
            {
                this.EndSprites();
            }
            return(Bounds2.SafeBounds(bottom_left_start_pos + new Vector2(0f, char_height), max));
        }
コード例 #12
0
        private static float CalculateTextureOffset(float spritePosition, float spriteSize, float offsetPosition, float textureMarginSize, float maxTextureSize, float frontPanelSize)
        {
            float result;

            if (spritePosition < maxTextureSize - textureMarginSize - spriteSize)
            {
                result = 0f;
            }
            else if (spritePosition > frontPanelSize - spriteSize - textureMarginSize)
            {
                result = FMath.Max(frontPanelSize - maxTextureSize, 0f);
            }
            else if (spritePosition > offsetPosition + textureMarginSize && spritePosition < offsetPosition + maxTextureSize - textureMarginSize - spriteSize)
            {
                result = offsetPosition;
            }
            else
            {
                result = spritePosition + spriteSize / 2f - maxTextureSize / 2f;
            }
            return(result);
        }
コード例 #13
0
        public void Update(float dt)
        {
            this.m_observed_velocity         = (this.Emit.TransformForVelocityEstimate.Z - this.m_tracking_transform_prev.Z).Xy / dt;
            this.m_observed_angular_velocity = this.m_tracking_transform_prev.X.Xy.Normalize().Angle(this.Emit.TransformForVelocityEstimate.X.Xy.Normalize()) / dt;
            this.m_tracking_transform_prev   = this.Emit.TransformForVelocityEstimate;
            this.m_elapsed += (double)dt;
            float num = FMath.Max(0f, this.Emit.WaitTime * (1f + this.Emit.WaitTimeRelVar * this.m_random.NextFloatMinus1_1()));

            this.m_emit_timer += dt;
            while (this.m_emit_timer > num && !this.IsFull)
            {
                this.init_auto_particle(this.m_particles[this.m_particles_count]);
                this.m_particles_count++;
                this.m_emit_timer -= num;
                num = FMath.Max(0f, this.Emit.WaitTime * (1f + this.Emit.WaitTimeRelVar * this.m_random.NextFloatMinus1_1()));
            }
            Vector2 vector = this.Simulation.Gravity * this.Simulation.GravityDirection + this.Simulation.Wind * this.Simulation.WindDirection;
            int     i      = 0;

            while (i < this.m_particles_count)
            {
                if (this.m_particles[i].Dead)
                {
                    Common.Swap <ParticleSystem.Particle>(ref this.m_particles[i], ref this.m_particles[this.m_particles_count - 1]);
                    this.m_particles_count--;
                }
                else
                {
                    Vector2 vector2 = vector;
                    if (this.Simulation.BrownianScale != 0f)
                    {
                        vector2 += this.m_random.NextVector2Minus1_1() * this.Simulation.BrownianScale;
                    }
                    this.update(this.m_particles[i], dt, vector2);
                    i++;
                }
            }
        }
コード例 #14
0
        private void init_auto_particle(ParticleSystem.Particle p)
        {
            p.LifeSpan         = FMath.Max(0f, this.Emit.LifeSpan * (1f + this.Emit.LifeSpanRelVar * this.m_random.NextFloatMinus1_1()));
            p.Age              = 0f;
            p.LifeSpanRcp      = 1f / p.LifeSpan;
            p.Position         = this.Emit.Position + this.Emit.PositionVar * this.m_random.NextVector2(-1f, 1f);
            p.Position         = (this.Emit.Transform * p.Position.Xy1).Xy;
            p.Velocity         = this.Emit.Velocity + this.Emit.VelocityVar * this.m_random.NextVector2(-1f, 1f);
            p.Velocity         = (this.Emit.Transform * p.Velocity.Xy0).Xy;
            p.Angle            = FMath.Max(0f, this.Emit.Angle + this.Emit.AngleVar * this.m_random.NextFloatMinus1_1());
            p.Angle           += Math.Angle(this.Emit.Transform.X.Xy.Normalize());
            p.AngularVelocity  = FMath.Max(0f, this.Emit.AngularVelocity + this.Emit.AngularVelocityVar * this.m_random.NextFloatMinus1_1());
            p.Velocity        += this.Emit.ForwardMomentum * this.m_observed_velocity;
            p.AngularVelocity += this.Emit.AngularMomentun * this.m_observed_angular_velocity;
            p.ScaleStart       = FMath.Max(0f, this.Emit.ScaleStart * (1f + this.Emit.ScaleStartRelVar * this.m_random.NextFloatMinus1_1()));
            float num = FMath.Max(0f, this.Emit.ScaleEnd * (1f + this.Emit.ScaleEndRelVar * this.m_random.NextFloatMinus1_1()));

            p.ScaleDelta = (num - p.ScaleStart) / p.LifeSpan;
            p.ColorStart = (this.Emit.ColorStart + this.Emit.ColorStartVar * this.m_random.NextFloatMinus1_1()).Clamp(0f, 1f);
            Vector4 vector = (this.Emit.ColorEnd + this.Emit.ColorEndVar * this.m_random.NextFloatMinus1_1()).Clamp(0f, 1f);

            p.ColorDelta = (vector - p.ColorStart) / p.LifeSpan;
        }
コード例 #15
0
        static bool keepTriangle(VFixedPoint triImpactDistance, VFixedPoint triAlignmentValue, VFixedPoint bestImpactDistance, VFixedPoint bestAlignmentValue, VFixedPoint maxDistance, VFixedPoint distEpsilon)
        {
            // Reject triangle if further than the maxDistance
            if (triImpactDistance > maxDistance)
            {
                return(false);
            }

            // PT: make it a relative epsilon to make sure it still works with large distances
            distEpsilon *= FMath.Max(VFixedPoint.One, FMath.Max(triImpactDistance, bestImpactDistance));

            // If new distance is more than epsilon closer than old distance
            if (triImpactDistance < bestImpactDistance - distEpsilon)
            {
                return(true);
            }

            // If new distance is no more than epsilon farther than oldDistance and "face is more opposing than previous"
            if (triImpactDistance < bestImpactDistance + distEpsilon && triAlignmentValue < bestAlignmentValue)
            {
                return(true);
            }

            // If alignment value is the same, but the new triangle is closer than the best distance
            if (triAlignmentValue == bestAlignmentValue && triImpactDistance < bestImpactDistance)
            {
                return(true);
            }

            // If initial overlap happens, keep the triangle
            if (triImpactDistance == VFixedPoint.Zero)
            {
                return(true);
            }

            return(false);
        }
コード例 #16
0
ファイル: CtrlStage.cs プロジェクト: hatano0x06/Coroppoxus
        /// 壁の生成
        public void makeWall(int scrPosX, int scrPosY)
        {
            GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager();

            Vector3 posStart = new Vector3(0, 0, 0);
            Vector3 posEnd   = new Vector3(0, 0, 0);

            /// チェックする開始座標と終了座標のセット
            ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 0.0f, ref posStart);
            ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 1.0f, ref posEnd);


            DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine(posStart, posEnd);

            /// 衝突対象の登録
            useCollMgr.TrgContainer.Clear();
            ctrlResMgr.CtrlTo.SetDestinationActor(useCollMgr.TrgContainer);
            useCollMgr.TrgContainer.Add(actorStg, actorStg.GetUseObj(0));


            /// 衝突判定
            calCollLook.SetMoveType(Data.CollTypeId.ChDestination);

            bool checkBound = calCollLook.Check(useCollMgr, moveMoveLine);

            if (checkBound)
            {
                /// マーカーのセット
//            actorDestination.Start();

                Matrix4 mtx = Matrix4.RotationY(0);
                destinationTrgActor = useCollMgr.TrgContainer.GetEntryObjParent(0);
                ShapeSphere bndSph = destinationTrgActor.GetBoundingShape();
                if (destinationTrgActor.CheckMoveTrgId() == 2)          //始点の建物に接触
                {
                    towerNowPos  = destinationTrgActor.BasePos;
                    TouchPostion = destinationTrgActor.BasePos;
                    if (towerPos.X != towerNowPos.X && towerPos.Z != towerNowPos.Z && !(towerPos.X == 0.0f && towerPos.Y == 0.0f && towerPos.Z == 0.0f))              //最初のタッチ以外もしくは前のタワー以外との接触の場合
                    {
                        if (bndSph != null)
                        {
                            towerNowPos.Y += bndSph.Sphre.R;
                        }
                        towerNowPos.Y         += 0.1f;
                        ctrlResMgr.AddWall     = true;
                        ctrlResMgr.AddWallPos1 = towerPos;
                        ctrlResMgr.AddWallPos2 = towerNowPos;
                        makeTowerFlag          = false;
                        Console.WriteLine("asdf");
                    }
                }
                else
                {
                    Console.WriteLine("fdsa");
                    towerNowPos    = calCollLook.NextPos;
                    TouchPostion   = calCollLook.NextPos;
                    towerNowPos.Y += 0.1f;
                    if (towerPos.X == 0.0f && towerPos.Y == 0.0f && towerPos.Z == 0.0f)
                    {
                        towerPos  = towerNowPos;
                        effectPos = towerNowPos;
                        //ctrlResMgr.CtrlTo.EntryAddTower( 1, 0.0f, towerNowPos, (int)StaticDataList.getRandom(0,5));
                    }
                    double dis2 = Common.VectorUtil.Distance(towerPos, towerNowPos);
                    if (dis2 > newTowerDis)
                    {
                        ctrlResMgr.AddWall     = true;
                        ctrlResMgr.AddWallPos1 = towerPos;
                        ctrlResMgr.AddWallPos2 = towerNowPos;

                        ctrlResMgr.AddTower    = true;
                        ctrlResMgr.AddTowerPos = towerNowPos;

                        TowerAreaNorth = FMath.Max(TowerAreaNorth, towerNowPos.X);
                        TowerAreaSouth = FMath.Min(TowerAreaSouth, towerNowPos.X);
                        TowerAreaEast  = FMath.Max(TowerAreaEast, towerNowPos.Z);
                        TowerAreaWest  = FMath.Min(TowerAreaWest, towerNowPos.Z);
                        //AppSound.GetInstance().PlaySeCamDis( AppSound.SeId.MakeMo, towerNowPos );

                        towerPos = towerNowPos;
                        //sumPos += towerPos;
                        //sumcount++;
                    }
                    dis2 = Common.VectorUtil.Distance(effectPos, towerNowPos);
                    if (dis2 > newEffectDis)
                    {
                        ctrlResMgr.AddEffectFromEnemy = true;
                        ctrlResMgr.AddEnemyEffectPos  = towerNowPos;
                        effectPos = towerNowPos;
                    }
                }
            }
        }
コード例 #17
0
ファイル: Map.cs プロジェクト: gambiting/VitaShooter
        public Map(string filePath)
        {
            this.filePath = filePath;
            random        = new Random();

            tileLocations = new Dictionary <MapTile.Types, Vector2i>();

            setupLocations();

            tiles     = new List <MapTile> ();
            wallTiles = new List <MapTile> ();


            ParseFile(this, filePath, tiles);

            tiles.Reverse();

            prepareDescriptions(this, tiles);

            spriteList = prepareTiles(this, tiles);


            Console.WriteLine("map: " + filePath);
            Console.WriteLine("width: " + width);
            Console.WriteLine("heigh: " + height);

            //prepare thumbnail

            //create new scene for the thumbnail
            ThumbnailScene ts = new ThumbnailScene();

            //set up the camera so the entire level is visible
            ts.Camera2D.SetViewFromWidthAndCenter(FMath.Max(width, height), new Vector2(width / 2.0f, height / 2.0f));



            //create a new framebuffer for the thumbnail
            FrameBuffer thumbnailBuffer = new FrameBuffer();
            //create an associated texture
            Texture2D tex2d = new Texture2D(256, 256, false, PixelFormat.Rgba, PixelBufferOption.Renderable);

            thumbnailBuffer.SetColorTarget(tex2d, 0);

            //sprite to contain the thumbnail
            thumbnailSprite = new SpriteUV(new TextureInfo(tex2d));


            //render the thumbnail:
            if (Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.CurrentScene == null)
            {
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.RunWithScene(ts, true);
            }
            else
            {
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.ReplaceScene(ts);
            }
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Update();

            //save the current framebuffer and viewport
            FrameBuffer oldBuffer      = Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.GetFrameBuffer();
            ImageRect   oldViewport    = Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.GetViewport();
            Vector4     oldClearColour = Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.GetClearColor();

            //set the new framebuffer for the thumbnail
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetFrameBuffer(thumbnailBuffer);
            //set the correct viewport
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetViewport(0, 0, 256, 256);

            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetClearColor(new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.Clear();

            //add the spritelists to the scene
            foreach (SpriteList sl in spriteList)
            {
                ts.Background.AddChild(sl);
            }

            //render the thumbnail scene
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.CurrentScene.render();

            //switch back to old framebuffer and viewport:
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetFrameBuffer(oldBuffer);
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetViewport(oldViewport);
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetClearColor(oldClearColour);


            //get rid of the scene
            //remove all children,but WITHOUT THE CLEANUP(otherwise they won't work in the main Game scene)
            ts.Background.RemoveAllChildren(false);
            ts = null;

            //Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SwapBuffers ();
            //Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.PostSwap ();

            //make the thumbnail larger
            //thumbnailSprite.Position = new Vector2(100.0f,100.0f);
            thumbnailSprite.FlipV = true;
            thumbnailSprite.CenterSprite(new Vector2(0.5f, 0.5f));
            thumbnailSprite.Scale = new Vector2(400.0f, 400.0f);
        }
コード例 #18
0
 public static VInt3 Max(VInt3 a, VInt3 b)
 {
     return(new VInt3(FMath.Max(a.x, b.x), FMath.Max(a.y, b.y), FMath.Max(a.z, b.z)));
 }
コード例 #19
0
ファイル: AnimationUtility.cs プロジェクト: weimingtom/Sakura
        private static float GetFunctionInterpolateRatio(int strength)
        {
            float num = (float)(-(float)strength) / 100f;

            return(Math.Abs(FMath.Max(-1f, FMath.Min(1f, num))));
        }
コード例 #20
0
ファイル: Camera2D.cs プロジェクト: weimingtom/Sakura
        public void Navigate(int control)
        {
            this.m_prev_touch_state = this.m_touch_state;
            this.m_touch_state      = Input2.Touch00.Down;
            bool flag        = this.m_touch_state && !this.m_prev_touch_state;
            bool touch_state = this.m_touch_state;

            if (control == 1)
            {
                if (touch_state)
                {
                    if (flag)
                    {
                        this.m_drag_start_pos = this.GetTouchPos(0, false);
                        this.m_data_start     = this.m_data;
                        this.m_drag_mode      = 1;
                    }
                    if (this.m_drag_mode == 1)
                    {
                        Camera2D.Data data = this.m_data;
                        this.m_data = this.m_data_start;
                        Vector2 touchPos = this.GetTouchPos(0, !flag);
                        this.m_data          = data;
                        this.m_data.m_center = this.m_data_start.m_center + (this.m_drag_start_pos - touchPos);
                    }
                }
                else
                {
                    this.m_drag_mode = 0;
                }
            }
            if (control == 2)
            {
                if (touch_state)
                {
                    if (flag)
                    {
                        this.m_drag_start_pos     = this.GetTouchPos(0, false);
                        this.m_drag_start_pos_ncs = Input2.Touch00.Pos;
                        this.m_data_start         = this.m_data;
                        this.m_drag_mode          = 2;
                    }
                    if (this.m_drag_mode == 2)
                    {
                        Camera2D.Data data = this.m_data;
                        this.m_data = this.m_data_start;
                        Vector2 touchPos2 = this.GetTouchPos(0, !flag);
                        Vector2 vector    = (!flag) ? Input2.Touch00.PreviousPos : Input2.Touch00.Pos;
                        this.m_data = data;
                        Vector2 vector2 = vector - this.m_drag_start_pos_ncs;
                        this.m_data.m_support_scale = this.m_data_start.m_support_scale * this.zoom_curve(-vector2.Y, 2f, 5f);
                        this.m_data.m_support_scale = FMath.Clamp(this.m_data.m_support_scale, this.m_data_start.m_support_scale / 100f, this.m_data_start.m_support_scale * 10f);
                        this.m_data.m_support_scale = FMath.Max(this.m_data.m_support_scale, 0.0001f);
                    }
                }
                else
                {
                    this.m_drag_mode = 0;
                }
            }
        }