コード例 #1
0
ファイル: App.xaml.cs プロジェクト: bashocz/Examples
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            //Resources.Add("Locator", GetLocator());

            MainWindowView mainWindow = new MainWindowView();

            ProgramData programData = new ProgramData();
            mainWindow.DataContext = new MainWindowViewModel(programData, new CoreManager(programData));

            mainWindow.Show();
        }
コード例 #2
0
        public void TestRestEntityDeleteRetry()
        {
            RestEntity<ProgramData> data = new ProgramData { Name = "testData", Id = "1" };

            var fakeException = new WebException("test", WebExceptionStatus.ConnectionClosed);

            var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 2, data);

            dataContextMock.Setup((ctxt) => ctxt.AttachTo("Origins", data));
            dataContextMock.Setup((ctxt) => ctxt.DeleteObject(data));

            _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object);

            data.SetMediaContext(_mediaContext);

            data.Delete();

            dataContextMock.Verify((ctxt) => ctxt.SaveChangesAsync(data), Times.Exactly(2));
        }
コード例 #3
0
        public void TestProgramCreateRetryAsyn()
        {
            var expected = new ProgramData { Name = "testData" };
            var fakeException = new WebException("test", WebExceptionStatus.ConnectionClosed);
            var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 2, expected);

            dataContextMock.Setup((ctxt) => ctxt.AddObject("Channels", It.IsAny<object>()));

            _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object);

            IChannel channel = new ChannelData();
            ProgramBaseCollection programs = new ProgramBaseCollection(_mediaContext, channel);

            var actual = programs.Create(expected.Name, TimeSpan.FromHours(1), Guid.NewGuid().ToString());

            Assert.AreEqual(expected.Name, actual.Name);

            dataContextMock.Verify((ctxt) => ctxt.SaveChangesAsync(It.IsAny<object>()), Times.Exactly(2));
        }
コード例 #4
0
        public async Task InitGameAsync(bool forceNewGame)
        {
            _settings = await SettingsManager.Instance.GetCurrentData().ConfigureAwait(true);

            if (forceNewGame || ReferenceEquals(_settings.CurrentGame, null))
            {
                _currentModel = CreateNewGame();
                _settings.CurrentGame = _currentModel.Data;

                await SettingsManager.Instance.SaveCurrentAsync().ConfigureAwait(true);
            }
            else
            {
                _currentModel = new GameModel(_settings.CurrentGame);
            }

            var gameColors = _currentModel.Data.Colors;
            GameColors = gameColors.Select((v, i) => new GameColorViewModel(gameColors, i)).ToArray();
        }
コード例 #5
0
        public async Task<ProgramData> GetCurrentData()
        {
            var allFiles = await SettingsFolder.GetFilesAsync();

            if (!allFiles.Any(sf => string.Equals(sf.Name, SettingsFileName, StringComparison.Ordinal)))
            {
                _currentSettings = new ProgramData();

                return _currentSettings;
            }

            var settingsFile = await SettingsFolder.GetFileAsync(SettingsFileName);

            using (var fileStream = await settingsFile.OpenReadAsync())
            {
                using (var stream = fileStream.AsStreamForRead())
                {
                    _currentSettings = (ProgramData)Serializer.Deserialize(stream);
                }

                return _currentSettings;
            }
        }
コード例 #6
0
        public static int AddProgram(string vertexShader, string fragmentShader)
        {
            int program_number = -1;
            bool new_program = true;
            for (int i = 0; i < ActivePrograms.Count; i++)
            {
                ProgramData pd = ActivePrograms[i];

                if (pd.CompareShaders(vertexShader, fragmentShader))
                {
                    new_program = false;
                    program_number = i;
                    break;
                }
            }

            if (new_program == true)
            {
                ProgramData pd = new ProgramData(vertexShader, fragmentShader);
                ActivePrograms.Add(pd);
                program_number = ActivePrograms.Count - 1;
            }
            return program_number;
        }
コード例 #7
0
ファイル: ProgramLogic.cs プロジェクト: bbadilla/tecAirlines
        /// <summary>
        /// Lista de programas
        /// </summary>
        /// <returns></returns>
        public List <object> GetPrograms()
        {
            List <Object> dataList = new List <object>();

            using (tecAirlinesEntities entities = new tecAirlinesEntities())
            {
                try
                {
                    var programList = entities.Programas.ToList();
                    int n           = programList.Count;
                    if (n == 0)
                    {
                        dataList = null;
                        return(dataList);
                    }
                    else
                    {
                        for (int i = 0; i < programList.Count; ++i)
                        {
                            ProgramData data = new ProgramData();
                            data.C_Usuario      = programList.ElementAt(i).C_Usuario;
                            data.ID_Universidad = programList.ElementAt(i).ID_Universidad;
                            data.Millas         = programList.ElementAt(i).Millas;

                            dataList.Add(data);
                        }
                        return(dataList);
                    }
                }
                catch
                {
                    dataList = null;
                    return(dataList);
                }
            }
        }
コード例 #8
0
ファイル: _Program.cs プロジェクト: codigo20/MultiRPC
 public ProgramData(string name)
 {
     if (!string.IsNullOrEmpty(name))
     {
         Path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + $"/MultiRPC/";
         File = Path + $"{name.ToLower()}.json";
         if (!Directory.Exists(Path))
         {
             Directory.CreateDirectory(Path);
         }
         if (!System.IO.File.Exists(File))
         {
             using (StreamWriter file = System.IO.File.CreateText(File))
             {
                 JsonSerializer serializer = new JsonSerializer
                 {
                     Formatting = Formatting.Indented
                 };
                 serializer.Serialize(file, this);
             }
         }
         else
         {
             using (StreamReader reader = new StreamReader(File))
             {
                 JsonSerializer serializer = new JsonSerializer
                 {
                     Formatting = Formatting.Indented
                 };
                 ProgramData Data = (ProgramData)serializer.Deserialize(reader, typeof(ProgramData));
                 Priority = Data.Priority;
                 Enabled  = Data.Enabled;
             }
         }
     }
 }
コード例 #9
0
ファイル: NetBehavior.cs プロジェクト: Tclauncher/Tranx
 /// <summary>
 /// 服务端或客户端接收到的消息,存入msgIN
 /// </summary>
 static void ChaterIN(ProgramData prog, System.Net.Sockets.Socket chat, bool isserver)
 {
     try{
         byte[] buffer = new byte[1024 * 1024];
         int    n      = 1;
         while (true)
         {
             try{
                 n = chat.Receive(buffer);
             }catch (Exception) {
                 if (!isserver)
                 {
                     prog.msgSHOW.Enqueue("[WARNING]:Server Disconnected");
                 }
                 return;
             }
             string str = Encoding.UTF8.GetString(buffer, 0, n);
             if (str != String.Empty && str != "heart")
             {
                 prog.msgIN.Enqueue(str);
             }
         }
     }catch (Exception e) { ExceptionClass.ExceptReporter(e); }
 }
コード例 #10
0
        public void TestProgramCreateRetryAsyncAndFailed()
        {
            var expected = new ProgramData { Name = "testData" };
            var fakeException = new WebException("test", WebExceptionStatus.Timeout);
            var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 100, expected);

            dataContextMock.Setup((ctxt) => ctxt.AddObject("Channels", It.IsAny<object>()));

            _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object);

            IChannel channel = new ChannelData();
            ProgramBaseCollection programs = new ProgramBaseCollection(_mediaContext, channel);

            try
            {
                var actual = programs.CreateAsync(expected.Name, TimeSpan.FromHours(1), Guid.NewGuid().ToString()).Result;

            }
            catch (AggregateException)
            {
                dataContextMock.Verify((ctxt) => ctxt.SaveChangesAsync(It.IsAny<object>()), Times.AtLeast(2));
                throw;
            }
        }
コード例 #11
0
        static void InitializePrograms()
        {
            g_litShaderProg = LoadStandardProgram(VertexShaders.BasicTexture_PN, FragmentShaders.ShaderGaussian);
            g_litTextureProg = LoadStandardProgram(VertexShaders.BasicTexture_PN, FragmentShaders.TextureGaussian);

            g_Unlit = LoadUnlitProgram(VertexShaders.PosTransform, FragmentShaders.ColorUniform_frag);
        }
コード例 #12
0
 public void error(string message)
 {
     ProgramData.Log("Plugin: " + name, message, ProgramData.LOG_STYLE_ERROR);
 }
コード例 #13
0
 public void success(string message)
 {
     ProgramData.Log("Plugin: " + name, message, ProgramData.LOG_STYLE_SUCCESS);
 }
コード例 #14
0
        ProgramData LoadLitProgram(string vertexShader, string fragmentShader)
        {
            ProgramData data = new ProgramData();
            int vertexShaderInt = Shader.compileShader(ShaderType.VertexShader, vertexShader);
            int fragmentShaderInt = Shader.compileShader(ShaderType.FragmentShader, fragmentShader);

            data.theProgram = Shader.createAndLinkProgram(vertexShaderInt, fragmentShaderInt);
            data.modelToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "modelToCameraMatrix");
            data.modelSpaceLightPosUnif = GL.GetUniformLocation(data.theProgram, "modelSpaceLightPos");
            data.lightIntensityUnif = GL.GetUniformLocation(data.theProgram, "lightIntensity");
            data.ambientIntensityUnif = GL.GetUniformLocation(data.theProgram, "ambientIntensity");

            data.cameraToClipMatrixUnif = GL.GetUniformLocation(data.theProgram, "cameraToClipMatrix");
            return data;
        }
コード例 #15
0
 void InitializePrograms()
 {
     g_program = LoadProgram(VertexShaders.PT, FragmentShaders.Tex);
 }
コード例 #16
0
        public void GenerateWorld()
        {
#if !DEBUG
            try
#endif
            {
                CurrentState = GenerationState.Generating;

                LoadingMessage = "Init..";
                OverworldMap.heightNoise.Seed = Overworld.Seed;
                Overworld.Map.Map             = new OverworldCell[Overworld.Width, Overworld.Height];

                Progress = 0.01f;

                LoadingMessage           = "Height Map ...";
                float[,] heightMapLookup = null;
                heightMapLookup          = OverworldMap.GenerateHeightMapLookup(Overworld.Width, Overworld.Height);
                Overworld.Map.CreateHeightFromLookup(heightMapLookup);

                Progress = 0.05f;

                int numRains       = (int)Overworld.GenerationSettings.NumRains;
                int rainLength     = 250;
                int numRainSamples = 3;

                for (int x = 0; x < Overworld.Width; x++)
                {
                    for (int y = 0; y < Overworld.Height; y++)
                    {
                        Overworld.Map.Map[x, y].Erosion    = 1.0f;
                        Overworld.Map.Map[x, y].Weathering = 0;
                        Overworld.Map.Map[x, y].Faults     = 1.0f;
                    }
                }

                LoadingMessage = "Climate";
                for (int x = 0; x < Overworld.Width; x++)
                {
                    for (int y = 0; y < Overworld.Height; y++)
                    {
                        Overworld.Map.Map[x, y].Temperature = ((float)(y) / (float)(Overworld.Height)) * Overworld.GenerationSettings.TemperatureScale;
                    }
                }

                OverworldImageOperations.Distort(Overworld.Map.Map, Overworld.Width, Overworld.Height, 30.0f, 0.005f, OverworldField.Temperature);
                for (int x = 0; x < Overworld.Width; x++)
                {
                    for (int y = 0; y < Overworld.Height; y++)
                    {
                        Overworld.Map.Map[x, y].Temperature = Math.Max(Math.Min(Overworld.Map.Map[x, y].Temperature, 1.0f), 0.0f);
                    }
                }

                int numVoronoiPoints = (int)Overworld.GenerationSettings.NumFaults;

                Progress       = 0.1f;
                LoadingMessage = "Faults ...";

                Voronoi(Overworld.Width, Overworld.Height, numVoronoiPoints);
                Overworld.Map.CreateHeightFromLookupWithErosion(heightMapLookup);

                Progress = 0.2f;

                Overworld.Map.CreateHeightFromLookupWithErosion(heightMapLookup);

                Progress = 0.25f;

                LoadingMessage = "Erosion...";
                var buffer = new float[Overworld.Width, Overworld.Height];
                Erode(Overworld.Width, Overworld.Height, Overworld.GenerationSettings.SeaLevel, Overworld.Map.Map, numRains, rainLength, numRainSamples, buffer);
                Overworld.Map.CreateHeightFromLookupWithErosion(heightMapLookup);

                Progress = 0.9f;

                LoadingMessage = "Blur.";
                OverworldImageOperations.Blur(Overworld.Map.Map, Overworld.Width, Overworld.Height, OverworldField.Erosion);

                LoadingMessage = "Generate height.";
                Overworld.Map.CreateHeightFromLookupWithErosion(heightMapLookup);

                LoadingMessage = "Rain";
                CalculateRain(Overworld.Width, Overworld.Height);

                LoadingMessage = "Biome";
                for (int x = 0; x < Overworld.Width; x++)
                {
                    for (int y = 0; y < Overworld.Height; y++)
                    {
                        Overworld.Map.Map[x, y].Biome = Library.GetBiomeForConditions(Overworld.Map.Map[x, y].Temperature, Overworld.Map.Map[x, y].Rainfall, Overworld.Map.Map[x, y].Height).Biome;
                    }
                }

                LoadingMessage = "Volcanoes";
                GenerateVolcanoes(Overworld.Width, Overworld.Height);

                LoadingMessage = "Factions";
                FactionSet library = new FactionSet();
                library.Initialize(null, new CompanyInformation());

                Overworld.Natives = new List <OverworldFaction>();
                foreach (var fact in library.Factions)
                {
                    Overworld.Natives.Add(fact.Value.ParentFaction); // Todo: Don't create a whole faction just to grab the overworldfactions from them.
                }
                for (int i = 0; i < Overworld.GenerationSettings.NumCivilizations; i++)
                {
                    Overworld.Natives.Add(library.GenerateOverworldFaction(Overworld, i, Overworld.GenerationSettings.NumCivilizations));
                }
                Politics.Initialize(Overworld);

                Overworld.ColonyCells      = new CellSet("World\\colonies");
                Overworld.InstanceSettings = new InstanceSettings(Overworld.ColonyCells.GetCellAt(16, 0));

                SeedCivs();
                GrowCivs();

                for (int x = 0; x < Overworld.Width; x++)
                {
                    Overworld.Map.Map[x, 0] = Overworld.Map.Map[x, 1];
                    Overworld.Map.Map[x, Overworld.Height - 1] = Overworld.Map.Map[x, Overworld.Height - 2];
                }

                for (int y = 0; y < Overworld.Height; y++)
                {
                    Overworld.Map.Map[0, y] = Overworld.Map.Map[1, y];
                    Overworld.Map.Map[Overworld.Width - 1, y] = Overworld.Map.Map[Overworld.Width - 2, y];
                }

                CurrentState   = GenerationState.Finished;
                LoadingMessage = "";
                Progress       = 1.0f;
            }
#if !DEBUG
            catch (Exception exception)
            {
                ProgramData.WriteExceptionLog(exception);
                throw;
            }
#endif
        }
コード例 #17
0
ファイル: EquippedEvent.cs プロジェクト: Dessyreqt/RogueArena
 protected override void Handle(ProgramData data)
 {
     data.GameData.MessageLog.AddMessage($"You equipped the {_equippedEntity.Name}.");
 }
コード例 #18
0
 static void InitializePrograms()
 {
     simpleTextureProgram = LoadProgram(VertexShaders.SimpleTexture, FragmentShaders.SimpleTexture);
 }
コード例 #19
0
 protected override void Handle(ProgramData data)
 {
     data.GameData.Player.Get <EquipmentComponent>().ToggleEquip(_equippableEntity, data);
     data.GameData.GameState = GameState.EnemyTurn;
 }
コード例 #20
0
        private static void SetGlobalMatrices(ProgramData program)
        {
            Shape.worldToCamera = worldToCameraMatrix;
            Shape.cameraToClip = cameraToClipMatrix;

            //GL.UseProgram(program.theProgram);
            //GL.UniformMatrix4(program.cameraToClipMatrixUnif, false, ref cameraToClipMatrix);  // this one is first
            //GL.UniformMatrix4(program.worldToCameraMatrixUnif, false, ref worldToCameraMatrix); // this is the second one
            //GL.UseProgram(0);
        }
コード例 #21
0
        void InitializeProgram()
        {
            UniformColor = LoadProgram(VertexShaders.PosOnlyWorldTransform_vert, FragmentShaders.ColorUniform_frag);
            GL.UseProgram(UniformColor.theProgram);
            GL.Uniform4(UniformColor.baseColorUnif, 0.694f, 0.4f, 0.106f, 1.0f);
            GL.UseProgram(0);

            UniformColorTint = LoadProgram(VertexShaders.PosColorWorldTransform_vert, FragmentShaders.ColorMultUniform_frag);
            GL.UseProgram(UniformColorTint.theProgram);
            GL.Uniform4(UniformColorTint.baseColorUnif, 0.5f, 0.5f, 0f, 1.0f);
            GL.UseProgram(0);

            g_WhiteAmbDiffuseColor = LoadProgram(VertexShaders.DirAmbVertexLighting_PN_vert,
                                                 FragmentShaders.ColorPassthrough_frag);

            g_VertexDiffuseColor = LoadProgram(VertexShaders.DirVertexLighting_PCN,
                                               FragmentShaders.ColorPassthrough_frag);

            g_Unlit = LoadProgram(VertexShaders.unlit, FragmentShaders.unlit);

            g_litShaderProg = LoadProgram(VertexShaders.BasicTexture_PN, FragmentShaders.ShaderGaussian);

            GL.UseProgram(g_VertexDiffuseColor.theProgram);
            Vector4 lightIntensity = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
            GL.Uniform3(g_VertexDiffuseColor.dirToLightUnif, ref dirToLight);
            GL.Uniform4(g_VertexDiffuseColor.lightIntensityUnif, ref lightIntensity);
            GL.UseProgram(0);

            GL.UseProgram(g_WhiteAmbDiffuseColor.theProgram);
            Vector3 light_direction = new Vector3(10f, 10f, 0f);
            Vector4 light_intensity = new Vector4(0.5f, 0.5f, 0.5f, 0.5f);
            Vector4  ambient_intensity = new Vector4(0.3f, 0.0f, 0.3f, 0.6f);
            GL.Uniform3(g_WhiteAmbDiffuseColor.dirToLightUnif, ref light_direction);
            GL.Uniform4(g_WhiteAmbDiffuseColor.lightIntensityUnif, ref light_intensity);
            GL.Uniform4(g_WhiteAmbDiffuseColor.ambientIntensityUnif, ref ambient_intensity);
            Matrix3 m = Matrix3.Identity;
            GL.UniformMatrix3(g_WhiteAmbDiffuseColor.normalModelToCameraMatrixUnif, false, ref m);
            GL.UseProgram(0);

            GL.UseProgram(g_Unlit.theProgram);
            GL.Uniform4(g_Unlit.baseColorUnif, 0.5f, 0.5f, 0f, 1.0f);
            Matrix4 test = Matrix4.Identity;
            GL.UniformMatrix4(g_Unlit.cameraToClipMatrixUnif, false, ref test);
            GL.UseProgram(0);

            // Test shader lights and materials
            GL.UseProgram(g_litShaderProg.theProgram);
            g_litShaderProg.lightBlock = new LightBlock(NUMBER_OF_LIGHTS);
            g_litShaderProg.lightBlock.SetUniforms(g_litShaderProg.theProgram);

            g_litShaderProg.lightBlock.ambientIntensity = new Vector4(0.1f, 0.1f, 0.1f, 1.0f);

            g_litShaderProg.lightBlock.lights[0].cameraSpaceLightPos = new Vector4(4.0f, 0.0f, 1.0f, 1.0f);
            g_litShaderProg.lightBlock.lights[0].lightIntensity = new Vector4(0.7f, 0.0f, 0.0f, 1.0f);

            g_litShaderProg.lightBlock.lights[1].cameraSpaceLightPos = new Vector4(4.0f, 0.0f, 1.0f, 1.0f);
            g_litShaderProg.lightBlock.lights[1].lightIntensity = new Vector4(0.0f, 0.0f, 0.7f, 1.0f);

            g_litShaderProg.lightBlock.UpdateInternal();

            g_litShaderProg.materialBlock = new MaterialBlock(new Vector4(0.0f, 0.3f, 0.0f, 1.0f),
                new Vector4(0.5f, 0.0f, 0.5f, 1.0f), 0.6f);
            g_litShaderProg.materialBlock.SetUniforms(g_litShaderProg.theProgram);
            g_litShaderProg.materialBlock.UpdateInternal();

            GL.UseProgram(0);

            ObjectColor = LoadProgram(VertexShaders.PosColorWorldTransform_vert, FragmentShaders.ColorPassthrough_frag);
            currentProgram = ObjectColor;
        }
コード例 #22
0
        public override String keyboard(Keys keyCode, int x, int y)
        {
            StringBuilder result = new StringBuilder();
            result.AppendLine(keyCode.ToString());
            switch (keyCode) {
            case Keys.NumPad6:
                Camera.MoveTarget(0.5f, 0f, 0.0f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad4:
                Camera.MoveTarget(-0.5f, 0f, 0.0f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad8:
                Camera.MoveTarget(0.0f, 0.5f, 0.0f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad2:
                Camera.MoveTarget(0f, -0.5f, 0.0f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad7:
                Camera.MoveTarget(0.0f, 0.0f, 0.5f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad3:
                Camera.MoveTarget(0f, 0.0f, -0.5f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.D1:
                axis = Vector3.UnitX;
                angle = angle + 1;
                break;
            case Keys.D2:
                axis = Vector3.UnitY;
                angle = angle + 1;
                break;
            case Keys.D3:
                axis = Vector3.UnitZ;
                angle = angle + 1;
                break;
            case Keys.D4:
                break;
            case Keys.D5:
                break;
            case Keys.D6:
                break;
            case Keys.C:
                if (cull)
                {
                    cull = false;
                    GL.Disable(EnableCap.CullFace);
                    result.AppendLine("cull disabled");
                }
                else
                {
                    cull = true;
                    GL.Enable(EnableCap.CullFace);
                    result.AppendLine("cull enabled");
                }
                break;
            case Keys.R:
                if (rotateWorld)
                {
                    rotateWorld = false;
                    result.AppendLine("rotateWorld disabled");
                }
                else
                {
                    rotateWorld = true;
                    result.AppendLine("rotateWorld enabled");
                }
                break;
            case Keys.Escape:
                //timer.Enabled = false;
                break;
            case Keys.Space:
                newPerspectiveAngle = perspectiveAngle + 5f;
                if (newPerspectiveAngle > 120f)
                {
                    newPerspectiveAngle = 30f;
                }
                break;
            case Keys.Z:
                break;
            case Keys.X:
                noWorldMatrix = true;
                currentProgram = g_Unlit;
                reshape();
                break;
            case Keys.Y:
                noWorldMatrix = true;
                currentProgram = g_litShaderProg;
                reshape();
                break;
            case Keys.Q:
                result.AppendLine("currentProgram = " + currentProgram.ToString());
                break;
            case Keys.P:
                if (pause)
                {
                    pause = false;
                }
                else
                {
                    pause = true;
                }
                break;
            case Keys.V:
                playerNumber++;
                if (playerNumber > lastPlayer)
                {
                    playerNumber = 0;
                }
                ChangePlayerView();
                result.AppendLine("Player number = " + playerNumber.ToString());
                break;
            case Keys.I:
                result.AppendLine("cameraToClipMatrix " + cameraToClipMatrix.ToString());
                result.AppendLine(AnalysisTools.CalculateMatrixEffects(cameraToClipMatrix));
                result.AppendLine("worldToCameraMatrix " + worldToCameraMatrix.ToString());
                result.AppendLine(AnalysisTools.CalculateMatrixEffects(worldToCameraMatrix));

                Matrix4 cameraToClipMatrixTimesWorldToCameraMatrix =
                    Matrix4.Mult(cameraToClipMatrix, worldToCameraMatrix);
                result.AppendLine("cameraToClipMatrixTimesWorldToCameraMatrix " +
                    cameraToClipMatrixTimesWorldToCameraMatrix.ToString());
                result.AppendLine(AnalysisTools.CalculateMatrixEffects(cameraToClipMatrixTimesWorldToCameraMatrix));

                Matrix4 worldToCameraMatrixTimesCameraToClipMatrix =
                    Matrix4.Mult(worldToCameraMatrix, cameraToClipMatrix);
                result.AppendLine("worldToCameraMatrixTimesCameraToClipMatrix " +
                    worldToCameraMatrixTimesCameraToClipMatrix.ToString());
                result.AppendLine(AnalysisTools.CalculateMatrixEffects(worldToCameraMatrixTimesCameraToClipMatrix));
                break;
            case Keys.S:
                ball.SetSocketControl();
                result.AppendLine("Socket Control");
                break;
            case Keys.E:
                ball.SetElasticControl();
                result.AppendLine("Socket Control");
                break;
            case Keys.W:
                if (drawWalls)
                    drawWalls = false;
                else
                    drawWalls = true;
                break;
            }
            return result.ToString();
        }
コード例 #23
0
ファイル: AiComponent.cs プロジェクト: Dessyreqt/RogueArena
 public abstract void TakeTurn(Entity target, ProgramData data);
コード例 #24
0
        void InitializeProgram()
        {
            UniformColor = LoadProgram(VertexShaders.PosOnlyWorldTransform_vert, FragmentShaders.ColorUniform_frag);
            GL.UseProgram(UniformColor.theProgram);
            GL.Uniform4(UniformColor.baseColorUnif, 0.694f, 0.4f, 0.106f, 1.0f);
            GL.UseProgram(0);

            UniformColorTint = LoadProgram(VertexShaders.PosColorWorldTransform_vert, FragmentShaders.ColorMultUniform_frag);
            GL.UseProgram(UniformColorTint.theProgram);
            GL.Uniform4(UniformColorTint.baseColorUnif, 0.5f, 0.5f, 0f, 1.0f);
            GL.UseProgram(0);

            g_WhiteDiffuseColor = LoadProgram(VertexShaders.PosColorLocalTransform_vert,
                                              FragmentShaders.ColorPassthrough_frag);

            g_WhiteAmbDiffuseColor = LoadProgram(VertexShaders.DirAmbVertexLighting_PN_vert,
                                                 FragmentShaders.ColorPassthrough_frag);

            g_VertexDiffuseColor = LoadProgram(VertexShaders.DirVertexLighting_PCN,
                                               FragmentShaders.ColorPassthrough_frag);
            GL.UseProgram(g_VertexDiffuseColor.theProgram);
            Vector4 lightIntensity = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
            GL.Uniform3(g_VertexDiffuseColor.dirToLightUnif, ref dirToLight);
            GL.Uniform4(g_VertexDiffuseColor.lightIntensityUnif, ref lightIntensity);
            GL.UseProgram(0);

            GL.UseProgram(g_WhiteAmbDiffuseColor.theProgram);
            Vector3 light_direction = new Vector3(10f, 10f, 0f);
            Vector4 light_intensity = new Vector4(0.5f, 0.5f, 0.5f, 0.5f);
            Vector4  ambient_intensity = new Vector4(0.3f, 0.0f, 0.3f, 0.6f);
            GL.Uniform3(g_WhiteAmbDiffuseColor.dirToLightUnif, ref light_direction);
            GL.Uniform4(g_WhiteAmbDiffuseColor.lightIntensityUnif, ref light_intensity);
            GL.Uniform4(g_WhiteAmbDiffuseColor.ambientIntensityUnif, ref ambient_intensity);
            Matrix3 m = Matrix3.Identity;
            GL.UniformMatrix3(g_WhiteAmbDiffuseColor.normalModelToCameraMatrixUnif, false, ref m);
            GL.UseProgram(0);

            ObjectColor = LoadProgram(VertexShaders.PosColorWorldTransform_vert, FragmentShaders.ColorPassthrough_frag);
            currentProgram = ObjectColor;
        }
コード例 #25
0
        static ProgramData LoadProgram(String strVertexShader, String strFragmentShader)
        {
            ProgramData data = new ProgramData();
            int vertex_shader = Shader.compileShader(ShaderType.VertexShader, strVertexShader);
            int fragment_shader = Shader.compileShader(ShaderType.FragmentShader, strFragmentShader);
            data.theProgram  = Shader.createAndLinkProgram(vertex_shader, fragment_shader);

            data.position =  GL.GetAttribLocation(data.theProgram, "position");
            data.texCoord =  GL.GetAttribLocation(data.theProgram, "texCoord");

            int colorTextureUnif = GL.GetUniformLocation(data.theProgram, "diffuseColorTex");
            GL.UseProgram(data.theProgram);
            GL.Uniform1(colorTextureUnif, g_colorTexUnit);
            GL.UseProgram(0);

            return data;
        }
コード例 #26
0
        /// <summary>
        /// Checks and adjusts the start and end times for a program.
        /// </summary>
        /// <param name="guideData">The guide data.</param>
        /// <returns>true if successfull otherwise false</returns>
        public bool CheckAdjustTime(ref ProgramData guideData)
        {
            WorldDateTime guideStartTime = guideData.StartTime;
            WorldDateTime guideEndTime   = guideData.EndTime;

            _addDays = 1;

            // Check if the start time day value is set
            if (guideStartTime.Day == 0)
            {
                guideStartTime.Day = _startTime.Day; // Set program day to start day
            }
            else
            {
                // program has day value
                if (guideStartTime.Day != _startTime.Day && _expectedTime != Expect.Start)
                {
                    // day value not the same as start time -> increase start time one day
                    _grabDay++;
                    _startTime    = _startTime.AddDays(1);
                    _nextDay      = false;
                    _lastTime     = 0;
                    _expectedTime = Expect.BeforeMidday;
                }
            }

            // Check and set month and year
            if (guideStartTime.Year == 0)
            {
                guideStartTime.Year = _startTime.Year;
            }
            if (guideStartTime.Month == 0)
            {
                guideStartTime.Month = _startTime.Month;
            }


            // State loop Start, BeforeMidday and AfterMidday
            switch (_expectedTime)
            {
            // Start of a new day - need to work out if the listings start in the morning or afternoon
            case Expect.Start:
                if (OnPreviousDay(guideStartTime.Hour))
                {
                    return(false); // Guide starts on previous day ignore these listings.
                }

                if (_newDay)
                {
                    _newDay = false;
                    //if (guideStartTime.Hour < _startTime.Hour)
                    //  return false;

                    if (guideStartTime.Hour <= 12)
                    {
                        _expectedTime = Expect.BeforeMidday;
                        goto case Expect.BeforeMidday;
                    }

                    _expectedTime = Expect.AfterMidday;
                    goto case Expect.AfterMidday;
                }

                _expectedTime = Expect.BeforeMidday;
                goto case Expect.BeforeMidday; // Pass into BeforeMidday Code

            // Before Midday
            case Expect.BeforeMidday:
                if (_lastTime > guideStartTime.Hour)
                {
                    // last time was before midday, new time is less -> site doesn't have 24 hours or AM/PM
                    _expectedTime = Expect.AfterMidday;
                }
                else
                {
                    if (guideStartTime.Hour <= 12)
                    {
                        break; // Time is before midday -> Do nothing
                    }
                }

                // Pass into AfterMidday Code
                goto case Expect.AfterMidday;

            // After midday
            case Expect.AfterMidday:
                bool adjusted = false;
                if (guideStartTime.Hour < 12)  // Site doesn't have correct time
                {
                    guideStartTime.Hour += 12; // starts again at 1:00 without "pm"
                    adjusted             = true;
                }

                if (_lastTime > guideStartTime.Hour)
                {
                    if (_nextDay)
                    {
                        _addDays++;
                        _grabDay++;
                        _startTime = _startTime.AddDays(1);
                    }
                    else
                    {
                        _nextDay = true;
                    }

                    if (adjusted)
                    {
                        guideStartTime.Hour -= 12;
                    }

                    if (guideStartTime.Hour < 12)
                    {
                        _expectedTime = Expect.BeforeMidday;
                    }
                }

                break;

            default:
                break;
            }

            // store current hour as last hour
            _lastTime = guideStartTime.Hour;

            // Check if orogram has an end time
            if (guideEndTime != null)
            {
                // set Day, Month and Year is not set
                if (guideEndTime.Year == 0)
                {
                    guideEndTime.Year = guideStartTime.Year;
                }
                if (guideEndTime.Month == 0)
                {
                    guideEndTime.Month = guideStartTime.Month;
                }
                if (guideEndTime.Day == 0)
                {
                    guideEndTime.Day = guideStartTime.Day;
                }

                // correct date if required
                if (_nextDay)
                {
                    if (guideStartTime.Hour > guideEndTime.Hour)
                    {
                        // start before midnight end after
                        guideEndTime = guideEndTime.AddDays(_addDays + 1);
                    }
                    else
                    {
                        guideEndTime = guideEndTime.AddDays(_addDays);
                    }
                }
                else
                {
                    if (guideStartTime.Hour > guideEndTime.Hour)
                    {
                        guideEndTime = guideEndTime.AddDays(_addDays);
                    }
                }
            }

            // if next day -> correct start date
            if (_nextDay)
            {
                guideStartTime = guideStartTime.AddDays(_addDays);
            }

            //Log.Debug("WebEPG: Guide, Program Debug: [{0} {1}]", _GrabDay, _bNextDay);

            guideData.StartTime = guideStartTime;
            guideData.EndTime   = guideEndTime;

            return(true);
        }
コード例 #27
0
        //Called whenever a key on the keyboard was pressed.
        //The key is given by the ''key'' parameter, which is in ASCII.
        //It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to
        //exit the program.
        public override String keyboard(Keys keyCode, int x, int y)
        {
            StringBuilder result = new StringBuilder();
            switch (keyCode) {

                case Keys.D1:
                    currentProgram = ObjectColor;
                    noWorldMatrix = false;
                    break;
                case Keys.D2:
                    currentProgram = UniformColor;
                    noWorldMatrix = false;
                    break;
                case Keys.D3:
                    currentProgram = UniformColorTint;
                    noWorldMatrix = false;
                    break;
                case Keys.D4:
                    currentProgram = g_WhiteDiffuseColor;
                    noWorldMatrix = true;
                    break;
                case Keys.D5:
                    currentProgram = g_WhiteAmbDiffuseColor;
                    noWorldMatrix = true;
                    break;
                case Keys.D6:
                    currentProgram = g_VertexDiffuseColor;
                    noWorldMatrix = true;
                    break;

                case Keys.A:
                    current_mesh = g_pCylinderMesh;
                    break;
                case Keys.B:
                    current_mesh = g_pCubeColorMesh;
                    break;
                case Keys.C:
                    current_mesh = g_pPlaneMesh;
                    break;
                case Keys.D:
                    current_mesh = g_pInfinityMesh;
                    break;

                case Keys.I:
                    result.AppendLine("I Decrease g_camTarget.X");
                    Camera.MoveTarget(-4.0f, 0, 0);
                    break;
                case Keys.M:
                    result.AppendLine("M Increase g_camTarget.X");
                    Camera.MoveTarget(4.0f, 0, 0);
                    break;
                case Keys.J:
                    result.AppendLine("J Increase g_camTarget.Z");
                    Camera.MoveTarget(0, 0, 4.0f);
                    break;
                case Keys.K:
                    result.AppendLine("K Decrease g_camTarget.Z");
                    Camera.MoveTarget(0, 0, -4.0f);
                    break;
                case Keys.Escape:
                    //timer.Enabled = false;
                    break;
                case Keys.Space:
                    break;
            }
            result.AppendLine(keyCode.ToString());
            result.AppendLine("currentProgram = " + currentProgram.ToString());

            reshape();
            display();
            return result.ToString();
        }
コード例 #28
0
 void InitializeProgram()
 {
     UniformColor = LoadProgram(VertexShaders.PosOnlyWorldTransform_vert, FragmentShaders.ColorUniform_frag);
     ObjectColor = LoadProgram(VertexShaders.PosColorWorldTransform_vert, FragmentShaders.ColorPassthrough_frag);
     UniformColorTint = LoadProgram(VertexShaders.PosColorWorldTransform_vert, FragmentShaders.ColorMultUniform_frag);
 }
        public IActionResult Searchuniv()
        {
            var schoolDataList = new List <SchoolData>();

            if (!dbContext.Schools.Any())
            {
                httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Accept.Clear();
                httpClient.DefaultRequestHeaders.Add("X-Api-Key", API_KEY);
                httpClient.DefaultRequestHeaders.Accept.Add(
                    new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                string SCHOOL_DATA_API_PATH = BASE_URL + "schools?fields=id,ope6_id,school.name,school.city,school.state,school.zip";

                string schooldata = "";



                Schools schools = null;

                httpClient.BaseAddress = new Uri(SCHOOL_DATA_API_PATH);

                try
                {
                    HttpResponseMessage response = httpClient.GetAsync(SCHOOL_DATA_API_PATH).GetAwaiter().GetResult();

                    if (response.IsSuccessStatusCode)
                    {
                        schooldata = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                        schooldata = replaceString(schooldata);
                    }

                    if (!schooldata.Equals(""))
                    {
                        schools = JsonConvert.DeserializeObject <Schools>(schooldata);
                        schools.results.ToList().ForEach(s =>
                        {
                            var school = new SchoolData()
                            {
                                //id = s.id,
                                ope6_id = s.ope6_id,


                                schoolcity  = s.schoolcity,
                                schoolname  = s.schoolname,
                                schoolstate = s.schoolstate,
                                schoolzip   = s.schoolzip
                            };

                            dbContext.Schools.Add(school);
                        });
                        dbContext.SaveChanges();
                    }
                    schoolDataList = dbContext.Schools.ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            else
            {
                schoolDataList = dbContext.Schools.ToList();
            }
            ViewBag.Schools    = schoolDataList;
            schoolsInformation = schoolDataList;
            if (!dbContext.Programs.Any())
            {
                dbContext.Database.EnsureCreated();
                ProgramData[] plist = new ProgramData[]
                {
                    new ProgramData {
                        code = "1", title = "Management Sciences and Quantitative Methods", ope6_id = "001002", unit_id = 1
                    },
                    new ProgramData {
                        code = "2", title = "Journalism", ope6_id = "001002", unit_id = 2
                    },
                    new ProgramData {
                        code = "3", title = "Entrepreneurial and Small Business Operations", ope6_id = "001002", unit_id = 3
                    },
                    new ProgramData {
                        code = "4", title = "Public Relations, Advertising, and Applied Communication", ope6_id = "001003", unit_id = 4
                    },
                    new ProgramData {
                        code = "5", title = "Geological and Earth Sciences/Geosciences", ope6_id = "001003", unit_id = 5
                    },
                    new ProgramData {
                        code = "6", title = "International Business", ope6_id = "001003", unit_id = 6
                    },
                    new ProgramData {
                        code = "7", title = "Communication and Media Studies", ope6_id = "041872", unit_id = 7
                    },
                    new ProgramData {
                        code = "8", title = "Computer/Information Technology Administration and Management", ope6_id = "041872", unit_id = 8
                    },
                    new ProgramData {
                        code = "9", title = "Food Science and Technology", ope6_id = "041872", unit_id = 9
                    },
                    new ProgramData {
                        code = "10", title = "Parks, Recreation and Leisure Facilities Management", ope6_id = "001017", unit_id = 10
                    },
                    new ProgramData {
                        code = "11", title = "Family and Consumer Sciences/Human Sciences, General", ope6_id = "001017", unit_id = 11
                    },
                    new ProgramData {
                        code = "12", title = "Business, Management, Marketing, and Related Support Services, Other", ope6_id = "001017", unit_id = 12
                    },
                    new ProgramData {
                        code = "13", title = "Computer Systems Networking and Telecommunicationss", ope6_id = "001060", unit_id = 13
                    },
                    new ProgramData {
                        code = "14", title = "Computer Software and Media Applications", ope6_id = "001060", unit_id = 14
                    },
                    new ProgramData {
                        code = "15", title = "Vehicle Maintenance and Repair Technologies", ope6_id = "001060", unit_id = 15
                    },
                    new ProgramData {
                        code = "16", title = "Management Sciences and Quantitative Methods", ope6_id = "001015", unit_id = 16
                    },
                    new ProgramData {
                        code = "17", title = "Journalism", ope6_id = "001015", unit_id = 17
                    },
                    new ProgramData {
                        code = "18", title = "Entrepreneurial and Small Business Operations", ope6_id = "001015", unit_id = 18
                    },
                    new ProgramData {
                        code = "19", title = "Public Relations, Advertising, and Applied Communication", ope6_id = "013039", unit_id = 19
                    },
                    new ProgramData {
                        code = "20", title = "Geological and Earth Sciences/Geosciences", ope6_id = "013039", unit_id = 20
                    },
                    new ProgramData {
                        code = "21", title = "International Business", ope6_id = "013039", unit_id = 21
                    },
                    new ProgramData {
                        code = "22", title = "Communication and Media Studies", ope6_id = "012182", unit_id = 22
                    },
                    new ProgramData {
                        code = "23", title = "Computer/Information Technology Administration and Management", ope6_id = "012182", unit_id = 23
                    },
                    new ProgramData {
                        code = "24", title = "Food Science and Technology", ope6_id = "012182", unit_id = 24
                    },
                    new ProgramData {
                        code = "25", title = "Parks, Recreation and Leisure Facilities Management", ope6_id = "001012", unit_id = 25
                    },
                    new ProgramData {
                        code = "26", title = "Family and Consumer Sciences/Human Sciences, General", ope6_id = "001012", unit_id = 26
                    },
                    new ProgramData {
                        code = "27", title = "Business, Management, Marketing, and Related Support Services, Other", ope6_id = "001012", unit_id = 27
                    },
                    new ProgramData {
                        code = "28", title = "Computer Systems Networking and Telecommunicationss", ope6_id = "001009", unit_id = 28
                    },
                    new ProgramData {
                        code = "29", title = "Computer Software and Media Applications", ope6_id = "001009", unit_id = 29
                    },
                    new ProgramData {
                        code = "30", title = "Vehicle Maintenance and Repair Technologies", ope6_id = "001009", unit_id = 30
                    },
                    new ProgramData {
                        code = "31", title = "Management Sciences and Quantitative Methods", ope6_id = "008310", unit_id = 31
                    },
                    new ProgramData {
                        code = "32", title = "Journalism", ope6_id = "008310", unit_id = 32
                    },
                    new ProgramData {
                        code = "33", title = "Entrepreneurial and Small Business Operations", ope6_id = "008310", unit_id = 33
                    },
                    new ProgramData {
                        code = "34", title = "Public Relations, Advertising, and Applied Communication", ope6_id = "001008", unit_id = 34
                    },
                    new ProgramData {
                        code = "35", title = "Geological and Earth Sciences/Geosciences", ope6_id = "001008", unit_id = 35
                    },
                    new ProgramData {
                        code = "36", title = "International Business", ope6_id = "001008", unit_id = 36
                    },
                    new ProgramData {
                        code = "37", title = "Communication and Media Studies", ope6_id = "001007", unit_id = 37
                    },
                    new ProgramData {
                        code = "38", title = "Computer/Information Technology Administration and Management", ope6_id = "001007", unit_id = 38
                    },
                    new ProgramData {
                        code = "39", title = "Food Science and Technology", ope6_id = "001007", unit_id = 39
                    },
                    new ProgramData {
                        code = "40", title = "Parks, Recreation and Leisure Facilities Management", ope6_id = "001051", unit_id = 40
                    },
                    new ProgramData {
                        code = "41", title = "Family and Consumer Sciences/Human Sciences, General", ope6_id = "001051", unit_id = 41
                    },
                    new ProgramData {
                        code = "42", title = "Business, Management, Marketing, and Related Support Services, Other", ope6_id = "001051", unit_id = 42
                    },
                    new ProgramData {
                        code = "43", title = "Computer Systems Networking and Telecommunicationss", ope6_id = "001005", unit_id = 43
                    },
                    new ProgramData {
                        code = "44", title = "Computer Software and Media Applications", ope6_id = "001005", unit_id = 44
                    },
                    new ProgramData {
                        code = "45", title = "Vehicle Maintenance and Repair Technologies", ope6_id = "001005", unit_id = 45
                    },
                    new ProgramData {
                        code = "46", title = "Management Sciences and Quantitative Methods", ope6_id = "001055", unit_id = 46
                    },
                    new ProgramData {
                        code = "47", title = "Journalism", ope6_id = "001055", unit_id = 47
                    },
                    new ProgramData {
                        code = "48", title = "Entrepreneurial and Small Business Operations", ope6_id = "001055", unit_id = 48
                    },
                    new ProgramData {
                        code = "49", title = "Public Relations, Advertising, and Applied Communication", ope6_id = "025034", unit_id = 49
                    },
                    new ProgramData {
                        code = "50", title = "Geological and Earth Sciences/Geosciences", ope6_id = "025034", unit_id = 50
                    },
                    new ProgramData {
                        code = "51", title = "International Business", ope6_id = "025034", unit_id = 51
                    },
                    new ProgramData {
                        code = "52", title = "Communication and Media Studies", ope6_id = "001052", unit_id = 52
                    },
                    new ProgramData {
                        code = "53", title = "Computer/Information Technology Administration and Management", ope6_id = "001052", unit_id = 53
                    },
                    new ProgramData {
                        code = "54", title = "Food Science and Technology", ope6_id = "001052", unit_id = 54
                    },
                    new ProgramData {
                        code = "55", title = "Parks, Recreation and Leisure Facilities Management", ope6_id = "001018", unit_id = 55
                    },
                    new ProgramData {
                        code = "56", title = "Family and Consumer Sciences/Human Sciences, General", ope6_id = "001018", unit_id = 56
                    },
                    new ProgramData {
                        code = "57", title = "Business, Management, Marketing, and Related Support Services, Other", ope6_id = "001018", unit_id = 57
                    },
                    new ProgramData {
                        code = "58", title = "Computer Systems Networking and Telecommunicationss", ope6_id = "007871", unit_id = 58
                    },
                    new ProgramData {
                        code = "59", title = "Computer Software and Media Applications", ope6_id = "007871", unit_id = 59
                    },
                    new ProgramData {
                        code = "60", title = "Vehicle Maintenance and Repair Technologies", ope6_id = "007871", unit_id = 60
                    },
                };
                foreach (ProgramData p in plist)
                {
                    dbContext.Programs.Add(p);
                }
                dbContext.SaveChanges();
            }

            return(View(schoolDataList));
        }
コード例 #30
0
        void InitializePrograms()
        {
            g_WhiteDiffuseColor = LoadLitProgram(VertexShaders.ModelPosVertexLighting_PN,
                                                 FragmentShaders.ColorPassthrough_frag);
            g_VertexDiffuseColor = LoadLitProgram(VertexShaders.ModelPosVertexLighting_PCN,
                                                  FragmentShaders.ColorPassthrough_frag);
            g_FragWhiteDiffuseColor = LoadLitProgram(VertexShaders.FragmentLighting_PN,
                                                     FragmentShaders.FragmentLighting);
            g_FragVertexDiffuseColor = LoadLitProgram(VertexShaders.FragmentLighting_PCN,
                                                      FragmentShaders.FragmentLighting);

            g_Unlit = LoadUnlitProgram(VertexShaders.PosTransform, FragmentShaders.ColorUniform_frag);
        }
コード例 #31
0
 public ConsoleOutput(ref ProgramData data)
 {
     _data = data;
 }
コード例 #32
0
 public void log(string message)
 {
     ProgramData.Log("Plugin: " + name, message, ProgramData.LOG_STYLE_NORMAL);
 }
コード例 #33
0
 public override NodeRunResult Run(ref ProgramCounter pc, ref ProgramData pd)
 {
     Console.WriteLine(ActorId + ": " + Text);
     return(NodeRunResult.NextCommand);
 }
コード例 #34
0
 public void warn(string message)
 {
     ProgramData.Log("Plugin: " + name, message, ProgramData.LOG_STYLE_WARN);
 }
コード例 #35
0
        void IEpgDataSink.WriteProgram(ProgramData programData, bool merged)
        {
            string channelId = programData.ChannelId;

            if (merged)
            {
                channelId = "[Merged]";
            }

            if (programData.StartTime != null &&
                programData.ChannelId != string.Empty &&
                programData.Title != string.Empty)
            {
                _writer.WriteStartElement("programme");
                TimeSpan t     = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
                string   tzOff = " " + t.Hours.ToString("+00;-00") + t.Minutes.ToString("00");
                _writer.WriteAttributeString("start", programData.StartTime.ToLocalTime().ToString("yyyyMMddHHmmss") + tzOff);
                if (programData.EndTime != null)
                {
                    _writer.WriteAttributeString("stop", programData.EndTime.ToLocalTime().ToString("yyyyMMddHHmmss") + tzOff);
                }
                _writer.WriteAttributeString("channel", _currentChannelName + "-" + channelId);

                _writer.WriteStartElement("title");
                //_writer.WriteAttributeString("lang", "de");
                _writer.WriteString(programData.Title);
                _writer.WriteEndElement();

                if (programData.SubTitle != string.Empty && programData.SubTitle != "unknown")
                {
                    _writer.WriteElementString("sub-title", programData.SubTitle);
                }

                if (programData.Description != string.Empty && programData.Description != "unknown")
                {
                    _writer.WriteElementString("desc", programData.Description);
                }

                if (programData.Genre != string.Empty && programData.Genre != "-")
                {
                    _writer.WriteElementString("category", programData.Genre);
                }

                string episodeNum = string.Empty;
                if (programData.Episode > 0)
                {
                    episodeNum += programData.Episode;
                }

                if (programData.Season > 0)
                {
                    episodeNum += "." + programData.Season;
                }

                if (episodeNum != string.Empty)
                {
                    _writer.WriteElementString("episode-num", episodeNum);
                }

                //if (program.Repeat != string.Empty)
                //{
                //  _writer.WriteElementString("previously-shown", null);
                //}

                /*
                 * _writer.WriteStartElement("credits");
                 * _writer.WriteElementString("director", "xxx");
                 * _writer.WriteElementString("actor", "xxx");
                 * _writer.WriteElementString("actor", "xxx");
                 * _writer.WriteElementString("actor", "xxx");
                 * _writer.WriteEndElement();
                 *
                 * _writer.WriteElementString("date", "xxx");
                 * _writer.WriteElementString("country", "xxx");
                 * _writer.WriteElementString("episode-num", "xxx");
                 *
                 * _writer.WriteStartElement("video");
                 * _writer.WriteElementString("aspect", "xxx");
                 * _writer.WriteEndElement();
                 *
                 * _writer.WriteStartElement("star-rating");
                 * _writer.WriteElementString("value", "3/3");
                 * _writer.WriteEndElement();
                 */

                _writer.WriteEndElement();
                _writer.Flush();
            }
        }
コード例 #36
0
 public TC_Data_FileStop(ProgramData thisProgPass, TrueCryptSWObj tcSWObjPass)
 {
     thisProginst = thisProgPass;
     tcSWobj      = tcSWObjPass;
 }
コード例 #37
0
 protected override void Handle(ProgramData data)
 {
     data.GameData          = GameData.New(data);
     data.PreviousGameState = data.GameData.GameState;
     data.ShowMainMenu      = false;
 }
コード例 #38
0
        static ProgramData LoadStandardProgram(String strVertexShader, String strFragmentShader)
        {
            ProgramData data = new ProgramData();
            int vertex_shader = Shader.compileShader(ShaderType.VertexShader, strVertexShader);
            int fragment_shader = Shader.compileShader(ShaderType.FragmentShader, strFragmentShader);
            data.theProgram  = Shader.createAndLinkProgram(vertex_shader, fragment_shader);

            data.modelToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "modelToCameraMatrix");
            data.normalModelToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "normalModelToCameraMatrix");

            data.cameraToClipMatrixUnif = GL.GetUniformLocation(data.theProgram, "cameraToClipMatrix");

            // Replace uniform buffers
            data.lightBlock = new LightBlock(NUMBER_OF_LIGHTS);
            data.lightBlock.SetUniforms(data.theProgram);

            data.materialBlock = new MaterialBlock();
            data.materialBlock.SetUniforms(data.theProgram);

            int gaussianTextureUnif = GL.GetUniformLocation(data.theProgram, "gaussianTexture");
            GL.UseProgram(data.theProgram);
            GL.Uniform1(gaussianTextureUnif, g_gaussTexUnit);
            GL.UseProgram(0);

            return data;
        }
コード例 #39
0
ファイル: frmMainView.cs プロジェクト: retroric/OricExplorer
        public void DisplayData(OricProgram.SpecialMode specialMode = OricProgram.SpecialMode.None)
        {
            DynamicByteProvider dynamicByteProvider;

            dynamicByteProvider = new DynamicByteProvider(ProgramData.ProgramData);

            hxbDump.ByteProvider   = dynamicByteProvider;
            hxbDump.LineInfoOffset = ProgramInfo.StartAddress;
            hxbDump.ReadOnly       = true;

            mMainForm.programInfoForm.DisplayProgramInformation(ProgramInfo);

            if (ShowSourceCode)
            {
                // Display the programs sourcecode
                if (ProgramInfo.Format == OricProgram.ProgramFormat.BinaryFile)
                {
                    fctSourceCode.Text = ProgramData.ListAssembler(specialMode);
                }
                else if (ProgramInfo.Format == OricProgram.ProgramFormat.BasicProgram)
                {
                    fctSourceCode.Text = ProgramData.ListBasicSourceAsText();
                }
                else if (ProgramInfo.Format == OricProgram.ProgramFormat.HyperbasicProgram)
                {
                    fctSourceCode.Text = ProgramData.ListHyperbasicSourceAsText();
                }
                else if (ProgramInfo.Format == OricProgram.ProgramFormat.TeleassSource)
                {
                    fctSourceCode.Text = ProgramData.ListTeleassSourceAsText();
                }
                else if (ProgramInfo.Format == OricProgram.ProgramFormat.OrixProgram)
                {
                    fctSourceCode.Text = ProgramData.ListAssembler(specialMode);
                }
            }

            switch (UserControl)
            {
            case UserControls.CharacterSetViewer:
                characterSetViewer.ProgramInfo = ProgramInfo;
                characterSetViewer.ProgramData = ProgramData;
                characterSetViewer.InitialiseView();
                break;

            case UserControls.DataFileViewer:
                dataFileViewer.ProgramInfo = ProgramInfo;
                dataFileViewer.ProgramData = ProgramData;
                dataFileViewer.InitialiseView();
                break;

            case UserControls.DataViewer:
                dataViewer.ProgramInfo = ProgramInfo;
                dataViewer.ProgramData = ProgramData;
                dataViewer.InitialiseView();
                break;

            case UserControls.ScreenViewer:
                screenViewer.ProgramInfo = ProgramInfo;
                screenViewer.ProgramData = ProgramData;
                screenViewer.InitialiseView();
                break;

            case UserControls.SequentialFileViewer:
                sequentialFileViewer.ProgramInfo = ProgramInfo;
                sequentialFileViewer.ProgramData = ProgramData;
                sequentialFileViewer.InitialiseView();
                break;

            case UserControls.None:
                break;

            default:
                break;
            }

            DisplayIndexAndAddress();
        }
コード例 #40
0
ファイル: ItemFunction.cs プロジェクト: Dessyreqt/RogueArena
 public abstract List <Event> Execute(ProgramData data);
コード例 #41
0
        void InitializeProgram()
        {
            ProgramData UniformColor = LoadProgram("PosOnlyWorldTransform_vert ColorUniform_frag");
            GL.UseProgram(UniformColor.theProgram);
            GL.Uniform4(UniformColor.baseColorUnif, 0.694f, 0.4f, 0.106f, 1.0f);
            GL.UseProgram(0);

            ProgramData UniformColorTint = LoadProgram("PosColorWorldTransform_vert ColorMultUniform_frag");
            GL.UseProgram(UniformColorTint.theProgram);
            GL.Uniform4(UniformColorTint.baseColorUnif, 0.5f, 0.5f, 0f, 1.0f);
            GL.UseProgram(0);

            ProgramData g_WhiteAmbDiffuseColor = LoadProgram("DirAmbVertexLighting_PN_vert ColorPassthrough_frag");

            ProgramData g_VertexDiffuseColor = LoadProgram("DirVertexLighting_PCN ColorPassthrough_frag");

            ProgramData g_Unlit = LoadProgram("unlit");

            ProgramData g_litShaderProg = LoadProgram("BasicTexture_PN ShaderGaussian");

            GL.UseProgram(g_VertexDiffuseColor.theProgram);
            Vector4 lightIntensity = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
            GL.Uniform3(g_VertexDiffuseColor.dirToLightUnif, ref dirToLight);
            GL.Uniform4(g_VertexDiffuseColor.lightIntensityUnif, ref lightIntensity);
            GL.UseProgram(0);

            GL.UseProgram(g_WhiteAmbDiffuseColor.theProgram);
            Vector3 light_direction = new Vector3(10f, 10f, 0f);
            Vector4 light_intensity = new Vector4(0.5f, 0.5f, 0.5f, 0.5f);
            Vector4  ambient_intensity = new Vector4(0.3f, 0.0f, 0.3f, 0.6f);
            GL.Uniform3(g_WhiteAmbDiffuseColor.dirToLightUnif, ref light_direction);
            GL.Uniform4(g_WhiteAmbDiffuseColor.lightIntensityUnif, ref light_intensity);
            GL.Uniform4(g_WhiteAmbDiffuseColor.ambientIntensityUnif, ref ambient_intensity);
            Matrix3 m = Matrix3.Identity;
            GL.UniformMatrix3(g_WhiteAmbDiffuseColor.normalModelToCameraMatrixUnif, false, ref m);
            GL.UseProgram(0);

            GL.UseProgram(g_Unlit.theProgram);
            GL.Uniform4(g_Unlit.baseColorUnif, 0.5f, 0.5f, 0f, 1.0f);
            Matrix4 test = Matrix4.Identity;
            GL.UniformMatrix4(g_Unlit.cameraToClipMatrixUnif, false, ref test);
            GL.UseProgram(0);

            // Test shader lights and materials
            GL.UseProgram(g_litShaderProg.theProgram);
            g_litShaderProg.lightBlock = new LightBlock(NUMBER_OF_LIGHTS);
            g_litShaderProg.lightBlock.SetUniforms(g_litShaderProg.theProgram);

            g_litShaderProg.lightBlock.ambientIntensity = new Vector4(0.1f, 0.1f, 0.1f, 1.0f);

            g_litShaderProg.lightBlock.lights[0].cameraSpaceLightPos = new Vector4(4.0f, 0.0f, 1.0f, 1.0f);
            g_litShaderProg.lightBlock.lights[0].lightIntensity = new Vector4(0.7f, 0.0f, 0.0f, 1.0f);

            g_litShaderProg.lightBlock.lights[1].cameraSpaceLightPos = new Vector4(4.0f, 0.0f, 1.0f, 1.0f);
            g_litShaderProg.lightBlock.lights[1].lightIntensity = new Vector4(0.0f, 0.0f, 0.7f, 1.0f);

            g_litShaderProg.lightBlock.UpdateInternal();

            g_litShaderProg.materialBlock = new MaterialBlock(new Vector4(0.0f, 0.3f, 0.0f, 1.0f),
                new Vector4(0.5f, 0.0f, 0.5f, 1.0f), 0.6f);
            g_litShaderProg.materialBlock.SetUniforms(g_litShaderProg.theProgram);
            g_litShaderProg.materialBlock.UpdateInternal();

            GL.UseProgram(0);

            ProgramData ObjectColor = LoadProgram("PosColorWorldTransform_vert ColorPassthrough_frag");
            currentProgram = ObjectColor;

            ProgramData g_WhiteDiffuseColor = LoadProgram("PosColorLocalTransform_vert ColorPassthrough_frag");

            ProgramData DiffuseSpecularHDR = LoadProgram("HDR_PCN DiffuseSpecularHDR");
            ProgramData DiffuseOnlyHDR = LoadProgram("HDR_PCN DiffuseOnlyHDR");
            ProgramData DiffuseSpecularMtlHDR = LoadProgram("HDR_PCN DiffuseSpecularMtlHDR");
            ProgramData DiffuseOnlyMtlHDR = LoadProgram("HDR_PCN DiffuseOnlyMtlHDR");

            otherPrograms.Add(ObjectColor);
            otherPrograms.Add(UniformColor);
            otherPrograms.Add(UniformColorTint);
            otherPrograms.Add(g_WhiteDiffuseColor);
            otherPrograms.Add(g_VertexDiffuseColor);
            otherPrograms.Add(g_WhiteAmbDiffuseColor);
            otherPrograms.Add(g_Unlit);
            otherPrograms.Add(g_WhiteDiffuseColor);
            otherPrograms.Add(DiffuseSpecularHDR);
            otherPrograms.Add(DiffuseOnlyHDR);
            otherPrograms.Add(DiffuseSpecularMtlHDR);
            otherPrograms.Add(DiffuseOnlyMtlHDR);
        }
コード例 #42
0
        ProgramData LoadProgram(string vertexShader, string fragmentShader)
        {
            ProgramData data = new ProgramData();
            int vertexShaderInt = Shader.compileShader(ShaderType.VertexShader, vertexShader);
            int fragmentShaderInt = Shader.compileShader(ShaderType.FragmentShader, fragmentShader);

            data.theProgram = Shader.createAndLinkProgram(vertexShaderInt, fragmentShaderInt);
            data.modelToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "modelToCameraMatrix");

            data.cameraToClipMatrixUnif = GL.GetUniformLocation(data.theProgram, "cameraToClipMatrix");

            int colorTextureUnif = GL.GetUniformLocation(data.theProgram, "colorTexture");
            GL.UseProgram(data.theProgram);
            GL.Uniform1(colorTextureUnif, g_colorTexUnit);
            GL.UseProgram(0);

            return data;
        }
コード例 #43
0
        public void WorldLoaderThread(int min, int max)
        {
#if CREATE_CRASH_LOGS
            try
#endif
            {
                for (int i = min; i < max; i++)
                {
                    if (ExitThreads)
                    {
                        break;
                    }

                    Worlds[i].Lock.WaitOne();
                    if (!Worlds[i].IsLoaded)
                    {
                        Worlds[i].Lock.ReleaseMutex();

                        //Worlds[i].File = new OverworldFile(Worlds[i].FileName, true);
                        Worlds[i].File      = new OverworldFile();
                        Worlds[i].File.Data = new OverworldFile.OverworldData();

                        Worlds[i].Lock.WaitOne();
                        try
                        {
                            Worlds[i].File.Data.Screenshot = TextureManager.LoadInstanceTexture(Worlds[i].ScreenshotName);
                            if (Worlds[i].File.Data.Screenshot != null)
                            {
                                Worlds[i].Button.Image           = new ImageFrame(Worlds[i].File.Data.Screenshot);
                                Worlds[i].Button.Mode            = Button.ButtonMode.ImageButton;
                                Worlds[i].Button.KeepAspectRatio = true;
                                Worlds[i].Button.Text            = Worlds[i].WorldName;
                                Worlds[i].Button.TextColor       = Color.Black;
                            }
                            else
                            {
                                Worlds[i].Button.Text = Worlds[i].WorldName;
                            }
                        }
                        catch (Exception e)
                        {
                            Worlds[i].Button.Text = "ERROR " + Worlds[i].WorldName;
                            Console.Error.WriteLine(e.Message);
                        }
                        Worlds[i].Lock.ReleaseMutex();
                    }
                    else
                    {
                        Worlds[i].Lock.ReleaseMutex();
                    }

                    Worlds[i].IsLoaded = true;
                }
            }
#if CREATE_CRASH_LOGS
            catch (Exception exception)
            {
                ProgramData.WriteExceptionLog(exception);
            }
#endif
        }
コード例 #44
0
ファイル: CassetteData.cs プロジェクト: zmthy/nztronix
 public CassetteData(MetaData meta, ProgramData program)
 {
     Meta = meta;
       Program = program;
 }
コード例 #45
0
        ProgramData LoadProgram(String vertexShader, String fragmentShader)
        {
            ProgramData data = new ProgramData();
            int vertexShaderInt = Shader.compileShader(ShaderType.VertexShader, vertexShader);
            int fragmentShaderInt = Shader.compileShader(ShaderType.FragmentShader, fragmentShader);
            data.theProgram = Shader.createAndLinkProgram(vertexShaderInt, fragmentShaderInt);

            data.positionAttribute = GL.GetAttribLocation(data.theProgram, "position");
            data.colorAttribute = GL.GetAttribLocation(data.theProgram, "color");
            data.normalAttribute = GL.GetAttribLocation(data.theProgram, "normal");

            if (data.positionAttribute != -1)
            {
                if (data.positionAttribute != 0)
                {
                    MessageBox.Show("These meshes only work with position at location 0 " + vertexShader);
                }
            }
            if (data.colorAttribute != -1)
            {
                if (data.colorAttribute != 1)
                {
                    MessageBox.Show("These meshes only work with color at location 1" + vertexShader);
                }
            }

            data.modelToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "modelToCameraMatrix");
            data.normalModelToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "normalModelToCameraMatrix");
            data.dirToLightUnif = GL.GetUniformLocation(data.theProgram, "dirToLight");
            data.lightIntensityUnif = GL.GetUniformLocation(data.theProgram, "lightIntensity");
            data.ambientIntensityUnif = GL.GetUniformLocation(data.theProgram, "ambientIntensity");

            //FIX_THIS  int projectionBlock = GL.GetUniformBlockIndex(data.theProgram, "Projection");
            //FIX_THIS  GL.UniformBlockBinding(data.theProgram, projectionBlock, g_projectionBlockIndex);
            // to avoid uniform block
            data.cameraToClipMatrixUnif = GL.GetUniformLocation(data.theProgram, "Projection.cameraToClipMatrix");
            if (data.cameraToClipMatrixUnif == -1)
            {
                data.cameraToClipMatrixUnif = GL.GetUniformLocation(data.theProgram, "cameraToClipMatrix");

            }
            return data;
        }
コード例 #46
0
        /* concept:
         *
         * foreach mod on the portal, check if we have an entry for said mod alraedy
         * if we do, compare latest release release date
         * if it differs, get ResultEntryFull from the protal
         * for every release with a maintained factorio version,
         * check if we already have this version downloaded
         * if we don't download it
         *
         * if we don't have an entry already, create an entry for the mod
         * and then do the same download logic as above
         * this includes checking for existing ones, so mods that were manually
         * copied into the mods folder would be identified
         *
         */

        public async Task RunAsync()
        {
            if (argsService.GetArgs().CreateConfig)
            {
                return;
            }

            Console.WriteLine("Syncronizing with mod portal...");

            ProgramData      programData      = programDataService.GetProgramData();
            HashSet <string> modNamesToDelete = programData.Mods.Values.Select(m => m.Name).ToHashSet();

            Console.WriteLine($"Loaded {programData.Mods.Count} mods from data file.");

            DateTime lastSaveTime       = DateTime.Now;
            int      attemptedSaveCount = 0;

            void SaveChanges(bool bypassConditions = false)
            {
                // only save every 5 minutes, but also only if there have been 32 attempts
                // to save, which indicates that something changed 32 times
                ++attemptedSaveCount;
                if (bypassConditions ||
                    (
                        attemptedSaveCount >= 32 &&
                        (DateTime.Now - lastSaveTime).Minutes >= 5
                    ))
                {
                    Console.WriteLine($"Saving {attemptedSaveCount} changes.");
                    attemptedSaveCount = 0;
                    programDataService.SetProgramData(programData);
                    lastSaveTime = DateTime.Now;
                }
            }

            // create and update
            await foreach (var entry in client.EnumerateAsync())
            {
                if (programData.Mods.TryGetValue(entry.Name, out var modData))
                {
                    modNamesToDelete.Remove(entry.Name);

                    if ((entry.LatestRelease?.ReleasedAt ?? null) != (modData.LatestRelease?.ReleasedAt ?? null))
                    {
                        SyncMod(entry, await client.GetResultEntryFullAsync(entry.Name), modData);
                        Console.WriteLine($"Changed {entry.Name}.");
                        SaveChanges();
                    }
                    else
                    {
                        SyncModPartial(entry, modData);
                    }
                }
                else
                {
                    var entryFull = await client.GetResultEntryFullAsync(entry.Name);

                    modData = mapperService.MapToModData(entryFull);
                    SyncMod(entry, entryFull, modData);
                    programData.Mods.Add(modData.Name, modData);
                    Console.WriteLine($"Added   {entry.Name}.");
                    SaveChanges();
                }
            }

            // delete mods
            if (modNamesToDelete.Count > 0)
            {
                foreach (var modNameToDelete in modNamesToDelete)
                {
                    programData.Mods.Remove(modNameToDelete);
                    Console.WriteLine($"Removed {modNameToDelete}.");
                }
                SaveChanges();
            }

            if (attemptedSaveCount > 0)
            {
                --attemptedSaveCount;
                SaveChanges(bypassConditions: true);
            }

            Console.WriteLine("Determining which releases should be maintained. Downloading and deleting accordingly.");

            var maintainedVersions = configService.GetConfig().MaintainedFactorioVersions;

            List <FactorioVersion> cachedReleases = new List <FactorioVersion>();

            foreach (var mod in programData.Mods.Values)
            {
                await SyncMaintainedReleasesAsync(mod, maintainedVersions, cachedReleases);
            }
        }
コード例 #47
0
 private static void SetGlobalMatrices(ProgramData program)
 {
     GL.UseProgram(program.theProgram);
     GL.UniformMatrix4(program.cameraToClipMatrixUnif, false, ref pm);  // this one is first
     GL.UniformMatrix4(program.worldToCameraMatrixUnif, false, ref cm); // this is the second one
     GL.UseProgram(0);
 }
コード例 #48
0
 public override NodeRunResult Run(ref ProgramCounter pc, ref ProgramData pd)
 {
     return(NodeRunResult.PushChildFirst);
 }
コード例 #49
0
        ProgramData LoadProgram(String strVertexShader, String strFragmentShader)
        {
            ProgramData data = new ProgramData();
            int vertex_shader = Shader.compileShader(ShaderType.VertexShader, strVertexShader);
            int fragment_shader = Shader.compileShader(ShaderType.FragmentShader, strFragmentShader);
            data.theProgram  = Shader.createAndLinkProgram(vertex_shader, fragment_shader);

            data.positionAttribute = GL.GetAttribLocation(data.theProgram, "position");
            if (data.positionAttribute != -1)
            {
                if (data.positionAttribute != 0)
                {
                    MessageBox.Show("These meshes only work with position at location 0 " + strVertexShader);
                }
            }
            data.colorAttribute = GL.GetAttribLocation(data.theProgram, "color");

            data.modelToWorldMatrixUnif = GL.GetUniformLocation(data.theProgram, "modelToWorldMatrix");
            data.worldToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "worldToCameraMatrix");
            data.cameraToClipMatrixUnif = GL.GetUniformLocation(data.theProgram, "cameraToClipMatrix");
            data.baseColorUnif = GL.GetUniformLocation(data.theProgram, "baseColor");

            return data;
        }
コード例 #50
0
        public override String keyboard(Keys keyCode, int x, int y)
        {
            StringBuilder result = new StringBuilder();
            result.AppendLine(keyCode.ToString());
            switch (keyCode) {
            case Keys.NumPad6:
                Camera.MoveTarget(0.5f, 0f, 0.0f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad4:
                Camera.MoveTarget(-0.5f, 0f, 0.0f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad8:
                Camera.MoveTarget(0.0f, 0.5f, 0.0f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad2:
                Camera.MoveTarget(0f, -0.5f, 0.0f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad7:
                Camera.MoveTarget(0.0f, 0.0f, 0.5f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.NumPad3:
                Camera.MoveTarget(0f, 0.0f, -0.5f);
                result.AppendFormat(Camera.GetTargetString());
                break;
            case Keys.D1:
                axis = Vector3.UnitX;
                angle = angle + 1;
                break;
            case Keys.D2:
                axis = Vector3.UnitY;
                angle = angle + 1;
                break;
            case Keys.D3:
                axis = Vector3.UnitZ;
                angle = angle + 1;
                break;
            case Keys.D4:
                break;
            case Keys.D5:
                break;
            case Keys.D6:
                break;
            case Keys.V:
                newPerspectiveAngle = perspectiveAngle + 5f;
                if (newPerspectiveAngle > 120f)
                {
                    newPerspectiveAngle = 30f;
                }
                break;
            case Keys.S:
                renderWithString = true;
                renderString = "flat";
                break;
            case Keys.M:
                renderWithString = false;
                currentMesh++;
                if (currentMesh > meshes.Count - 1) currentMesh = 0;
                result.AppendLine("Mesh = " + meshes[currentMesh].fileName);
                break;
            case Keys.X:
                noWorldMatrix = true;
                reshape();
                break;
            case Keys.P:
                noWorldMatrix = true;
                currentProgram = otherPrograms[currentOtherProgram++];
                if (currentOtherProgram > otherPrograms.Count - 1) currentOtherProgram = 0;
                result.AppendLine("Program = " + otherPrograms[currentOtherProgram].name);
                break;
            case Keys.Q:
                result.AppendLine("currentProgram = " + currentProgram.ToString());
                break;
            case Keys.I:
                result.AppendLine("Current Mesh Data");
                result.Append(meshes[currentMesh].GetMeshData());
                break;
            case Keys.O:
                scaleFactor = meshes[currentMesh].GetUnitScaleFactor();
                result.Append(scaleFactor.ToString());
                break;
            }

            reshape();
            display();
            return result.ToString();
        }
コード例 #51
0
        /// <summary>
        /// Gets the program given index number.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <returns>the tv program data</returns>
        private ProgramData GetProgram(int index)
        {
            ProgramData guideData = (ProgramData)_parser.GetData(index);

            if (guideData == null ||
                guideData.StartTime == null || guideData.Title == string.Empty)
            {
                return(null);
            }

            // Set ChannelId
            guideData.ChannelId = _strID;

            if (_grabber.Actions != null && guideData.IsRemoved(_grabber.Actions))
            {
                _discarded++;
                return(null);
            }

            //Log.Debug("WebEPG: Guide, Program title: {0}", guideData.Title);
            //Log.Debug("WebEPG: Guide, Program start: {0}:{1} - {2}/{3}/{4}", guideData.StartTime.Hour, guideData.StartTime.Minute, guideData.StartTime.Day, guideData.StartTime.Month, guideData.StartTime.Year);
            //if (guideData.EndTime != null)
            //  Log.Debug("WebEPG: Guide, Program end  : {0}:{1} - {2}/{3}/{4}", guideData.EndTime.Hour, guideData.EndTime.Minute, guideData.EndTime.Day, guideData.EndTime.Month, guideData.EndTime.Year);
            //Log.Debug("WebEPG: Guide, Program desc.: {0}", guideData.Description);
            //Log.Debug("WebEPG: Guide, Program genre: {0}", guideData.Genre);

            // Adjust Time
            if (guideData.StartTime.Day == 0 || guideData.StartTime.Month == 0 || guideData.StartTime.Year == 0)
            {
                if (!_timeControl.CheckAdjustTime(ref guideData))
                {
                    _discarded++;
                    return(null);
                }
            }

            //Set TimeZone
            guideData.StartTime.TimeZone = _siteTimeZone;
            if (guideData.EndTime != null)
            {
                guideData.EndTime.TimeZone = _siteTimeZone;
                Log.Info("WebEPG: Guide, Program Info: {0} / {1} - {2}",
                         guideData.StartTime.ToLocalLongDateTime(), guideData.EndTime.ToLocalLongDateTime(), guideData.Title);
            }
            else
            {
                Log.Info("WebEPG: Guide, Program Info: {0} - {1}", guideData.StartTime.ToLocalLongDateTime(),
                         guideData.Title);
            }

            if (guideData.StartTime.ToLocalTime() < _grabStart.AddHours(-2))
            {
                Log.Info("WebEPG: Program starts in the past, ignoring it.");
                _discarded++;
                return(null);
            }

            // Check TV db if program exists
            if (_dblookup)
            {
                Program dbProg = dbProgram(guideData.Title, guideData.StartTime.ToLocalTime());
                if (dbProg != null)
                {
                    Log.Info("WebEPG: Program already in db");
                    Channel chan = Broker.TryRetrieveInstance <Channel>(new Key(true, "ExternalId", _strID));
                    if (chan != null)
                    {
                        ProgramData dbProgramData = new ProgramData();
                        dbProgramData.InitFromProgram(dbProg);
                        dbProgramData.ChannelId = _strID;
                        return(dbProgramData);
                    }
                }
            }

            // SubLink
            if (guideData.HasSublink())
            {
                if (_parser is WebParser)
                {
                    // added: delay info
                    Log.Info("WebEPG: SubLink Request {0} - Delay: {1}ms", guideData.SublinkRequest.ToString(),
                             guideData.SublinkRequest.Delay);

                    WebParser webParser = (WebParser)_parser;

                    if (!webParser.GetLinkedData(ref guideData))
                    {
                        Log.Info("WebEPG: Getting sublinked data failed");
                    }
                    else
                    {
                        Log.Debug("WebEPG: Getting sublinked data sucessful");
                    }
                }
            }

            if (_grabber.Actions != null)
            {
                guideData.Replace(_grabber.Actions);
            }

            return(guideData /*.ToTvProgram()*/);
        }
コード例 #52
0
 // TODO Return result enum
 public virtual NodeRunResult Run(ref ProgramCounter pc, ref ProgramData pd)
 {
     Console.WriteLine("TODO Implement Execute for:" + NodeType + " " + CommandType);
     return(NodeRunResult.NextCommand);
 }
コード例 #53
0
        /// <summary>
        /// Gets the channel listing.
        /// </summary>
        /// <param name="error">if set to <c>true</c> [error].</param>
        /// <returns>bool - more data exist</returns>
        private bool GetListing(out bool error)
        {
            int  listingCount = 0;
            int  programCount = 0;
            bool bMore        = false;

            error = false;

            HTTPRequest request = _reqBuilder.GetRequest();

            // added: delay info
            Log.Info("WebEPG: Reading {0} - Delay: {1}ms", request.ToString(), request.Delay);

            listingCount = _parser.ParseUrl(request);

            if (listingCount == 0)
            {
                if (_grabber.Listing.SearchParameters.MaxListingCount == 0 ||
                    (_grabber.Listing.SearchParameters.MaxListingCount != 0 && _reqBuilder.Offset == 0))
                {
                    Log.Info("WebEPG: No Listings Found");
                    //_reqBuilder.AddDays(1); -- removed because adding double days if continuing on error. 5/3/09
                    error = true;
                }
                else
                {
                    Log.Info("WebEPG: Listing Count 0");
                }
            }
            else
            {
                Log.Info("WebEPG: Listing Count {0}", listingCount);

                if (_reqBuilder.IsMaxListing(listingCount) || !_reqBuilder.IsLastPage())
                {
                    bMore = true;
                }

                _discarded   = 0;
                programCount = 0;
                _timeControl.SetProgramCount(listingCount);
                for (int i = 0; i < listingCount; i++)
                {
                    ProgramData program = GetProgram(i);
                    if (program != null)
                    {
                        _programs.Add(program);
                        programCount++;
                    }
                }

                Log.Debug("WebEPG: Program Count ({0}), Listing Count ({1}), Discard Count ({2})", programCount,
                          listingCount, _discarded);
                if (programCount < (listingCount - _discarded))
                {
                    Log.Info("WebEPG: Program Count ({0}) < Listing Count ({1}) - Discard Count ({2}), possible template error",
                             programCount, listingCount, _discarded);
                }

                if (_timeControl.GrabDay > _maxGrabDays)
                {
                    bMore = false;
                }
            }

            return(bMore);
        }
コード例 #54
0
 void InitializeProgram()
 {
     g_WhiteDiffuseColor = LoadProgram(VertexShaders.DirVertexLighting_PN_vert, FragmentShaders.ColorPassthrough_frag);
     g_VertexDiffuseColor = LoadProgram(VertexShaders.DirVertexLighting_PCN_vert, FragmentShaders.ColorPassthrough_frag);
     g_WhiteAmbDiffuseColor = LoadProgram(VertexShaders.DirAmbVertexLighting_PN_vert, FragmentShaders.ColorPassthrough_frag);
     g_VertexAmbDiffuseColor = LoadProgram(VertexShaders.DirAmbVertexLighting_PCN_vert, FragmentShaders.ColorPassthrough_frag);
 }
コード例 #55
0
        //private ProgramKey ParseKey(string key)

        private bool ParseProgramData(List <string> line, int startIndex, DeviceType device, out ProgramData data)
        {
            data = null;
            if (regex3.IsMatch(line[startIndex].Trim()))
            {
                data = new ProgramData();
                //начинаем считывание частот и времен
                for (int i = startIndex; i < line.Count; i++)
                {
                    string freq = line[i].Trim();
                    if (regex3.IsMatch(freq))
                    {
                        float  f    = float.Parse(freq.Replace(',', '.'), CultureInfo.InvariantCulture.NumberFormat);
                        string time = line[i + 1].Trim();
                        if (!regex3.IsMatch(time))
                        {
                            throw new Exception(Lang.Phrase("Частота найдена, но не найдено время для нее"));
                        }
                        if (f <= 0 || f > DeviceInfo.GetMaxFreq(device))
                        {
                            throw new Exception(Lang.Phrase("Частота '{0}' выходит за допустимый диапазон", f));
                        }
                        UInt16   t  = UInt16.Parse(time);
                        FreqTime ft = new FreqTime(f, t);
                        data.Add(ft);
                        i++;
                    }
                    else
                    {
                        if (!regex4.IsMatch(freq))
                        {
                            throw new Exception(Lang.Phrase("Неизвестный завершающий символ '{0}'", freq));
                        }
                        break;
                    }
                }

                if (data.Count > DeviceInfo.GetMaxFreqCount(device))
                {
                    throw new Exception(Lang.Phrase("Число частот программы превышает допустимое значение для данного типа устройства"));
                }

                return(true);
            }

            return(false);
        }
コード例 #56
0
 public override NodeRunResult Run(ref ProgramCounter pc, ref ProgramData pd)
 {
     return(NodeRunResult.PushParallel);
 }
コード例 #57
0
 public override NodeRunResult Run(ref ProgramCounter pc, ref ProgramData pd)
 {
     pc.ReturnRegisterString = this.TargetPage;
     return(NodeRunResult.PushPage);
 }
コード例 #58
0
        ProgramData LoadProgram(string programSetString)
        {
            ProgramSet programSet = ProgramSets.Find(programSetString);
            ProgramData data = new ProgramData();
            data.name = programSet.name;
            int vertex_shader = Shader.compileShader(ShaderType.VertexShader, programSet.vertexShader);
            int fragment_shader = Shader.compileShader(ShaderType.FragmentShader, programSet.fragmentShader);
            data.theProgram  = Shader.createAndLinkProgram(vertex_shader, fragment_shader);

            data.positionAttribute = GL.GetAttribLocation(data.theProgram, "position");
            data.colorAttribute = GL.GetAttribLocation(data.theProgram, "color");
            if (data.positionAttribute != -1)
            {
                if (data.positionAttribute != 0)
                {
                    MessageBox.Show("These meshes only work with position at location 0 " + programSet.vertexShader);
                }
            }
            if (data.colorAttribute != -1)
            {
                if (data.colorAttribute != 1)
                {
                    MessageBox.Show("These meshes only work with color at location 1" + programSet.vertexShader);
                }
            }

            data.modelToWorldMatrixUnif = GL.GetUniformLocation(data.theProgram, "modelToWorldMatrix");
            data.worldToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "worldToCameraMatrix");
            data.cameraToClipMatrixUnif = GL.GetUniformLocation(data.theProgram, "cameraToClipMatrix");
            if (data.cameraToClipMatrixUnif == -1)
            {
                data.cameraToClipMatrixUnif = GL.GetUniformLocation(data.theProgram, "Projection.cameraToClipMatrix");
            }
            data.baseColorUnif = GL.GetUniformLocation(data.theProgram, "baseColor");
            if (data.baseColorUnif == -1)
            {
                data.baseColorUnif = GL.GetUniformLocation(data.theProgram, "objectColor");
            }

            data.modelToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "modelToCameraMatrix");

            data.normalModelToCameraMatrixUnif = GL.GetUniformLocation(data.theProgram, "normalModelToCameraMatrix");
            data.dirToLightUnif =  GL.GetUniformLocation(data.theProgram, "dirToLight");
            data.lightIntensityUnif = GL.GetUniformLocation(data.theProgram, "lightIntensity");
            data.ambientIntensityUnif = GL.GetUniformLocation(data.theProgram, "ambientIntensity");
            data.normalAttribute = GL.GetAttribLocation(data.theProgram, "normal");

            return data;
        }
コード例 #59
0
        public void GenerateWorld(int seed, int width, int height)
        {
#if CREATE_CRASH_LOGS
            try
#endif
            {
                Seed = seed;
                MathFunctions.Random       = new ThreadSafeRandom(Seed);
                Overworld.heightNoise.Seed = seed;
                CurrentState = GenerationState.Generating;

                if (Overworld.Name == null)
                {
                    Overworld.Name = WorldGenerationSettings.GetRandomWorldName();
                }

                LoadingMessage             = "Init..";
                Overworld.heightNoise.Seed = Seed;
                worldData     = new Color[width * height];
                Overworld.Map = new Overworld.MapData[width, height];

                Progress = 0.01f;

                LoadingMessage           = "Height Map ...";
                float[,] heightMapLookup = null;
                heightMapLookup          = Overworld.GenerateHeightMapLookup(width, height);
                Overworld.GenerateHeightMapFromLookup(heightMapLookup, width, height, 1.0f, false);

                Progress = 0.05f;

                int numRains       = (int)Settings.NumRains;
                int rainLength     = 250;
                int numRainSamples = 3;

                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        Overworld.Map[x, y].Erosion    = 1.0f;
                        Overworld.Map[x, y].Weathering = 0;
                        Overworld.Map[x, y].Faults     = 1.0f;
                    }
                }

                LoadingMessage = "Climate";
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        Overworld.Map[x, y].Temperature = ((float)(y) / (float)(height)) * Settings.TemperatureScale;
                        //Overworld.Map[x, y].Rainfall = Math.Max(Math.Min(Overworld.noise(x, y, 1000.0f, 0.01f) + Overworld.noise(x, y, 100.0f, 0.1f) * 0.05f, 1.0f), 0.0f) * RainfallScale;
                    }
                }

                //Overworld.Distort(width, height, 60.0f, 0.005f, Overworld.ScalarFieldType.Rainfall);
                Overworld.Distort(width, height, 30.0f, 0.005f, Overworld.ScalarFieldType.Temperature);
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        Overworld.Map[x, y].Temperature = Math.Max(Math.Min(Overworld.Map[x, y].Temperature, 1.0f), 0.0f);
                    }
                }

                int numVoronoiPoints = (int)Settings.NumFaults;

                if (UpdatePreview != null)
                {
                    UpdatePreview();
                }

                Progress       = 0.1f;
                LoadingMessage = "Faults ...";

                #region voronoi

                Voronoi(width, height, numVoronoiPoints);

                #endregion

                Overworld.GenerateHeightMapFromLookup(heightMapLookup, width, height, 1.0f, true);

                Progress = 0.2f;

                Overworld.GenerateHeightMapFromLookup(heightMapLookup, width, height, 1.0f, true);

                Progress = 0.25f;
                if (UpdatePreview != null)
                {
                    UpdatePreview();
                }
                LoadingMessage = "Erosion...";

                #region erosion

                float[,] buffer = new float[width, height];
                Erode(width, height, Settings.SeaLevel, Overworld.Map, numRains, rainLength, numRainSamples, buffer);
                Overworld.GenerateHeightMapFromLookup(heightMapLookup, width, height, 1.0f, true);

                #endregion

                Progress = 0.9f;


                LoadingMessage = "Blur.";
                Overworld.Blur(Overworld.Map, width, height, Overworld.ScalarFieldType.Erosion);

                LoadingMessage = "Generate height.";
                Overworld.GenerateHeightMapFromLookup(heightMapLookup, width, height, 1.0f, true);


                LoadingMessage = "Rain";
                CalculateRain(width, height);

                LoadingMessage = "Biome";
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        Overworld.Map[x, y].Biome = Overworld.GetBiome(Overworld.Map[x, y].Temperature, Overworld.Map[x, y].Rainfall, Overworld.Map[x, y].Height).Biome;
                    }
                }

                LoadingMessage = "Volcanoes";

                GenerateVolcanoes(width, height);

                if (UpdatePreview != null)
                {
                    UpdatePreview();
                }


                LoadingMessage = "Factions";
                FactionLibrary library = new FactionLibrary();
                library.Initialize(null, new CompanyInformation());

                if (Settings.Natives == null || Settings.Natives.Count == 0)
                {
                    NativeCivilizations = new List <Faction>();
                    for (int i = 0; i < Settings.NumCivilizations; i++)
                    {
                        NativeCivilizations.Add(library.GenerateFaction(null, i, Settings.NumCivilizations));
                    }
                    Settings.Natives = NativeCivilizations;
                }
                else
                {
                    NativeCivilizations = Settings.Natives;

                    if (Settings.NumCivilizations > Settings.Natives.Count)
                    {
                        int count = Settings.Natives.Count;
                        for (int i = count; i < Settings.NumCivilizations; i++)
                        {
                            NativeCivilizations.Add(library.GenerateFaction(null, i, Settings.NumCivilizations));
                        }
                    }
                }
                SeedCivs(Overworld.Map, Settings.NumCivilizations, NativeCivilizations);
                GrowCivs(Overworld.Map, 200, NativeCivilizations);


                for (int x = 0; x < width; x++)
                {
                    Overworld.Map[x, 0]          = Overworld.Map[x, 1];
                    Overworld.Map[x, height - 1] = Overworld.Map[x, height - 2];
                }

                for (int y = 0; y < height; y++)
                {
                    Overworld.Map[0, y]         = Overworld.Map[1, y];
                    Overworld.Map[width - 1, y] = Overworld.Map[width - 2, y];
                }

                LoadingMessage = "Selecting Spawn Point";
                AutoSelectSpawnRegion();

                CurrentState   = GenerationState.Finished;
                LoadingMessage = "";
                Progress       = 1.0f;
            }
#if CREATE_CRASH_LOGS
            catch (Exception exception)
            {
                ProgramData.WriteExceptionLog(exception);
                throw;
            }
#endif
        }