Ejemplo n.º 1
0
 public AddVehiculeController()
 {
     veh  = new MVehiculo();
     mec  = new MMecanico();
     mod  = new MModelo();
     prov = new MProveedor();
 }
        /// <summary>
        /// Draw.
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="render">The render.</param>
        /// <param name="camera">The camera.</param>
        /// <param name="lights">The lights.</param>
        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera camera, IList <ILight> lights)
        {
            IModelo modelo = obj.Modelo;

            IdParameter.SetValue(shaderId);
            SpecularIntensityParameter.SetValue(specularIntensity);
            SpecularPowerParameter.SetValue(specularPower);
            ViewProjectionParameter.SetValue(camera.ViewProjection);

            for (int i = 0; i < modelo.MeshNumber; i++)
            {
                BatchInformation[] bi = modelo.GetBatchInformation(i);
                for (int j = 0; j < bi.Count(); j++)
                {
                    if (useAmbientCubeMap)
                    {
                        render.Textures[4] = modelo.GetCubeTexture(TextureType.AMBIENT_CUBE_MAP, i, j);
                        //PAmbientCubeTexture.SetValue(modelo.GetCubeTexture(TextureType.AMBIENT_CUBE_MAP, i, j));
                        PAmbientCubeMapScale.SetValue(AmbientCubeMapScale);
                    }
                    render.Textures[0] = modelo.getTexture(TextureType.DIFFUSE, i, j);
                    //TextureParameter.SetValue(modelo.getTexture(TextureType.DIFFUSE,i,j));
                    WorldParameter.SetValue(bi[j].ModelLocalTransformation * obj.WorldMatrix);
                    render.RenderBatch(bi[j], _shader);
                }
            }
        }
