protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_downloads_list);
            appContext = (DemoApplication)Application;
            handler    = new Timer();

            ListItem mapResourcesItem = new ListItem();

            await Task.Run(() => initializeMapResources())
            .ContinueWith((t) =>
            {
                if (t.Result)
                {
                    appContext.AppPrefs.SaveBooleanPreference(ApplicationPreferences.MAP_RESOURCES_UPDATE_NEEDED, false);
                    populateWithChildMaps(mapResourcesItem);
                    currentListItems = mapResourcesItem.Children;

                    listView         = (ListView)FindViewById(Resource.Id.list_view);
                    adapter          = new DownloadsAdapter(this);
                    listView.Adapter = adapter;
                    FindViewById(Resource.Id.cancel_all_button).Visibility = activeDownloads.Count == 0 ? ViewStates.Gone : ViewStates.Visible;
                    downloadManager = SKToolsDownloadManager.GetInstance(adapter);
                    if (activeDownloads.Count != 0 && activeDownloads[0].DownloadState == SKToolsDownloadItem.Downloading)
                    {
                        StartPeriodicUpdates();
                    }
                }
                else
                {
                    Toast.MakeText(this, "Could not retrieve map data from the server", ToastLength.Short).Show();
                    Finish();
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
        public static void SetEnvironment(Context context, int environment)
        {
            GetPreferences(context)
            .Edit()
            .PutInt(ENVIRONMENT, environment)
            .Apply();

            DemoApplication.ResetApiClient();
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_list);
            FindViewById(Resource.Id.label_operation_in_progress).Visibility = ViewStates.Gone;
            listView = (ListView)FindViewById(Resource.Id.list_view);
            app      = (DemoApplication)Application;
            string gpxName = Intent.Extras.GetString(Intent.ExtraText);

            loadedFile = SKTracksFile.LoadAtPath(app.MapResourcesDirPath + "GPXTracks/" + gpxName);
            Initialize();
        }
Example #4
0
        async void LaunchGame()
        {
            await Task.Yield();

            using (var context = new Context())
            {
                using (var app = new DemoApplication(context, new ApplicationOptions()))
                {
                    app.Run();
                }
            }
        }
Example #5
0
 public static int SdlMain(int argn, IntPtr argv)
 {
     Trace.WriteLine("MainActivity.SDLMain()");
     using (var context = new Urho3DNet.Context())
     {
         var options = new ApplicationOptions();
         //var assets = Android.OS.Environment.ExternalStorageDirectory.ToString();
         //options.EpResourcePrefixPaths = assets+";"+ assets+"/Assets";
         using (var application = new DemoApplication(context, options))
         {
             return(application.Run());
         }
     }
 }
Example #6
0
        /**
         * Checks if the current version code is grater than the previous and performs an SDK update.
         */
        public void CheckForSDKUpdate()
        {
            DemoApplication appContext         = Application as DemoApplication;
            int             currentVersionCode = appContext.AppPrefs.GetIntPreference(ApplicationPreferences.CURRENT_VERSION_CODE);
            int             versionCode        = VersionCode;

            if (currentVersionCode == 0)
            {
                appContext.AppPrefs.SetCurrentVersionCode(versionCode);
            }

            if (0 < currentVersionCode && currentVersionCode < versionCode)
            {
                SKMaps.UpdateToLatestSDKVersion = true;
                appContext.AppPrefs.SetCurrentVersionCode(versionCode);
            }
        }
Example #7
0
        /**
         * Copies the map creator file and logFile from assets to a storage.
         */
        private async void PrepareMapCreatorFile()
        {
            string          mapResourcesDirPath = SKMaps.Instance.MapInitSettings.MapResourcesPath;
            DemoApplication app = Application as DemoApplication;
            await Task.Run(() =>
            {
                try
                {
                    bool resAlreadyExist;

                    string mapCreatorFolderPath = mapResourcesDirPath + "MapCreator";
                    // create the folder where you want to copy the json file
                    File mapCreatorFolder = new File(mapCreatorFolderPath);

                    resAlreadyExist = mapCreatorFolder.Exists();
                    if (!resAlreadyExist || _update)
                    {
                        if (!resAlreadyExist)
                        {
                            mapCreatorFolder.Mkdirs();
                        }
                        app.MapCreatorFilePath = mapCreatorFolderPath + "/mapcreatorFile.json";
                        DemoUtils.CopyAsset(Assets, "MapCreator", mapCreatorFolderPath, "mapcreatorFile.json");
                    }

                    // Copies the log file from assets to a storage.
                    string logFolderPath = mapResourcesDirPath + "logFile";
                    File logFolder       = new File(logFolderPath);
                    resAlreadyExist      = logFolder.Exists();
                    if (!resAlreadyExist || _update)
                    {
                        if (!resAlreadyExist)
                        {
                            logFolder.Mkdirs();
                        }
                        DemoUtils.CopyAsset(Assets, "logFile", logFolderPath, "Seattle.log");
                    }
                }
                catch (IOException e)
                {
                    e.PrintStackTrace();
                }
            });
        }
Example #8
0
 public void OnLibraryInitialized(bool isSuccessful)
 {
     SKLogging.WriteLog(TAG, " SKMaps library initialized isSuccessful= " + isSuccessful + " time= " + (DemoUtils.CurrentTimeMillis() - _startLibInitTime), SKLogging.LogDebug);
     if (isSuccessful)
     {
         DemoApplication app = Application as DemoApplication;
         app.MapCreatorFilePath  = SKMaps.Instance.MapInitSettings.MapResourcesPath + "MapCreator/mapcreatorFile.json";
         app.MapResourcesDirPath = SKMaps.Instance.MapInitSettings.MapResourcesPath;
         CopyOtherResources();
         PrepareMapCreatorFile();
         //everything ok. proceed
         SKVersioningManager.Instance.SetMapUpdateListener(this);
         GoToMap();
     }
     else
     {
         //map was not initialized successfully
         Finish();
     }
 }
Example #9
0
        static void Main(string[] args)
        {
            // Create app
            DemoApplication application = new DemoApplication();

            // Create Services
            uint          width         = 1280;
            uint          height        = 720;
            WindowsSystem windowsSystem = new WaveEngine.Forms.FormsWindowsSystem();

            application.Container.RegisterInstance(windowsSystem);
            var window = windowsSystem.CreateWindow("NET5Demo - DX12", width, height);

            ConfigureGraphicsContext(application, window);

            // Creates XAudio device
            var xaudio = new WaveEngine.XAudio2.XAudioDevice();

            application.Container.RegisterInstance(xaudio);

            Stopwatch clockTimer = Stopwatch.StartNew();

            windowsSystem.Run(
                () =>
            {
                application.Initialize();
            },
                () =>
            {
                var gameTime = clockTimer.Elapsed;
                clockTimer.Restart();

                application.UpdateFrame(gameTime);
                application.DrawFrame(gameTime);
            });
        }
 internal static HandleRef getCPtr(DemoApplication obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Example #11
0
    public static int glutmain(int argc, SWIGTYPE_p_p_char argv, int width, int height, string title, DemoApplication demoApp)
    {
        int ret = OpenGLSupportPINVOKE.glutmain(argc, SWIGTYPE_p_p_char.getCPtr(argv), width, height, title, DemoApplication.getCPtr(demoApp));

        return(ret);
    }
Example #12
0
        public TestRig(DemoApplication demoApplication, DynamicsWorld ownerWorld, ref IndexedVector3 positionOffset, bool bFixed)
        {
            m_dynamicsWorld = ownerWorld;
            IndexedVector3 vUp = new IndexedVector3(0, 1, 0);

            //
            // Setup geometry
            //
            float fBodySize      = 0.25f;
            float fLegLength     = 0.45f;
            float fForeLegLength = 0.75f;

            m_shapes[0] = new CapsuleShape(fBodySize, 0.10f);
            for (int i = 0; i < NUM_LEGS; i++)
            {
                m_shapes[1 + 2 * i] = new CapsuleShape(0.10f, fLegLength);
                m_shapes[2 + 2 * i] = new CapsuleShape(0.08f, fForeLegLength);
            }

            //
            // Setup rigid bodies
            //
            float         fHeight = 0.5f;
            IndexedMatrix offset  = IndexedMatrix.Identity;

            offset._origin = positionOffset;

            // root
            IndexedVector3 vRoot     = new IndexedVector3(0, fHeight, 0);
            IndexedMatrix  transform = IndexedMatrix.Identity;

            transform._origin = vRoot;

            if (bFixed)
            {
                m_bodies[0] = demoApplication.LocalCreateRigidBody(0.0f, offset * transform, m_shapes[0]);
            }
            else
            {
                m_bodies[0] = demoApplication.LocalCreateRigidBody(1.0f, offset * transform, m_shapes[0]);
            }
            // legs
            for (int i = 0; i < NUM_LEGS; i++)
            {
                float fAngle = MathUtil.SIMD_2_PI * i / NUM_LEGS;
                float fSin   = (float)Math.Sin(fAngle);
                float fCos   = (float)Math.Cos(fAngle);

                transform = IndexedMatrix.Identity;
                IndexedVector3 vBoneOrigin = new IndexedVector3(fCos * (fBodySize + 0.5f * fLegLength), fHeight, fSin * (fBodySize + 0.5f * fLegLength));
                transform._origin = vBoneOrigin;

                // thigh
                IndexedVector3 vToBone = (vBoneOrigin - vRoot);
                vToBone.Normalize();

                IndexedVector3 vAxis = IndexedVector3.Cross(vToBone, vUp);
                transform._basis    = new IndexedBasisMatrix(new IndexedQuaternion(vAxis, MathUtil.SIMD_HALF_PI));
                transform._origin   = vBoneOrigin;
                m_bodies[1 + 2 * i] = demoApplication.LocalCreateRigidBody(1.0f, offset * transform, m_shapes[1 + 2 * i]);

                // shin
                transform           = IndexedMatrix.Identity;
                transform._origin   = new IndexedVector3(fCos * (fBodySize + fLegLength), fHeight - 0.5f * fForeLegLength, fSin * (fBodySize + fLegLength));
                m_bodies[2 + 2 * i] = demoApplication.LocalCreateRigidBody(1.0f, offset * transform, m_shapes[2 + 2 * i]);
            }

            // Setup some damping on the m_bodies
            for (int i = 0; i < BODYPART_COUNT; ++i)
            {
                m_bodies[i].SetDamping(0.05f, 0.85f);
                m_bodies[i].SetDeactivationTime(0.8f);
                //m_bodies[i].setSleepingThresholds(1.6, 2.5);
                m_bodies[i].SetSleepingThresholds(0.5f, 0.5f);
            }


            //
            // Setup the constraints
            //
            HingeConstraint hingeC;

            IndexedMatrix localA, localB, localC;

            for (int i = 0; i < NUM_LEGS; i++)
            {
                float fAngle = MathUtil.SIMD_2_PI * i / NUM_LEGS;
                float fSin   = (float)Math.Sin(fAngle);
                float fCos   = (float)Math.Cos(fAngle);

                // hip joints
                localA = IndexedMatrix.Identity;
                localB = IndexedMatrix.Identity;

                localA         = MathUtil.SetEulerZYX(0f, -fAngle, 0f);
                localA._origin = new IndexedVector3(fCos * fBodySize, 0.0f, fSin * fBodySize);
                localB         = m_bodies[1 + 2 * i].GetWorldTransform().Inverse() * m_bodies[0].GetWorldTransform() * localA;


                if (BulletGlobals.g_streamWriter != null && false)
                {
                    MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "Hip LocalA", localA);
                    MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "Hip LocalB", localB);
                }

                hingeC = new HingeConstraint(m_bodies[0], m_bodies[1 + 2 * i], ref localA, ref localB);
                hingeC.SetLimit(-0.75f * MathUtil.SIMD_QUARTER_PI, MathUtil.SIMD_QUARTER_PI / 2f);
                m_joints[2 * i] = hingeC;
                m_dynamicsWorld.AddConstraint(m_joints[2 * i], true);

                // knee joints
                localA = IndexedMatrix.Identity;
                localB = IndexedMatrix.Identity;
                localC = IndexedMatrix.Identity;

                localA         = MathUtil.SetEulerZYX(0f, -fAngle, 0f);
                localA._origin = new IndexedVector3(fCos * (fBodySize + fLegLength), 0.0f, fSin * (fBodySize + fLegLength));

                localB = m_bodies[1 + 2 * i].GetWorldTransform().Inverse() * m_bodies[0].GetWorldTransform() * localA;
                localC = m_bodies[2 + 2 * i].GetWorldTransform().Inverse() * m_bodies[0].GetWorldTransform() * localA;


                if (BulletGlobals.g_streamWriter != null && false)
                {
                    MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "Knee LocalA", localA);
                    MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "Knee LocalB", localB);
                    MathUtil.PrintMatrix(BulletGlobals.g_streamWriter, "Knee LocalC", localC);
                }

                hingeC = new HingeConstraint(m_bodies[1 + 2 * i], m_bodies[2 + 2 * i], ref localB, ref localC);
                //hingeC.setLimit(float(-0.01), float(0.01));
                hingeC.SetLimit(-MathUtil.SIMD_QUARTER_PI / 2f, 0.2f);
                m_joints[1 + 2 * i] = hingeC;
                m_dynamicsWorld.AddConstraint(m_joints[1 + 2 * i], true);
            }
        }
 public static int glutmain(int argc, SWIGTYPE_p_p_char argv, int width, int height, string title, DemoApplication demoApp) {
   int ret = OpenGLSupportPINVOKE.glutmain(argc, SWIGTYPE_p_p_char.getCPtr(argv), width, height, title, DemoApplication.getCPtr(demoApp));
   return ret;
 }
Example #14
0
 public ExitDemoCommand(DemoApplication demoApplication)
 {
     this.demoApplication = demoApplication ?? throw new ArgumentNullException(nameof(demoApplication));
 }
Example #15
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.activity_reverse_geocoding);
     application = Application as DemoApplication;
 }
Example #16
0
 internal static HandleRef getCPtr(DemoApplication obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }