예제 #1
0
        public IHttpActionResult PostWater([FromBody] string water)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            WaterModel sm  = JsonConvert.DeserializeObject <WaterModel>(water);
            EMI        emi = new EMI()
            {
                EmisCode     = sm.Generalmodel.Emi.EmisCode,
                NameOfSchool = sm.Generalmodel.Emi.NameOfSchool,
                CreatedOn    = DateTime.UtcNow,
                ModifiedOn   = DateTime.UtcNow
            };

            db.EMIS.Add(emi);
            db.SaveChanges();
            Comment c = new Comment()
            {
                Entity     = sm.Generalmodel.Comment.Entity,
                SurveyID   = sm.Generalmodel.Comment.SurveyID,
                Section    = sm.Generalmodel.Comment.Section,
                CreatedOn  = DateTime.UtcNow,
                ModifiedOn = DateTime.UtcNow,
                Comments   = sm.Generalmodel.Comment.Comments
            };

            db.Comments.Add(c);
            db.SaveChanges();
            SpecialFacility sf = new SpecialFacility()
            {
                Entity     = sm.Generalmodel.Specialfacility.Entity,
                SurveyID   = sm.Generalmodel.Specialfacility.SurveyID,
                Section    = sm.Generalmodel.Specialfacility.Section,
                CreatedOn  = DateTime.UtcNow,
                ModifiedOn = DateTime.UtcNow,
                AnyFacilitiesForDisableStudents = sm.Generalmodel.Specialfacility.AnyFacilitiesForDisableStudents,
                Description = sm.Generalmodel.Specialfacility.Description
            };

            db.SpecialFacilities.Add(sf);
            db.SaveChanges();
            List <Picture> res = sm.Generalmodel.Img.Select(x => new Picture
            {
                Entity     = x.Entity,
                SurveyID   = x.SurveyID,
                Section    = x.Section,
                CreatedOn  = DateTime.UtcNow,
                ModifiedOn = DateTime.UtcNow,
                Picture1   = x.Picture1
            }).ToList();

            db.Pictures.AddRange(res);
            db.SaveChanges();



            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        public void Shutdown()
        {
            // Release the position object.
            Position = null;
            // Release the light object.
            Light = null;
            // Release the fps object.
            FPS = null;
            // Release the camera object.
            Camera = null;

            // Release the text object.
            Text?.Shutdown();
            Text = null;
            // Release the cpu object.
            CPU?.Shutdown();
            CPU = null;
            // Release the water shader object.
            WaterShader?.ShutDown();
            WaterShader = null;
            // Release the water object.
            WaterModel?.ShutDown();
            WaterModel = null;
            // Release the reflection shader object.
            ReflectionShader?.ShutDown();
            ReflectionShader = null;
            // Release the reflection render to texture object.
            ReflectionTexture?.Shutdown();
            ReflectionTexture = null;
            // Release the refraction render to texture object.
            RefractionTexture?.Shutdown();
            RefractionTexture = null;
            // Release the sky plane shader object.
            SkyPlaneShader?.ShutDown();
            SkyPlaneShader = null;
            // Release the sky plane object.
            SkyPlane?.ShurDown();
            SkyPlane = null;
            // Release the sky dome shader object.
            SkyDomeShader?.ShutDown();
            SkyDomeShader = null;
            // Release the sky dome object.
            SkyDome?.ShutDown();
            SkyDome = null;
            // Release the terrain shader object.
            TerrainShader?.ShutDown();
            TerrainShader = null;
            // Release the tree object.
            TerrainModel?.ShutDown();
            TerrainModel = null;
            // Release the input object.
            Input?.Shutdown();
            Input = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
예제 #3
0
파일: Water.cs 프로젝트: jaisrael1/Grow
    // Use this for initialization
    public void init(Hex h, EnvironmentManager em)
    {
        this.em = em;
        this.h  = h;
        this.c  = em.c;
        this.transform.localPosition = h.transform.localPosition;
        var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);

        model = modelObject.AddComponent <WaterModel>();
        model.init(this);
        //this.transform.localScale = this.transform.localScale * .3f;
        h.waterInit(this);
    }
        public bool Frame(float frameTime)
        {
            // Update the system stats.
            FPS.Frame();
            CPU.Frame();

            // Update the FPS value in the text object.
            if (!Text.SetFps(FPS.FPS, D3D.DeviceContext))
            {
                return(false);
            }

            // Update the CPU usage value in the text object.
            if (!Text.SetCpu(CPU.CPUUsage, D3D.DeviceContext))
            {
                return(false);
            }

            // Do the frame input processing.
            if (!HandleInput(frameTime))
            {
                return(false);
            }

            // Do the water frame processing.
            WaterModel.Frame();

            // Do the sky plane frame processing.
            SkyPlane.Frame();

            // Render the refraction of the scene to a texture.
            if (!RenderRefractionToTexture())
            {
                return(false);
            }

            // Render the reflection of the scene to a texture.
            if (!RenderReflectionToTexture())
            {
                return(false);
            }

            // Render the graphics.
            if (!Render())
            {
                return(false);
            }

            return(true);
        }
