public IHttpActionResult PutBillboardModel(int id, BillboardModel billboardModel)
        {
            if (id != billboardModel.id)
            {
                return(BadRequest());
            }

            db.Entry(billboardModel).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BillboardModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostBillboardModel(BillboardModel billboardModel)
        {
            db.BillboardModels.Add(billboardModel);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = billboardModel.id }, billboardModel));
        }
        public bool Render()
        {
            // Clear the buffers to begin the scene.
            D3D.BeginScene(0, 0, 0, 1f);

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

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

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

            // Render the floor model using the texture shader.
            if (!TextureShader.Render(D3D.DeviceContext, FloorModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, FloorModel.GetTexture()))
            {
                return(false);
            }

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

            // Set the position of the billboard model.
            Vector3 modelPosition = new Vector3();

            modelPosition.X = 0.0f;
            modelPosition.Y = 1.5f;
            modelPosition.Z = 0.0f;

            // Calculate the rotation that needs to be applied to the billboard model to face the current camera position using the arc tangent function.
            double angle = Math.Atan2(modelPosition.X - cameraPosition.X, modelPosition.Z - cameraPosition.Z) * (180.0f / Math.PI);
            // Convert rotation into radians.
            float rotation = (float)angle * 0.0174532925f;

            // Setup the rotation the billboard at the origin using the world matrix.
            Matrix.RotationY(rotation, out worldMatrix);
            // Setup the translation matrix from the billboard model.
            Matrix translationMatrix = Matrix.Translation(modelPosition.X, modelPosition.Y, modelPosition.Z);

            // Finally combine the rotation and translation matrices to create the final world matrix for the billboard model.
            Matrix.Multiply(ref worldMatrix, ref translationMatrix, out worldMatrix);

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

            // Render the model using the texture shader.
            if (!TextureShader.Render(D3D.DeviceContext, BillboardModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, BillboardModel.GetTexture()))
            {
                return(false);
            }

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

            return(true);
        }
        public IHttpActionResult DeleteBillboardModel(int id)
        {
            BillboardModel billboardModel = db.BillboardModels.Find(id);

            if (billboardModel == null)
            {
                return(NotFound());
            }

            db.BillboardModels.Remove(billboardModel);
            db.SaveChanges();

            return(Ok(billboardModel));
        }
        public Instance3D(BillboardModel bb)
        {
            int texture_index = MdxRender.SM.m_TextureManager.GetBillboardTextureIndex(bb);

            m_SelectTool      = new SelectTool();
            m_Model           = MdxRender.MM.ArrowModel;
            m_BillboardMatrix = new Matrix();
            billboard         = new Billboard(0.5f, 0.5f, texture_index);
            UpdateTransform();
            objectColor.Ambient     = Color.Gray;
            objectColor.Diffuse     = Color.White;
            fullBrightColor.Ambient = Color.White;
            fullBrightColor.Diffuse = Color.White;
            bBillboardMode          = true;
            billboardCount++;
        }
        //todo - permissions
        public ActionResult UploadBillboardImage(FormCollection formCollection, BillboardModel model)
        {
            if (Request != null && Request.Files.Count == 1)
            {
                string targetFilePath = Utilities.GetDaikinCityDirectory() + "images\\" + model.SinglePoster.image;
                //bool fileExists = System.IO.File.Exists(targetFilePath);

                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0 && file.ContentType == "image/jpeg")
                {
                    file.SaveAs(targetFilePath);
                }
            }
            return(RedirectToAction("HomeScreen"));
        }
        public void Shutdown()
        {
            // Release the camera object.
            Camera = null;

            // Release the texture shader object.
            TextureShader?.ShutDown();
            TextureShader = null;
            // Release the Floor model object.
            FloorModel?.Shutdown();
            FloorModel = null;
            // Release the Billboard model object.
            BillboardModel?.Shutdown();
            BillboardModel = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
示例#8
0
        public int GetBillboardTextureIndex(BillboardModel bm)
        {
            int texture_index = BillboardBaseIndex + (int)bm;

            return(texture_index);
        }