Ejemplo n.º 3
0
 public VehiculoController()
 {
     vehi = new MVehiculo();
     mode = new MModelo();
     marc = new MMarca();
     rent = new MRenta();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="MobileMeshObject "/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="pos">The pos.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="materialDescription">The material description.</param>
        /// <param name="MobileMeshSolidity">The mobile mesh solidity.</param>
        /// <param name="mass">The mass.</param>
        public MobileMeshObject(IModelo model, Vector3 pos, Matrix?rotation = null, Vector3?scale = null, MaterialDescription materialDescription = null, MobileMeshSolidity MobileMeshSolidity = MobileMeshSolidity.Solid, float mass = 10)
        {
            if (materialDescription == null)
            {
                materialDescription = MaterialDescription.DefaultBepuMaterial();
            }

            if (!rotation.HasValue)
            {
                rotation = Matrix.Identity;
            }

            if (!scale.HasValue)
            {
                scale = Vector3.One;
            }


            System.Diagnostics.Debug.Assert(scale != Vector3.Zero);
            System.Diagnostics.Debug.Assert(model != null);

            this.scale = scale.Value;
            Vector3[] vertices = null;
            int[]     indices  = null;
            ExtractData(ref vertices, ref indices, model);
            triangleGroup          = new MobileMesh(vertices, indices, new AffineTransform(scale.Value, Quaternion.CreateFromRotationMatrix(rotation.Value), pos), MobileMeshSolidity, mass);
            triangleGroup.Material = new BEPUphysics.Materials.Material(materialDescription.StaticFriction, materialDescription.DynamicFriction, materialDescription.Bounciness);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public virtual void Initialize(GraphicInfo ginfo, GraphicFactory factory, IObject obj)
        {
            #if !WINDOWS_PHONE && !REACH
            basicDraw             = factory.GetEffect("clippingPlane", false, true);
            getDepth              = factory.GetEffect("ShadowDepth", false, true);
            BasicDrawSamplerState = SamplerState.LinearWrap;
            #endif
            if (useOcclusionCulling)
            {
                if (Modelo == null)
                {
                    Modelo = new SimpleModel(factory, "block", true);
                }

                if (BasicEffect == null)
                {
                    BasicEffect = factory.GetBasicEffect();
                    BasicEffect.TextureEnabled     = false;
                    BasicEffect.VertexColorEnabled = false;
                }

                if (BlendState == null)
                {
                    BlendState = new Microsoft.Xna.Framework.Graphics.BlendState();
                    BlendState.ColorWriteChannels = ColorWriteChannels.None;
                }
                OcclusionQuery     = factory.CreateOcclusionQuery();
                OcclusionQuery.Tag = "Begin";
            }
            this.GraphicFactory = factory;
            isInitialized       = true;
        }
Ejemplo n.º 6
0
 public ControladorMV(object mdlo) : this()
 {
     if (mdlo != null)
     {
         this.modelo = crearModelo(mdlo);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TriangleMeshObject"/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="pos">The pos.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="materialDescription">The material description.</param>
        public TriangleMeshObject(IModelo model, Vector3 pos, Matrix?rotation = null, Vector3?scale = null, MaterialDescription materialDescription = null)
        {
            if (materialDescription == null)
            {
                materialDescription = MaterialDescription.DefaultBepuMaterial();
            }

            if (!rotation.HasValue)
            {
                rotation = Matrix.Identity;
            }

            if (!scale.HasValue)
            {
                scale = Vector3.One;
            }

            System.Diagnostics.Debug.Assert(model != null);
            System.Diagnostics.Debug.Assert(scale != Vector3.Zero);

            this.rotation = rotation.Value;
            this.scale    = scale.Value;
            this.position = pos;
            Vector3[] vertices = null;
            int[]     indices  = null;
            ExtractData(ref vertices, ref indices, model);
            triangleGroup          = new StaticMesh(vertices, indices, new AffineTransform(scale.Value, Quaternion.CreateFromRotationMatrix(rotation.Value), position));
            faceVector             = Vector3.Transform(Vector3.Forward, triangleGroup.WorldTransform.Matrix);
            triangleGroup.Material = new BEPUphysics.Materials.Material(materialDescription.StaticFriction, materialDescription.DynamicFriction, materialDescription.Bounciness);
        }
Ejemplo n.º 8
0
 public RentaController()
 {
     vehi  = new MVehiculo();
     mode  = new MModelo();
     rent  = new MRenta();
     trans = new MTransmicion();
 }
 /// <summary>
 /// Return the Instanced MEsh shape from a IModelo
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static InstancedMeshShape GetInstacedMesh(IModelo model)
 {
     Vector3[] vertices = null;
     int[]     indices  = null;
     ExtractData(ref vertices, ref indices, model);
     return(new InstancedMeshShape(vertices, indices));
 }
Ejemplo n.º 10
0
 public virtual void EstablecerModelo(object mdlo)
 {
     if (mdlo != null)
     {
         this.modelo = crearModelo(mdlo);
     }
 }
 public ControladorIncremento(IVista vista, IModelo modelo)
 {
     _vista = vista;
     _modelo = modelo;
     vista.SetControlador(this);
     modelo.Adjuntar((IModeloObservador)_vista);
     _vista.cambiada += new VistaHandler<IVista>(this.vista_cambiada);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IObject"/> class.
        /// </summary>
        /// <param name="Material">The material. (cannot be null, use the InvisibleMaterial.GetInstance when you dont need Material)</param>
        /// <param name="Modelo">The modelo. (can be null)</param>
        /// <param name="PhysicObject">The physic object. (cannot be null)</param>
        /// <param name="name">The name of the IObject (just an identifier).</param>
        public IObject(IMaterial Material, IModelo Modelo, IPhysicObject PhysicObject, String name = null)
        {
            System.Diagnostics.Debug.Assert(Material != null);
            System.Diagnostics.Debug.Assert(PhysicObject != null);

            this.Material     = Material;
            this.Modelo       = Modelo;
            this.PhysicObject = PhysicObject;
            this.Name         = name;
            IObjectAttachment = new List <IObjectAttachment>();

            if (this.Modelo == null && this.Material != null)
            {
                Material.IsVisible = false;
#if !WINDOWS_PHONE && !REACH
                Material.CanAppearOfReflectionRefraction = false;
                Material.CanCreateShadow = false;
#endif
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PhysxTriangleMesh"/> class.
        /// Cooks the Model on the fly
        /// </summary>
        /// <param name="PhysxPhysicWorld">The physx physic world.</param>
        /// <param name="model">The model.</param>
        /// <param name="worldTransformation">The world transformation.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="density">The density.</param>
        /// <param name="material">The material.</param>
        public PhysxTriangleMesh(PhysxPhysicWorld PhysxPhysicWorld, IModelo model, Microsoft.Xna.Framework.Matrix worldTransformation, Microsoft.Xna.Framework.Vector3 scale, float density = 1, StillDesign.PhysX.Material material = null)
        {
            Microsoft.Xna.Framework.Vector3[] vertices = null;
            int[] indices = null;
            ExtractData(ref vertices, ref indices, model);


            TriangleMeshDescription meshDesc = new TriangleMeshDescription();

            meshDesc.AllocateVertices <Microsoft.Xna.Framework.Vector3>(vertices.Count());
            meshDesc.VerticesStream.SetData <Microsoft.Xna.Framework.Vector3>(vertices);
            meshDesc.AllocateTriangles <int>(indices.Count());
            meshDesc.TriangleStream.SetData <int>(indices);
            meshDesc.Flags         = 0;
            meshDesc.VertexCount   = vertices.Count();
            meshDesc.TriangleCount = indices.Count();

            MemoryStream ms = new MemoryStream();

            Cooking.InitializeCooking();
            if (Cooking.CookTriangleMesh(meshDesc, ms) == false)
            {
                PloobsEngine.Engine.Logger.ActiveLogger.LogMessage("Cant Cook Model", Engine.Logger.LogLevel.FatalError);
            }
            Cooking.CloseCooking();

            ms.Position = 0;
            TriangleMesh triangleMesh = PhysxPhysicWorld.Core.CreateTriangleMesh(ms);
            TriangleMeshShapeDescription bunnyShapeDesc = new TriangleMeshShapeDescription();

            if (material != null)
            {
                bunnyShapeDesc.Material = material;
            }
            bunnyShapeDesc.TriangleMesh = triangleMesh;
            ActorDesc = new ActorDescription();
            ActorDesc.Shapes.Add(bunnyShapeDesc);
            ActorDesc.BodyDescription = null;
            ActorDesc.GlobalPose      = worldTransformation.AsPhysX();
            this.Scale = scale;
        }
Ejemplo n.º 14
0
        public BulletTriangleMesh(IModelo model, Vector3 pos, Matrix rotation, Vector3 scale)
        {
            TriangleMesh TriangleMesh = new BulletSharp.TriangleMesh(true, false);

            Vector3[] vertices = null;
            int[]     indices  = null;
            ExtractData(ref vertices, ref indices, model);
            for (int i = 0; i < indices.Count(); i += 3)
            {
                TriangleMesh.AddTriangle(vertices[indices[i]], vertices[indices[i + 1]], vertices[indices[i + 2]]);
            }
            vertices = null;
            indices  = null;

            BvhTriangleMeshShape = new BvhTriangleMeshShape(TriangleMesh, true, true);
            this.Shape           = BvhTriangleMeshShape;

            this.Scale         = scale;
            Shape.LocalScaling = scale;
            Object             = LocalCreateRigidBody(0, Matrix.CreateTranslation(pos) * rotation, Shape);
        }
        public static void CookTriangleMesh(PhysxPhysicWorld PhysxPhysicWorld, IModelo model, FileStream FileStream)
        {
            Microsoft.Xna.Framework.Vector3[] vertices = null;
            int[] indices = null;
            ExtractData(ref vertices, ref indices, model);

            TriangleMeshDesc meshDesc = new TriangleMeshDesc();

            Vector3[] points = new Vector3[vertices.Count()];
            for (int i = 0; i < vertices.Count(); i++)
            {
                points[i] = vertices[i].AsPhysX();
            }
            meshDesc.Points = points;
            meshDesc.SetTriangles <int>(indices);

            if (PhysxPhysicWorld.Cooking.CookTriangleMesh(meshDesc, FileStream) == false)
            {
                PloobsEngine.Engine.Logger.ActiveLogger.LogMessage("Cant Cook Model", Engine.Logger.LogLevel.FatalError);
            }
        }
Ejemplo n.º 16
0
        public static void CookTriangleMesh(IModelo model, FileStream FileStream)
        {
            Microsoft.Xna.Framework.Vector3[] vertices = null;
            int[] indices = null;
            ExtractData(ref vertices, ref indices, model);

            TriangleMeshDescription meshDesc = new TriangleMeshDescription();

            meshDesc.AllocateVertices <Microsoft.Xna.Framework.Vector3>(vertices.Count());
            meshDesc.VerticesStream.SetData <Microsoft.Xna.Framework.Vector3>(vertices);
            meshDesc.AllocateTriangles <int>(indices.Count());
            meshDesc.TriangleStream.SetData <int>(indices);
            meshDesc.Flags         = 0;
            meshDesc.VertexCount   = vertices.Count();
            meshDesc.TriangleCount = indices.Count();

            Cooking.InitializeCooking();
            if (Cooking.CookTriangleMesh(meshDesc, FileStream) == false)
            {
                PloobsEngine.Engine.Logger.ActiveLogger.LogMessage("Cant Cook Model", Engine.Logger.LogLevel.FatalError);
            }
            Cooking.CloseCooking();
        }
        public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
        {
            rHelper.PushRenderTarget(target);
            rHelper.Clear(Color.Black);
            effectdistorcion.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
            effectdistorcion.Parameters["DEPTH"].SetValue(rHelper[PrincipalConstants.DephRT]);
            effectdistorcion.Parameters["DistortionScale"].SetValue(Distortion);
            rHelper.PushDepthStencilState(DepthStencilState.None);

            foreach (var obj in objs)
            {
                IModelo modelo = obj.Modelo;

                for (int i = 0; i < modelo.MeshNumber; i++)
                {
                    BatchInformation[] bi = modelo.GetBatchInformation(i);
                    for (int j = 0; j < bi.Count(); j++)
                    {
                        Matrix w = bi[j].ModelLocalTransformation * obj.WorldMatrix;
                        effectdistorcion.Parameters["WorldViewProjection"].SetValue(w * world.CameraManager.ActiveCamera.View * world.CameraManager.ActiveCamera.Projection);
                        effectdistorcion.Parameters["WorldView"].SetValue(w * world.CameraManager.ActiveCamera.View);
                        rHelper.RenderBatch(bi[j], effectdistorcion);
                    }
                }
            }

            rHelper.PopDepthStencilState();

            x = rHelper.PopRenderTargetAsSingleRenderTarget2D();

            rHelper.Clear(Color.Black);
            effect.Parameters["SceneTexture"].SetValue(ImageToProcess);
            effect.Parameters["DistortionMap"].SetValue(x);
            //effect.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
            rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, effect, GraphicInfo.FullScreenRectangle);
        }
        public PhysxTriangleMesh(PhysxPhysicWorld PhysxPhysicWorld, IModelo model, Microsoft.Xna.Framework.Matrix localTransformation, Microsoft.Xna.Framework.Matrix worldTransformation, Microsoft.Xna.Framework.Vector3 scale, MaterialDescription MaterialDescription)
        {
            Microsoft.Xna.Framework.Vector3[] vertices = null;
            int[] indices = null;
            ExtractData(ref vertices, ref indices, model);


            TriangleMeshDesc meshDesc = new TriangleMeshDesc();

            Vector3[] points = new Vector3[vertices.Count()];
            for (int i = 0; i < vertices.Count(); i++)
            {
                points[i] = vertices[i].AsPhysX();
            }
            meshDesc.Points = points;
            meshDesc.SetTriangles <int>(indices);
            //meshDesc.Triangles = indices;

            MemoryStream ms = new MemoryStream();

            if (PhysxPhysicWorld.Cooking.CookTriangleMesh(meshDesc, ms) == false)
            {
                PloobsEngine.Engine.Logger.ActiveLogger.LogMessage("Cant Cook Model", Engine.Logger.LogLevel.FatalError);
            }

            ms.Position = 0;
            TriangleMesh triangleMesh = PhysxPhysicWorld.Physix.CreateTriangleMesh(ms);

            staticActor = PhysxPhysicWorld.Physix.CreateRigidStatic(worldTransformation.AsPhysX());
            TriangleMeshGeometry TriangleMeshGeometry = new TriangleMeshGeometry(triangleMesh, new MeshScale(scale.AsPhysX(), Quaternion.Identity));

            material      = PhysxPhysicWorld.Physix.CreateMaterial(MaterialDescription.StaticFriction, MaterialDescription.DynamicFriction, MaterialDescription.Bounciness);
            aTriMeshShape = staticActor.CreateShape(TriangleMeshGeometry, material, localTransformation.AsPhysX());

            this.Scale = scale;
        }
Ejemplo n.º 19
0
 public BaseObject(IMaterial mat, IPhysicObject py, IModelo model)
     : base(mat, model, py)
 {
 }
Ejemplo n.º 20
0
 public ThrowParticlesObject(DefaultSprite3DBillboardParticleSystem particleSystem, IMaterial material, IModelo modelo, IPhysicObject physicObject)
     : base(material, modelo, physicObject)
 {
     this.particleSystem = particleSystem;
 }
        /// <summary>
        /// Helper to get the vertex and index List from the model.
        /// </summary>
        /// <param name="vert">The vert.</param>
        /// <param name="ind">The ind.</param>
        /// <param name="model">The model.</param>
        private void ExtractData(ref Vector3[] vert, ref int[] ind, IModelo model)
        {
            List <Vector3> vertices = new List <Vector3>();
            List <int>     indices  = new List <int>();

            for (int i = 0; i < model.MeshNumber; i++)
            {
                BatchInformation[] bi = model.GetBatchInformation(i);
                for (int j = 0; j < bi.Length; j++)
                {
                    BatchInformation info = bi[j];
                    int       offset      = vertices.Count;
                    Vector3[] a           = new Vector3[info.NumVertices];

                    // Read the format of the vertex buffer
                    VertexDeclaration declaration    = bi[j].VertexBuffer.VertexDeclaration;
                    VertexElement[]   vertexElements = declaration.GetVertexElements();
                    // Find the element that holds the position
                    VertexElement vertexPosition = new VertexElement();
                    foreach (VertexElement elem in vertexElements)
                    {
                        if (elem.VertexElementUsage == VertexElementUsage.Position &&
                            elem.VertexElementFormat == VertexElementFormat.Vector3)
                        {
                            vertexPosition = elem;
                            // There should only be one
                            break;
                        }
                    }
                    // Check the position element found is valid
                    if (vertexPosition == null ||
                        vertexPosition.VertexElementUsage != VertexElementUsage.Position ||
                        vertexPosition.VertexElementFormat != VertexElementFormat.Vector3)
                    {
                        throw new Exception("Model uses unsupported vertex format!");
                    }
                    // This where we store the vertices until transformed
                    // Read the vertices from the buffer in to the array
                    bi[j].VertexBuffer.GetData <Vector3>(
                        bi[j].BaseVertex * declaration.VertexStride + vertexPosition.Offset,
                        a,
                        0,
                        bi[j].NumVertices,
                        declaration.VertexStride);

                    for (int k = 0; k != a.Length; ++k)
                    {
                        Vector3.Transform(ref a[k], ref info.ModelLocalTransformation, out a[k]);
                    }
                    vertices.AddRange(a);

                    if (info.IndexBuffer.IndexElementSize != IndexElementSize.SixteenBits)
                    {
                        int[] s = new int[info.PrimitiveCount * 3];
                        info.IndexBuffer.GetData <int>(info.StartIndex * 2, s, 0, info.PrimitiveCount * 3);
                        for (int k = 0; k != info.PrimitiveCount; ++k)
                        {
                            indices.Add(s[k * 3 + 2] + offset);
                            indices.Add(s[k * 3 + 1] + offset);
                            indices.Add(s[k * 3 + 0] + offset);
                        }
                    }
                    else
                    {
                        short[] s = new short[info.PrimitiveCount * 3];
                        info.IndexBuffer.GetData <short>(info.StartIndex * 2, s, 0, info.PrimitiveCount * 3);
                        for (int k = 0; k != info.PrimitiveCount; ++k)
                        {
                            indices.Add(s[k * 3 + 2] + offset);
                            indices.Add(s[k * 3 + 1] + offset);
                            indices.Add(s[k * 3 + 0] + offset);
                        }
                    }
                }
            }

            ind  = indices.ToArray();
            vert = vertices.ToArray();
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IObject"/> class.
 /// </summary>
 /// <param name="Material">The material.</param>
 /// <param name="Modelo">The modelo.</param>
 /// <param name="PhysicObject">The physic object.</param>
 /// <param name="UserData">The user data.</param>
 public UserObject(IMaterial Material, IModelo Modelo, IPhysicObject PhysicObject, T UserData)
     : base(Material, Modelo, PhysicObject)
 {
     this.UserData = UserData;
 }
Ejemplo n.º 23
0
 public ModeloController(IServiceProvider serviceProvider, IModelo Modelo) : base(serviceProvider)
 {
     _Modelo = Modelo;
 }
Ejemplo n.º 24
0
 public RVO3DObject(int id, IMaterial mat, IModelo model, IPhysicObject py)
     : base(mat, model, py)
 {
     this.RVOID = id;
 }
Ejemplo n.º 25
0
 public ModeloController(IServiceProvider serviceProvider, IModelo Modelo, ILogger <ModeloController> logger) : base(serviceProvider)
 {
     _Modelo = Modelo;
     _logger = logger;
 }
Ejemplo n.º 26
0
 public Presentador(IModelo modelo)
 {
     this.modelo = modelo;
 }
 public void ValorIncrementado(IModelo modelo, ModeloEventArgs e)
 {
     label1.Text = "" + e.valorNuevo;
 }