예제 #5
0
        public void TestSimpleDataServiceGetSingleWaterModelWithID()
        {
            Guid idNotExists = Guid.NewGuid();
            Guid idExists    = Guid.Parse("2a3eeecf-472c-4b0f-9df0-73386cb3b3f7");

            SimpleDataService <WaterModel> simpleService = new SimpleDataService <WaterModel>(_connection, "WaterModels");

            WaterModel result = simpleService.GetItemAsync(idNotExists).Result;

            Assert.Null(result);

            result = simpleService.GetItemAsync(idExists).Result;

            Assert.NotNull(result);

            Assert.True(result.Id == idExists);
        }
예제 #6
0
        // Gets a list of water sensors that the user has
        // Same as the old GetAllUnitsByAccuntId method in base controller
        public List <WaterModel> getAllWaterSensors(string email, string pw)
        {
            List <WaterModel> temp = new List <WaterModel>();
            IRestResponse     res  = CreateClient("https://api.remoni.com/v1/Data?orderby=Timestamp&Timestamp=ge(2018-08-04)&Timestamp=lt(2018-08-09)&UnitId=eq(1502)&AggregateType=eq(Day)&top=10000", email, pw);
            dynamic           conv = JsonConvert.DeserializeObject(res.Content);

            for (int i = 0; i < conv.Count; i++)
            {
                var data = new WaterModel
                {
                    DataType    = conv[i].DataType,
                    Temperature = conv[i].Value,
                    timeStamp   = conv[i].Timestamp
                };
                temp.Add(data);
            }
            return(temp);
        }
예제 #7
0
        public JsonResult GetWaterCurrentStatus(int id, string email, string password, string date1)
        {
            var myUrl = "https://api.remoni.com/v1/Data?orderby=Timestamp&Timestamp=ge(" + date1 + ")&Timestamp = lt()&UnitId=eq(" + id + ")&AggregateType=eq(Raw)&top=2";

            List <WaterModel> temp             = new List <WaterModel>();
            RemoniDataAccess  RemoniDataAccess = new RemoniDataAccess();
            IRestResponse     response         = RemoniDataAccess.ExecuteClient(myUrl, email, password);

            dynamic conv = JsonConvert.DeserializeObject(response.Content);

            for (int i = 0; i < conv.Count; i++)
            {
                var data = new WaterModel
                {
                    DataType    = conv[i].DataType,
                    Temperature = conv[i].Value,
                    timeStamp   = conv[i].Timestamp
                };
                temp.Add(data);
            }
            return(Json(temp, JsonRequestBehavior.AllowGet));
        }
예제 #8
0
        public void Shutdown()
        {
            // Release the light object.
            Light = null;
            // Release the camera object.
            Camera = null;

            // Release the water shader object.
            WaterShader?.ShutDown();
            WaterShader = null;
            // Release the refraction shader object.
            RefractionShader?.ShutDown();
            RefractionShader = null;
            /// Release the render to texture object.
            RenderReflectionTexture?.Shutdown();
            RenderReflectionTexture = null;
            // Release the render to texture object.
            RenderRefractionTexture?.Shutdown();
            RenderRefractionTexture = null;
            // Release the light shader object.
            LightShader?.ShutDown();
            LightShader = null;
            // Release the model object.
            GroundModel?.Shutdown();
            GroundModel = null;
            // Release the model object.
            WallModel?.Shutdown();
            WallModel = null;
            // Release the model object.
            BathModel?.Shutdown();
            BathModel = null;
            // Release the model object.
            WaterModel?.Shutdown();
            WaterModel = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
        private bool Render()
        {
            // Clear the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Get the world, view, projection, ortho, base view and reflection matrices from the camera and Direct3D objects.
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix viewCameraMatrix = Camera.ViewMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;
            Matrix orthoMatrix      = D3D.OrthoMatrix;
            Matrix baseViewMatrix   = Camera.BaseViewMatrix;
            Matrix reflectionMatrix = Camera.ReflectionViewMatrix;

            // Get the position of the camera.
            Vector3 cameraPosition = Camera.GetPosition();

            // Translate the sky dome to be centered around the camera position.
            Matrix.Translation(cameraPosition.X, cameraPosition.Y, cameraPosition.Z, out worldMatrix);

            // Turn off back face culling and the Z buffer.
            D3D.TurnOffCulling();
            D3D.TurnZBufferOff();

            // Render the sky dome using the sky dome shader.
            SkyDome.Render(D3D.DeviceContext);
            if (!SkyDomeShader.Render(D3D.DeviceContext, SkyDome.IndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, SkyDome.ApexColour, SkyDome.CenterColour))
            {
                return(false);
            }

            // Turn back face culling back on.
            D3D.TurnOnCulling();

            // Enable additive blending so the clouds blend with the sky dome color.
            D3D.EnableSecondBlendState();

            // Render the sky plane using the sky plane shader.
            SkyPlane.Render(D3D.DeviceContext);
            if (!SkyPlaneShader.Render(D3D.DeviceContext, SkyPlane.IndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, SkyPlane.CloudTexture.TextureResource, SkyPlane.PerturbTexture.TextureResource, SkyPlane.m_Translation, SkyPlane.m_Scale, SkyPlane.m_Brightness))
            {
                return(false);
            }

            // Turn off blending.
            D3D.TurnOffAlphaBlending();

            // Turn the Z buffer back on.
            D3D.TurnZBufferOn();

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Render the terrain using the terrain shader.
            TerrainModel.Render(D3D.DeviceContext);
            if (!TerrainShader.Render(D3D.DeviceContext, TerrainModel.IndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, TerrainModel.ColorTexture.TextureResource, TerrainModel.NormalMapTexture.TextureResource, Light.DiffuseColour, Light.Direction, 2.0f))
            {
                return(false);
            }

            // Translate to the location of the water and render it.
            Matrix.Translation(240.0f, WaterModel.WaterHeight, 250.0f, out worldMatrix);
            WaterModel.Render(D3D.DeviceContext);
            if (!WaterShader.Render(D3D.DeviceContext, WaterModel.IndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, reflectionMatrix, ReflectionTexture.ShaderResourceView, RefractionTexture.ShaderResourceView, WaterModel.Texture.TextureResource, Camera.GetPosition(), WaterModel.NormalMapTiling, WaterModel.WaterTranslation, WaterModel.ReflectRefractScale, WaterModel.RefractionTint, Light.Direction, WaterModel.SpecularShininess))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Turn off the Z buffer to begin all 2D rendering.
            D3D.TurnZBufferOff();

            // Turn on the alpha blending before rendering the text.
            D3D.TurnOnAlphaBlending();

            // Render the text user interface elements.
            Text.Render(D3D.DeviceContext, worldMatrix, orthoMatrix);

            // Turn off alpha blending after rendering the text.
            D3D.TurnOffAlphaBlending();

            // Turn the Z buffer back on now that all 2D rendering has completed.
            D3D.TurnZBufferOn();

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
예제 #10
0
        private bool RenderScene()
        {
            // Generate the view matrix based on the camera position.
            Camera.Render();

            // Get the world, view, and projection matrices from camera and d3d objects.
            var viewMatrix       = Camera.ViewMatrix;
            var worldMatrix      = D3D.WorldMatrix;
            var projectionMatrix = D3D.ProjectionMatrix;

            #region Render Ground Model
            // Translate to where the ground model will be rendered.
            Matrix.Translation(0f, 1f, 0f, out worldMatrix);

            // Put the ground model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            GroundModel.Render(D3D.DeviceContext);

            // Render the ground model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, GroundModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Wall Model
            // Translate to where the ground model will be rendered.
            Matrix.Translation(0f, 6f, 8f, out worldMatrix);

            // Put the wall model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            WallModel.Render(D3D.DeviceContext);

            // Render the wall model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, WallModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, WallModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Bath Model
            // Translate to where the bath model will be rendered.
            Matrix.Translation(0f, 2f, 0f, out worldMatrix);

            // Put the bath model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            BathModel.Render(D3D.DeviceContext);

            // Render the bath model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, BathModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, BathModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Water Model
            // Get the camera reflection view matrix.
            var reflectionMatrix = Camera.ReflectionViewMatrix;

            // Translate to where the water model will be rendered.
            Matrix.Translation(0f, WaterHeight, 0f, out worldMatrix);

            // Put the water model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            WaterModel.Render(D3D.DeviceContext);

            // Render the bath model using the light shader.
            if (!WaterShader.Render(D3D.DeviceContext, WaterModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, RenderReflectionTexture.ShaderResourceView, RenderRefractionTexture.ShaderResourceView, WaterModel.TextureCollection.Select(item => item.TextureResource).First(), WaterTranslation, 0.1f)) // was 0.01f for scale originally.
            {
                return(false);
            }
            #endregion

            return(true);
        }
예제 #11
0
 public WaterView(WaterModel waterModel, Canvas canvas)
 {
     WaterModel = waterModel;
     _canvas    = canvas;
 }
예제 #12
0
    public Block[] LoadBlocks(TextureManager textures, BlockManager alreadyLoadedBlocks, ModelManager models, int startingId)
    {
        Bounds standardBounds = new Bounds(Vector3.one / 2, Vector3.one * 1.001f);

        List <Block> blockList = new List <Block>();

        uint dirtTexture      = textures.GetTextureOrDefault("Base/Textures/Dirt");
        uint grassTopTexture  = textures.GetTextureOrDefault("Base/Textures/GrassTop");
        uint grassSideTexture = textures.GetTextureOrDefault("Base/Textures/GrassSide");
        uint stoneTexture     = textures.GetTextureOrDefault("Base/Textures/Stone");
        uint woodSideTexture  = textures.GetTextureOrDefault("Base/Textures/Wood");
        uint woodTopTexture   = textures.GetTextureOrDefault("Base/Textures/WoodTop");
        uint leavesTexture    = textures.GetTextureOrDefault("Base/Textures/Leaf");

        blockList.Add(new Block(startingId++, "Base/Block/Dirt", "Dirt", new Model(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            dirtTexture, dirtTexture, dirtTexture, dirtTexture, dirtTexture, dirtTexture
        }), standardBounds));

        Block grass = new Block(startingId++, "Base/Block/Grass", "Grass", new Model(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            grassSideTexture, grassSideTexture, grassSideTexture, grassSideTexture, grassTopTexture, dirtTexture
        }), standardBounds);

        blockList.Add(grass);

        blockList.Add(new Block(startingId++, "Base/Block/Stone", "Stone", new Model(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            stoneTexture, stoneTexture, stoneTexture, stoneTexture, stoneTexture, stoneTexture
        }), standardBounds));

        blockList.Add(new Block(startingId++, "Base/Block/Oak Wood", "Oak Wood", new Model(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            woodSideTexture, woodSideTexture, woodSideTexture, woodSideTexture, woodTopTexture, woodTopTexture
        }), standardBounds));

        blockList.Add(new Block(startingId++, "Base/Block/Oak Leaves", "Oak Leaves", new Model(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            leavesTexture, leavesTexture, leavesTexture, leavesTexture, leavesTexture, leavesTexture
        }, false), standardBounds));

        uint sandTexture = TextureManager.Inst.GetTextureOrDefault("Base/Textures/Sand");

        blockList.Add(new Block(startingId++, "Base/Block/Sand", "Sand", new Model(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            sandTexture, sandTexture, sandTexture, sandTexture, sandTexture, sandTexture
        }), standardBounds));

        uint sandStoneTexture = TextureManager.Inst.GetTextureOrDefault("Base/Textures/Sandstone");

        blockList.Add(new Block(startingId++, "Base/Block/Sandstone", "Sandstone", new Model(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            sandStoneTexture, sandStoneTexture, sandStoneTexture, sandStoneTexture, sandStoneTexture, sandStoneTexture
        }), standardBounds));

        uint iceTexture = TextureManager.Inst.GetTextureOrDefault("Base/Textures/Ice");

        blockList.Add(new Block(startingId++, "Base/Block/Ice", "Ice", new Model(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            iceTexture, iceTexture, iceTexture, iceTexture, iceTexture, iceTexture
        }), standardBounds));

        blockList.Add(new PlantBlock(startingId++, "Base/Block/GrassPlant", "Grass", new Model(models.GetEntryOrDefault("Base/Model/Cross"), new uint[] {
            textures.GetTextureOrDefault("Base/Textures/GrassPlant")
        }), new Bounds(new Vector3(0.5f, 0.375f, 0.5f), new Vector3(0.75f, 0.75f, 0.75f)), false, true, new Block[] { grass }));

        blockList.Add(new PlantBlock(startingId++, "Base/Block/Poppy", "Poppy", new Model(models.GetEntryOrDefault("Base/Model/Cross"), new uint[]
        {
            textures.GetTextureOrDefault("Base/Textures/PoppyPlant")
        }, false), new Bounds(new Vector3(0.5f, 0.421875f, 0.5f), new Vector3(0.34375f, 0.78125f, 0.34375f)), false, false, new Block[] { grass }));

        blockList.Add(new PlantBlock(startingId++, "Base/Block/Dandelion", "Dandelion", new Model(models.GetEntryOrDefault("Base/Model/Cross"), new uint[]
        {
            textures.GetTextureOrDefault("Base/Textures/DandelionPlant")
        }, false), new Bounds(new Vector3(0.5f, 0.328125f, 0.5f), new Vector3(0.375f, 0.625f, 0.375f)), false, false, new Block[] { grass }));

        uint       waterTexture = textures.GetTextureOrDefault("Base/Textures/Water");
        WaterModel waterModel   = new WaterModel(models.GetEntryOrDefault("Base/Model/Solid"), new uint[] {
            waterTexture, waterTexture, waterTexture, waterTexture, waterTexture, waterTexture,
            waterTexture, waterTexture, waterTexture, waterTexture, waterTexture, waterTexture
        });
        Block waterBlock = new Block(startingId++, "Base/Block/Water", "Water", waterModel, standardBounds, true, true, true);

        waterModel.SetWater(waterBlock);
        blockList.Add(waterBlock);

        return(blockList.ToArray());
    }