public void mousebuttontesteRight(MouseState ms)
        {
            PointLightPE pl = new PointLightPE(_mundo.CameraManager.ActiveCamera.Position, StaticRandom.RandomColor(), 100, 5);

            pl.UsePointLightQuadraticAttenuation = true;
            _mundo.AddLight(pl);
        }
Ejemplo n.º 2
0
        protected void DrawPointLight(ICamera camera, IList <ILight> lights, IDeferredGBuffer DeferredGBuffer, RenderHelper render)
        {
            render.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
            render.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
            SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);

            PointcameraPosition.SetValue(camera.Position);

            float _tanFovy = (float)Math.Tan(camera.FieldOfView / 2);

            pointLightEffect.Parameters["TanAspect"].SetValue(new Vector2(_tanFovy * camera.AspectRatio, -_tanFovy));
            pointLightEffect.Parameters["farPlane"].SetValue(camera.FarPlane);

            foreach (ILight item in lights)
            {
                if (item.LightType == LightType.Deferred_Point && item.Enabled == true)
                {
                    PointLightPE pl = item as PointLightPE;
                    Matrix       sphereWorldMatrix = Matrix.CreateScale(pl.LightRadius) * Matrix.CreateTranslation(pl.LightPosition);

                    ContainmentType ct = ContainmentType.Contains;
                    if (cullPointLight)
                    {
                        ct = camera.BoundingFrustum.Contains(new BoundingSphere(pl.LightPosition, pl.LightRadius));
                    }
                    if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects)
                    {
                        //convert light position into viewspace
                        Vector3 viewSpaceLPos = Vector3.Transform(pl.LightPosition, camera.View);

                        PointWordViewProjection.SetValue(sphereWorldMatrix * camera.ViewProjection);
                        PointlightPosition.SetValue(viewSpaceLPos);
                        PointColor.SetValue(pl.Color.ToVector3());
                        PointlightRadius.SetValue(pl.LightRadius);
                        PointlightIntensity.SetValue(pl.LightIntensity);
                        Pointquadratic.SetValue(pl.UsePointLightQuadraticAttenuation);

                        float cameraToCenter = Vector3.Distance(camera.Position, pl.LightPosition);

                        if (cameraToCenter < pl.LightRadius + camera.NearPlane)
                        {
                            render.PushRasterizerState(RasterizerState.CullClockwise);
                        }
                        else
                        {
                            render.PushRasterizerState(RasterizerState.CullCounterClockwise);
                        }

                        render.RenderBatch(sphereModel.GetBatchInformation(0)[0], pointLightEffect);

                        render.PopRasterizerState();
                    }
                }
            }
            render.SetSamplerState(s2, 2);
        }
 public void AddLight(PointLightPE pl,float speed, float radius , float initialAngle) 
 {
     lightProp lp = new lightProp();            
     lp.speedAcumullated = initialAngle;
     lp.pl = pl;
     lp.center = pl.LightPosition;
     lp.speed = speed;
     lp.radius = radius;
     lights.Add(lp);
 }
        public void AddLight(PointLightPE pl, float speed, float radius, float initialAngle)
        {
            lightProp lp = new lightProp();

            lp.speedAcumullated = initialAngle;
            lp.pl     = pl;
            lp.center = pl.LightPosition;
            lp.speed  = speed;
            lp.radius = radius;
            lights.Add(lp);
        }
Ejemplo n.º 5
0
        protected void DrawPointLight(ICamera camera, IList <ILight> lights, IDeferredGBuffer DeferredGBuffer, RenderHelper render)
        {
            render.device.Textures[0] = DeferredGBuffer[GBufferTypes.COLOR];
            render.device.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
            render.device.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
            SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);

            PointProjection.SetValue(camera.Projection);
            PointView.SetValue(camera.View);
            PointcameraPosition.SetValue(camera.Position);
            PointInvertViewProjection.SetValue(Matrix.Invert(camera.ViewProjection));

            foreach (ILight item in lights)
            {
                if (item.LightType == LightType.Deferred_Point && item.Enabled == true)
                {
                    PointLightPE pl = item as PointLightPE;
                    Matrix       sphereWorldMatrix = Matrix.CreateScale(pl.LightRadius) * Matrix.CreateTranslation(pl.LightPosition);

                    ContainmentType ct = ContainmentType.Contains;
                    if (cullPointLight)
                    {
                        ct = camera.BoundingFrustum.Contains(new BoundingSphere(pl.LightPosition, pl.LightRadius));
                    }
                    if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects)
                    {
                        PointWorld.SetValue(sphereWorldMatrix);
                        PointlightPosition.SetValue(pl.LightPosition);
                        PointColor.SetValue(pl.Color.ToVector3());
                        PointlightRadius.SetValue(pl.LightRadius);
                        PointlightIntensity.SetValue(pl.LightIntensity);
                        Pointquadratic.SetValue(pl.UsePointLightQuadraticAttenuation);

                        float cameraToCenter = Vector3.Distance(camera.Position, pl.LightPosition);

                        if (cameraToCenter < pl.LightRadius + camera.NearPlane)
                        {
                            render.PushRasterizerState(RasterizerState.CullClockwise);
                        }
                        else
                        {
                            render.PushRasterizerState(RasterizerState.CullCounterClockwise);
                        }

                        render.RenderBatch(sphereModel.GetBatchInformation(0)[0], pointLightEffect);

                        render.PopRasterizerState();
                    }
                }
            }
            render.SetSamplerState(s2, 2);
        }
Ejemplo n.º 6
0
        protected override void  LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ///Create a Simple Model
            IModelo sm = new SimpleModel(factory, "..\\Content\\Model\\cenario");
            ///Create a Physic Object
            IPhysicObject pi = new TriangleMeshObject(sm, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());

            pi.isMotionLess = true;
            ///Create a shader
            IShader shader = new DeferredNormalShader();
            ///Create a Material
            IMaterial mat = new DeferredMaterial(shader);
            ///Create a an Object that englobs everything and add it to the world
            IObject obj4 = new IObject(mat, sm, pi);

            this.World.AddObject(obj4);

            lt = new LightThrowBepu(this.World, factory);

            ///Create a FirstPerson Camera
            ///This is a special camera, used in the development
            ///You can move around using wasd / qz / and the mouse
            ICamera cam = new CameraFirstPerson(GraphicInfo);

            this.World.CameraManager.AddCamera(cam);

            PointLightCircularUpdater lcu = new PointLightCircularUpdater(this);

            ///Create 100 moving point lights and add to the world
            ///IF the radius of the point light is TOO big like 250, it will make the game slower
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PointLightPE pl0 = new PointLightPE(new Vector3(i * 5, 25, j * 5), StaticRandom.RandomColor(), 100, 2);
                    pl0.UsePointLightQuadraticAttenuation = true;
                    lcu.AddLight(pl0, 0.01f, 50 * i, j / StaticRandom.Random());
                    this.World.AddLight(pl0);
                }
            }

            lcu.Start();
            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        protected override void  LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
 	        base.LoadContent(GraphicInfo, factory, contentManager);     

            ///Create a Simple Model
            IModelo sm = new SimpleModel(factory, "..\\Content\\Model\\cenario");            
            ///Create a Physic Object
            IPhysicObject pi = new TriangleMeshObject(sm, Vector3.Zero, Matrix.Identity, Vector3.One,MaterialDescription.DefaultBepuMaterial());
            pi.isMotionLess = true;
            ///Create a shader 
            IShader shader = new DeferredNormalShader();            
            ///Create a Material
            IMaterial mat = new DeferredMaterial(shader);
            ///Create a an Object that englobs everything and add it to the world
            IObject obj4 = new IObject(mat, sm,pi);
            this.World.AddObject(obj4);

            lt = new LightThrowBepu(this.World, factory);  

            ///Create a FirstPerson Camera
            ///This is a special camera, used in the development
            ///You can move around using wasd / qz / and the mouse
            ICamera cam = new CameraFirstPerson(GraphicInfo);
            this.World.CameraManager.AddCamera(cam);

            PointLightCircularUpdater lcu = new PointLightCircularUpdater(this);

            ///Create 100 moving point lights and add to the world
            ///IF the radius of the point light is TOO big like 250, it will make the game slower
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PointLightPE pl0 = new PointLightPE(new Vector3(i * 5, 25, j * 5), StaticRandom.RandomColor(), 100, 2);
                    pl0.UsePointLightQuadraticAttenuation = true;
                    lcu.AddLight(pl0, 0.01f, 50 * i, j / StaticRandom.Random());                    
                    this.World.AddLight(pl0);
                }
            }

            lcu.Start();
            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        private void DrawPointLight(RenderHelper render, GraphicInfo ginfo, ICamera camera, PointLightPE pl, IDeferredGBuffer DeferredGBuffer,bool cullPointLight)
        {

                    pointLightEffect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
                    render.device.Textures[0] = DeferredGBuffer[GBufferTypes.COLOR];
                    render.device.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
                    render.device.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
                    SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);

                    pointLightEffect.Parameters["Projection"].SetValue(camera.Projection);
                    pointLightEffect.Parameters["View"].SetValue(camera.View);
                    pointLightEffect.Parameters["cameraPosition"].SetValue(camera.Position);
                    pointLightEffect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(camera.ViewProjection));

                    
                    Matrix sphereWorldMatrix = Matrix.CreateScale(pl.LightRadius) * Matrix.CreateTranslation(pl.LightPosition);

                    ContainmentType ct = ContainmentType.Contains;
                    if (cullPointLight)
                        ct = camera.BoundingFrustum.Contains(new BoundingSphere(pl.LightPosition, pl.LightRadius));
                    if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects)
                    {
                        pointLightEffect.Parameters["World"].SetValue(sphereWorldMatrix);
                        pointLightEffect.Parameters["lightPosition"].SetValue(pl.LightPosition);
                        pointLightEffect.Parameters["Color"].SetValue(pl.Color.ToVector3());
                        pointLightEffect.Parameters["lightRadius"].SetValue(pl.LightRadius);
                        pointLightEffect.Parameters["lightIntensity"].SetValue(pl.LightIntensity);
                        pointLightEffect.Parameters["quadratic"].SetValue(pl.UsePointLightQuadraticAttenuation);

                        float cameraToCenter = Vector3.Distance(camera.Position, pl.LightPosition);

                        if (cameraToCenter < pl.LightRadius + camera.NearPlane)
                            render.PushRasterizerState(RasterizerState.CullClockwise);
                        else
                            render.PushRasterizerState(RasterizerState.CullCounterClockwise);

                        render.RenderBatch(sphereModel.GetBatchInformation(0)[0], pointLightEffect);

                        render.PopRasterizerState();
                    }

                    render.SetSamplerState(s2, 2);
          }                    
        public ModelLoaderData Load(GraphicFactory factory, GraphicInfo ginfo, String Name)
        {            
            ModelLoaderData elements = new ModelLoaderData();
            Dictionary<String, XmlModelMeshInfo> infos = new Dictionary<string, XmlModelMeshInfo>();
            Dictionary<String, targetInfo> targets = new Dictionary<string, targetInfo>();
            Dictionary<String, SpotLightInformation> spotLights = new Dictionary<string, SpotLightInformation>();
            //Dictionary<String, ConstraintInformation> constraints = new Dictionary<string, ConstraintInformation>();
            Dictionary<String, CameraInfo> cameras = new Dictionary<string, CameraInfo>();
            Dictionary<String, ParticleInfo> particles = new Dictionary<string, ParticleInfo>();


            SerializerHelper.ChangeDecimalSymbolToPoint();
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(path + Name + ".xml");
            XmlNodeList worldNode = xDoc["SCENE"].ChildNodes;

            foreach (XmlNode node in worldNode)
            {


                if (node.Name == "Constraint")
                {

                    ConstraintInfo cinfo = new ConstraintInfo();


                    cinfo.Name = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);
                    XmlElement type = node["type"];
                    if (type != null)
                    {
                        cinfo.type = SerializerHelper.DeserializeAttributeBaseType<String>("value", type);
                    }

                    XmlElement child = node["child"];
                    if (child != null)
                    {
                        cinfo.bodyA = SerializerHelper.DeserializeAttributeBaseType<String>("name", child);
                    }

                    XmlElement parent = node["parent"];
                    if (parent != null)
                    {
                        cinfo.bodyB = SerializerHelper.DeserializeAttributeBaseType<String>("name", parent);
                    }

                    XmlElement breakable = node["isBreakable"];
                    if (breakable != null)
                    {

                        cinfo.breakable = SerializerHelper.DeserializeAttributeBaseType<bool>("value", breakable);

                    }



                    Vector3 pos = SerializerHelper.DeserializeVector3("position", node);
                    cinfo.Position = new Vector3(pos.X, pos.Y, pos.Z);


                    elements.ConstraintInfo.Add(cinfo);

                }
                if (node.Name == "particle")
                {
                    ParticleInfo pinfo = new ParticleInfo();
                    pinfo.Name = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);
                    pinfo.Position = SerializerHelper.DeserializeVector3("position", node);
                    pinfo.Orientation = SerializerHelper.DeserializeQuaternion("rotation", node);

                    XmlElement mass = node["type"];
                    if (mass != null)
                    {
                        pinfo.Type = SerializerHelper.DeserializeAttributeBaseType<String>("value", mass);
                    }

                    elements.ParticleInfo.Add(pinfo);
                }
                if (node.Name == "body")
                {
                    XmlModelMeshInfo info = new XmlModelMeshInfo();
                    info.modelName = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);



                    XmlElement mass = node["mass"];
                    if (mass != null)
                    {
                        info.mass = SerializerHelper.DeserializeAttributeBaseType<float>("value", mass);
                    }

                    XmlElement dfric = node["dinamicfriction"];
                    if (dfric != null)
                    {
                        info.dinamicfriction = SerializerHelper.DeserializeAttributeBaseType<float>("value", dfric);
                    }

                    XmlElement sfric = node["staticfriction"];
                    if (sfric != null)
                    {
                        info.staticfriction = SerializerHelper.DeserializeAttributeBaseType<float>("value", sfric);
                    }

                    XmlElement ellas = node["ellasticity"];
                    if (ellas != null)
                    {
                        info.ellasticity = SerializerHelper.DeserializeAttributeBaseType<float>("value", ellas);
                    }



                    XmlElement collision = node["collision"];
                    if (collision != null)
                    {
                        info.collisionType = SerializerHelper.DeserializeAttributeBaseType<String>("type", collision);

                        if (info.collisionType.Contains("Water"))
                        {

                            Vector3 pos = SerializerHelper.DeserializeVector3("position", collision);

                            float width = SerializerHelper.DeserializeAttributeBaseType<float>("value", collision["width"]);
                            float length = SerializerHelper.DeserializeAttributeBaseType<float>("value", collision["length"]);

                            info.material.extrainformation = new Dictionary<string, object>();
                            info.material.extrainformation.Add("position", pos);
                            info.material.extrainformation.Add("width", width);
                            info.material.extrainformation.Add("length", length);
                        }
                    }
                    XmlElement material = node["material"];
                    if (material == null)
                    {
                        info.material.difuseName = "white";
                    }
                    else
                    {

                        XmlElement reflect = material["reflection"];
                        if (reflect != null)
                        {
                            info.material.reflectionName = removeExtension(SerializerHelper.DeserializeAttributeBaseType<String>("name", reflect));
                        }
                        else
                        {
                            XmlElement difuse = material["diffuse"];
                            if (difuse != null)
                            {
                                info.material.difuseName = removeExtension(SerializerHelper.DeserializeAttributeBaseType<String>("name", difuse));
                            }
                            XmlElement bump = material["bump"];
                            if (bump != null)
                            {
                                info.material.bumpName = removeExtension(SerializerHelper.DeserializeAttributeBaseType<String>("name", bump));
                            }
                            XmlElement specular = material["specular"];
                            if (specular != null)
                            {
                                info.material.specularName = removeExtension(SerializerHelper.DeserializeAttributeBaseType<String>("name", specular));
                            }
                            XmlElement glow = material["glow"];
                            if (glow != null)
                            {
                                info.material.glowName = removeExtension(SerializerHelper.DeserializeAttributeBaseType<String>("name", glow));
                            }
                        }
                    }
                    infos.Add(info.modelName, info);
                }
                else if (node.Name == "pointlight")
                {
                    String name = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);
                    Vector3 pos = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    Vector3 vColor = SerializerHelper.DeserializeVector3("color", node);
                    Color color = new Color(vColor.X / 255, vColor.Y / 255, vColor.Z / 255);
                    float amount = SerializerHelper.DeserializeAttributeBaseType<float>("amount", node["multiplier"]);
                    float decay = SerializerHelper.DeserializeAttributeBaseType<float>("value", node["decay"]);
                    PointLightPE pl = new PointLightPE(pos, color, 200, amount);
                    pl.Name = name;
                    pl.UsePointLightQuadraticAttenuation = true;
                    elements.LightsInfo.Add(pl);
                }
                else if (node.Name == "spotlight")
                {
                    String name = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);
                    Vector3 pos = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    Vector3 vColor = SerializerHelper.DeserializeVector3("color", node);
                    float fallof = SerializerHelper.DeserializeBaseType<float>("fallof", node);
                    Color color = new Color(vColor.X / 255, vColor.Y / 255, vColor.Z / 255);
                    float amount = SerializerHelper.DeserializeAttributeBaseType<float>("amount", node["multiplier"]);
                    float decay = SerializerHelper.DeserializeAttributeBaseType<float>("value", node["decay"]);
                    bool castShadow = SerializerHelper.DeserializeBaseType<bool>("castShadows", node);

                    SpotLightInformation spi = new SpotLightInformation();
                    spi.angle = MathHelper.ToRadians(fallof);
                    spi.color = color;
                    spi.decay = decay;
                    spi.multiplier = amount;
                    spi.name = name;
                    spi.pos = pos;
                    spi.castShadow = castShadow;
                    spotLights.Add(spi.name, spi);


                }
                else if (node.Name == "target")
                {
                    String name = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);
                    Vector3 pos = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    targetInfo ti = new targetInfo();
                    ti.targetPos = pos;
                    ti.name = name;
                    targets.Add(ti.name, ti);
                }
                else if (node.Name == "camera")
                {
                    String name = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);
                    Vector3 pos = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    CameraInfo co = new CameraInfo();
                    co.Name = name;
                    co.Position = pos;
                    cameras.Add(co.Name, co);
                }
                else if (node.Name == "dummy")
                {
                    String name = SerializerHelper.DeserializeAttributeBaseType<String>("name", node);
                    Vector3 pos = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    DummyInfo di = new DummyInfo();
                    di.Name = name;
                    di.Position = pos;
                    elements.DummyInfo.Add(di);
                }
            }

            ///////PROCCESS LIGHTS /////////////////////
            foreach (var item in spotLights)
            {
                SpotLightInformation si = item.Value;
                targetInfo ti = targets[item.Key + ".Target"];
                SpotLightPE sl = new SpotLightPE(si.pos, Vector3.Normalize(ti.targetPos - si.pos), si.color,si.decay, (ti.targetPos - si.pos).Length() * 10f, (float)Math.Cos(si.angle / 2), si.multiplier);
                sl.CastShadown = si.castShadow;
                sl.Name = si.name;
                elements.LightsInfo.Add(sl);

            }

            ///////PROCCESS CAMERAS/////////////////////
            foreach (var item in cameras)
            {
                CameraInfo ci = item.Value;
                targetInfo ti = targets[item.Key + ".Target"];
                ci.Target = ti.targetPos;
                elements.CameraInfo.Add(ci);
            }


            Model model = factory.GetModel(modelPath + Name);
            modelNames.Add(modelPath + Name);
            Matrix[] m = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(m);

            ////////////EXTRAINDO MESHES
            for (int i = 0; i < model.Meshes.Count; i++)
            {
                String name = model.Meshes[i].Name.Substring(5);
                if (infos.ContainsKey(name))
                {

                    for (int j = 0; j < model.Meshes[i].MeshParts.Count; j++)
                    {
                        XmlModelMeshInfo inf = infos[name];
                        Matrix tr = m[model.Meshes[i].ParentBone.Index];

                        Vector3 scale;
                        Vector3 pos;
                        Quaternion ori;
                        tr.Decompose(out scale, out ori, out pos);

                        ObjectInformation mi = new ObjectInformation();
                        mi.modelName = inf.modelName;
                        mi.meshPartIndex = j;
                        mi.meshIndex = i;
                        mi.position = pos;
                        mi.scale = scale;
                        mi.rotation = ori;
                        
                        ModelBuilderHelper.Extract(m, model.Meshes[i].MeshParts[j], out mi.batchInformation);
                        mi.ellasticity = inf.ellasticity;
                        mi.dinamicfriction = inf.dinamicfriction;
                        mi.staticfriction = inf.staticfriction;
                        mi.collisionType = inf.collisionType;
                        mi.mass = inf.mass;

                        mi.batchInformation.ModelLocalTransformation = m[model.Meshes[i].ParentBone.Index];

                        mi.textureInformation = new TextureInformation(false, factory);
                        

                        if (inf.material.reflectionName != null)
                        {
                            mi.textureInformation.SetCubeTexture(factory.GetTextureCube(texturePath + inf.material.reflectionName), TextureType.ENVIRONMENT);
                            texturesNames.Add(texturePath + inf.material.reflectionName);
                        }

                        else
                        {
                            if (inf.material.difuseName != null)
                            {
                                mi.textureInformation.SetTexture(factory.GetTexture2D(texturePath + inf.material.difuseName), TextureType.DIFFUSE);
                                texturesNames.Add(texturePath + inf.material.difuseName);
                            }

                            if (inf.material.glowName != null)
                            {
                                mi.textureInformation.SetTexture(factory.GetTexture2D(texturePath + inf.material.glowName), TextureType.GLOW);
                                texturesNames.Add(texturePath + inf.material.glowName);
                            }

                            if (inf.material.specularName != null)
                            {
                                mi.textureInformation.SetTexture(factory.GetTexture2D(texturePath + inf.material.specularName), TextureType.SPECULAR);
                                texturesNames.Add(texturePath + inf.material.specularName);
                            }

                            if (inf.material.bumpName != null)
                            {
                                mi.textureInformation.SetTexture(factory.GetTexture2D(texturePath + inf.material.bumpName), TextureType.BUMP);
                                texturesNames.Add(texturePath + inf.material.bumpName);
                            }

                        }

                        if (inf.collisionType != null)
                        {
                            if (inf.collisionType.Contains("Water"))
                            {
                                mi.extra = inf.material.extrainformation;
                            }
                        }

                        mi.textureInformation.LoadTexture();
                        elements.ModelMeshesInfo.Add(mi);
                    }
                }
            }

            SerializerHelper.ChangeDecimalSymbolToSystemDefault();
            //Clear Stuffs
            infos.Clear();
            targets.Clear();
            spotLights.Clear();
            cameras.Clear();

            return elements;
        }
 public void mousebuttontesteRight(MouseState ms)
 {
     PointLightPE pl = new PointLightPE(_mundo.CameraManager.ActiveCamera.Position, StaticRandom.RandomColor(), 100, 5);
     pl.UsePointLightQuadraticAttenuation = true;
     _mundo.AddLight(pl);
 }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            #region Models
            ///Cenario
            {
                SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cenario");                
                IPhysicObject pi = new TriangleMeshObject(sm,Vector3.Zero,Matrix.Identity,Vector3.One,MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader(0.05f, 50);                            
                IMaterial mat = new DeferredMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
            }
            

            #endregion            

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);            
            cam.FarPlane = 2000;

            ///Atirador de bolas classico
            lt = new LightThrowBepu(this.World,factory);            
            
            ///Interpolador que ira variar a cor das luzes
            UnitLightInterpolator li = new UnitLightInterpolator(this, true);
            ///Inicia o funcionamento do componente IScreenUpdateable (classe pai do UnitLightInterpolator)
            li.Start();            
            
            ///Adiciona DIVERSAS luzes pelo cenario
            for (int i = -10; i < 10; i++)
            {
                for (int j = -10; j < 10 ; j++)
                {
                    ///Luz Pontual
                    PointLightPE pl = new PointLightPE(new Vector3(i * 20, 10, j * 20), Color.White, 35, 2);
                    //Atenuacao quadratica (inverso do quadrado ao inves do padrao que eh inverso da linear)
                    ///custa mais, mas eh mais bonita
                    pl.UsePointLightQuadraticAttenuation = true;
                    ///adiciona ao mundo
                    this.World.AddLight(pl);
                    ///adiciona ao interpolador
                    li.AddLight(pl, StaticRandom.RandomColor(), StaticRandom.RandomColor(), StaticRandom.RandomBetween(0, 5));
                }
            }

            ///mais luzes, mais alto
            for (int i = -5; i < 5; i++)
            {
                for (int j = -5; j < 5; j++)
                {
                    PointLightPE pl = new PointLightPE(new Vector3(i * 50, 140, j * 50), Color.White, 70, 1);
                    pl.UsePointLightQuadraticAttenuation = true;
                    this.World.AddLight(pl);
                    li.AddLight(pl, StaticRandom.RandomColor(), StaticRandom.RandomColor(), StaticRandom.RandomBetween(0, 10));
                }
            }

            this.World.CameraManager.AddCamera(cam);
            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
Ejemplo n.º 12
0
        private void DrawPointLight(RenderHelper render, GraphicInfo ginfo, ICamera camera, PointLightPE pl, IDeferredGBuffer DeferredGBuffer, bool cullPointLight)
        {
            pointLightEffect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
            render.device.Textures[0] = DeferredGBuffer[GBufferTypes.COLOR];
            render.device.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
            render.device.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
            SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);

            pointLightEffect.Parameters["Projection"].SetValue(camera.Projection);
            pointLightEffect.Parameters["View"].SetValue(camera.View);
            pointLightEffect.Parameters["cameraPosition"].SetValue(camera.Position);
            pointLightEffect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(camera.ViewProjection));


            Matrix sphereWorldMatrix = Matrix.CreateScale(pl.LightRadius) * Matrix.CreateTranslation(pl.LightPosition);

            ContainmentType ct = ContainmentType.Contains;

            if (cullPointLight)
            {
                ct = camera.BoundingFrustum.Contains(new BoundingSphere(pl.LightPosition, pl.LightRadius));
            }
            if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects)
            {
                pointLightEffect.Parameters["World"].SetValue(sphereWorldMatrix);
                pointLightEffect.Parameters["lightPosition"].SetValue(pl.LightPosition);
                pointLightEffect.Parameters["Color"].SetValue(pl.Color.ToVector3());
                pointLightEffect.Parameters["lightRadius"].SetValue(pl.LightRadius);
                pointLightEffect.Parameters["lightIntensity"].SetValue(pl.LightIntensity);
                pointLightEffect.Parameters["quadratic"].SetValue(pl.UsePointLightQuadraticAttenuation);

                float cameraToCenter = Vector3.Distance(camera.Position, pl.LightPosition);

                if (cameraToCenter < pl.LightRadius + camera.NearPlane)
                {
                    render.PushRasterizerState(RasterizerState.CullClockwise);
                }
                else
                {
                    render.PushRasterizerState(RasterizerState.CullCounterClockwise);
                }

                render.RenderBatch(sphereModel.GetBatchInformation(0)[0], pointLightEffect);

                render.PopRasterizerState();
            }

            render.SetSamplerState(s2, 2);
        }
        protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            #region Models
            ///Cenario
            {
                SimpleModel          sm     = new SimpleModel(factory, "..\\Content\\Model\\cenario");
                IPhysicObject        pi     = new TriangleMeshObject(sm, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader(0.05f, 50);
                IMaterial            mat    = new DeferredMaterial(shader);
                IObject obj3 = new IObject(mat, sm, pi);
                this.World.AddObject(obj3);
            }


            #endregion

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
            cam.FarPlane = 2000;

            ///Atirador de bolas classico
            lt = new LightThrowBepu(this.World, factory);

            ///Interpolador que ira variar a cor das luzes
            UnitLightInterpolator li = new UnitLightInterpolator(this, true);
            ///Inicia o funcionamento do componente IScreenUpdateable (classe pai do UnitLightInterpolator)
            li.Start();

            ///Adiciona DIVERSAS luzes pelo cenario
            for (int i = -10; i < 10; i++)
            {
                for (int j = -10; j < 10; j++)
                {
                    ///Luz Pontual
                    PointLightPE pl = new PointLightPE(new Vector3(i * 20, 10, j * 20), Color.White, 35, 2);
                    //Atenuacao quadratica (inverso do quadrado ao inves do padrao que eh inverso da linear)
                    ///custa mais, mas eh mais bonita
                    pl.UsePointLightQuadraticAttenuation = true;
                    ///adiciona ao mundo
                    this.World.AddLight(pl);
                    ///adiciona ao interpolador
                    li.AddLight(pl, StaticRandom.RandomColor(), StaticRandom.RandomColor(), StaticRandom.RandomBetween(0, 5));
                }
            }

            ///mais luzes, mais alto
            for (int i = -5; i < 5; i++)
            {
                for (int j = -5; j < 5; j++)
                {
                    PointLightPE pl = new PointLightPE(new Vector3(i * 50, 140, j * 50), Color.White, 70, 1);
                    pl.UsePointLightQuadraticAttenuation = true;
                    this.World.AddLight(pl);
                    li.AddLight(pl, StaticRandom.RandomColor(), StaticRandom.RandomColor(), StaticRandom.RandomBetween(0, 10));
                }
            }

            this.World.CameraManager.AddCamera(cam);
            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
        private void RenderLights(ICamera camera, IWorld world, RenderHelper render, GraphicInfo ginfo)
        {
            _lighting.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
            _lighting.Parameters["DepthBuffer"].SetValue(_depthBuffer);
            _lighting.Parameters["NormalBuffer"].SetValue(_normalBuffer);

            ApplyFrustumCorners(_lighting, -Vector2.One, Vector2.One);
            ApplyFrustumCorners(pointLightEffect, -Vector2.One, Vector2.One);

            for (int i = 0; i < world.Lights.Count; i++)
            {
                if (world.Lights[i].LightType == LightType.Deferred_Directional)
                {
                    DirectionalLightPE dl = (DirectionalLightPE)world.Lights[i];
                    _lighting.Parameters["LightColor"].SetValue(dl.Color.ToVector4());
                    _lighting.Parameters["LightIntensity"].SetValue(dl.LightIntensity);
                    _lighting.Parameters["LightDir"].SetValue(dl.LightDirection);
                    render.RenderFullScreenQuadVertexPixel(_lighting);
                }

                else if (world.Lights[i].LightType == LightType.Deferred_Point)
                {
                    PointLightPE    pl = world.Lights[i] as PointLightPE;
                    Matrix          sphereWorldMatrix = Matrix.CreateScale(pl.LightRadius) * Matrix.CreateTranslation(pl.LightPosition);
                    ContainmentType ct = camera.BoundingFrustum.Contains(new BoundingSphere(pl.LightPosition, pl.LightRadius));

                    Vector3 viewSpaceLPos = Vector3.Transform(pl.LightPosition,
                                                              camera.View);

                    pointLightEffect.Parameters["cameraPos"].SetValue(camera.Position);
                    pointLightEffect.Parameters["LightColor"].SetValue(pl.Color.ToVector4());
                    pointLightEffect.Parameters["LightPosition"].SetValue(viewSpaceLPos);
                    pointLightEffect.Parameters["lightRadius"].SetValue(pl.LightRadius);

                    pointLightEffect.Parameters["WorldViewProjection"].SetValue(sphereWorldMatrix * camera.ViewProjection);
                    //pointLightEffect.Parameters["FarClip"].SetValue(camera.FarPlane);

                    float _tanFovy = (float)Math.Tan(camera.FieldOfView);
                    //pointLightEffect.Parameters["TanAspect"].SetValue(new Vector2(_tanFovy * camera.AspectRatio, -_tanFovy));
                    pointLightEffect.Parameters["GBufferPixelSize"].SetValue(new Vector2(0.5f / _width, 0.5f / _height));

                    pointLightEffect.Parameters["lightIntensity"].SetValue(pl.LightIntensity);

                    if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects)
                    {
                        float cameraToCenter = Vector3.Distance(camera.Position, pl.LightPosition);

                        if (cameraToCenter < pl.LightRadius + camera.NearPlane)
                        {
                            render.PushRasterizerState(RasterizerState.CullClockwise);
                        }
                        else
                        {
                            render.PushRasterizerState(RasterizerState.CullCounterClockwise);
                        }

                        render.RenderBatch(sphereModel.GetBatchInformation(0)[0], pointLightEffect);

                        render.PopRasterizerState();
                    }
                }
            }
        }
        public ModelLoaderData Load(GraphicFactory factory, GraphicInfo ginfo, String Name)
        {
            ModelLoaderData elements = new ModelLoaderData();
            Dictionary <String, XmlModelMeshInfo>     infos      = new Dictionary <string, XmlModelMeshInfo>();
            Dictionary <String, targetInfo>           targets    = new Dictionary <string, targetInfo>();
            Dictionary <String, SpotLightInformation> spotLights = new Dictionary <string, SpotLightInformation>();
            //Dictionary<String, ConstraintInformation> constraints = new Dictionary<string, ConstraintInformation>();
            Dictionary <String, CameraInfo>   cameras   = new Dictionary <string, CameraInfo>();
            Dictionary <String, ParticleInfo> particles = new Dictionary <string, ParticleInfo>();


            SerializerHelper.ChangeDecimalSymbolToPoint();
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(path + Name + ".xml");
            XmlNodeList worldNode = xDoc["SCENE"].ChildNodes;

            foreach (XmlNode node in worldNode)
            {
                if (node.Name == "Constraint")
                {
                    ConstraintInfo cinfo = new ConstraintInfo();


                    cinfo.Name = SerializerHelper.DeserializeAttributeBaseType <String>("name", node);
                    XmlElement type = node["type"];
                    if (type != null)
                    {
                        cinfo.type = SerializerHelper.DeserializeAttributeBaseType <String>("value", type);
                    }

                    XmlElement child = node["child"];
                    if (child != null)
                    {
                        cinfo.bodyA = SerializerHelper.DeserializeAttributeBaseType <String>("name", child);
                    }

                    XmlElement parent = node["parent"];
                    if (parent != null)
                    {
                        cinfo.bodyB = SerializerHelper.DeserializeAttributeBaseType <String>("name", parent);
                    }

                    XmlElement breakable = node["isBreakable"];
                    if (breakable != null)
                    {
                        cinfo.breakable = SerializerHelper.DeserializeAttributeBaseType <bool>("value", breakable);
                    }



                    Vector3 pos = SerializerHelper.DeserializeVector3("position", node);
                    cinfo.Position = new Vector3(pos.X, pos.Y, pos.Z);


                    elements.ConstraintInfo.Add(cinfo);
                }
                if (node.Name == "particle")
                {
                    ParticleInfo pinfo = new ParticleInfo();
                    pinfo.Name        = SerializerHelper.DeserializeAttributeBaseType <String>("name", node);
                    pinfo.Position    = SerializerHelper.DeserializeVector3("position", node);
                    pinfo.Orientation = SerializerHelper.DeserializeQuaternion("rotation", node);

                    XmlElement mass = node["type"];
                    if (mass != null)
                    {
                        pinfo.Type = SerializerHelper.DeserializeAttributeBaseType <String>("value", mass);
                    }

                    elements.ParticleInfo.Add(pinfo);
                }
                if (node.Name == "body")
                {
                    XmlModelMeshInfo info = new XmlModelMeshInfo();
                    info.modelName = SerializerHelper.DeserializeAttributeBaseType <String>("name", node);



                    XmlElement mass = node["mass"];
                    if (mass != null)
                    {
                        info.mass = SerializerHelper.DeserializeAttributeBaseType <float>("value", mass);
                    }

                    XmlElement dfric = node["dinamicfriction"];
                    if (dfric != null)
                    {
                        info.dinamicfriction = SerializerHelper.DeserializeAttributeBaseType <float>("value", dfric);
                    }

                    XmlElement sfric = node["staticfriction"];
                    if (sfric != null)
                    {
                        info.staticfriction = SerializerHelper.DeserializeAttributeBaseType <float>("value", sfric);
                    }

                    XmlElement ellas = node["ellasticity"];
                    if (ellas != null)
                    {
                        info.ellasticity = SerializerHelper.DeserializeAttributeBaseType <float>("value", ellas);
                    }



                    XmlElement collision = node["collision"];
                    if (collision != null)
                    {
                        info.collisionType = SerializerHelper.DeserializeAttributeBaseType <String>("type", collision);

                        if (info.collisionType.Contains("Water"))
                        {
                            Vector3 pos = SerializerHelper.DeserializeVector3("position", collision);

                            float width  = SerializerHelper.DeserializeAttributeBaseType <float>("value", collision["width"]);
                            float length = SerializerHelper.DeserializeAttributeBaseType <float>("value", collision["length"]);

                            info.material.extrainformation = new Dictionary <string, object>();
                            info.material.extrainformation.Add("position", pos);
                            info.material.extrainformation.Add("width", width);
                            info.material.extrainformation.Add("length", length);
                        }
                    }
                    XmlElement material = node["material"];
                    if (material == null)
                    {
                        info.material.difuseName = "white";
                    }
                    else
                    {
                        XmlElement reflect = material["reflection"];
                        if (reflect != null)
                        {
                            info.material.reflectionName = removeExtension(SerializerHelper.DeserializeAttributeBaseType <String>("name", reflect));
                        }
                        else
                        {
                            XmlElement difuse = material["diffuse"];
                            if (difuse != null)
                            {
                                info.material.difuseName = removeExtension(SerializerHelper.DeserializeAttributeBaseType <String>("name", difuse));
                            }
                            XmlElement bump = material["bump"];
                            if (bump != null)
                            {
                                info.material.bumpName = removeExtension(SerializerHelper.DeserializeAttributeBaseType <String>("name", bump));
                            }
                            XmlElement specular = material["specular"];
                            if (specular != null)
                            {
                                info.material.specularName = removeExtension(SerializerHelper.DeserializeAttributeBaseType <String>("name", specular));
                            }
                            XmlElement glow = material["glow"];
                            if (glow != null)
                            {
                                info.material.glowName = removeExtension(SerializerHelper.DeserializeAttributeBaseType <String>("name", glow));
                            }
                        }
                    }
                    infos.Add(info.modelName, info);
                }
                else if (node.Name == "pointlight")
                {
                    String  name = SerializerHelper.DeserializeAttributeBaseType <String>("name", node);
                    Vector3 pos  = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    Vector3      vColor = SerializerHelper.DeserializeVector3("color", node);
                    Color        color  = new Color(vColor.X / 255, vColor.Y / 255, vColor.Z / 255);
                    float        amount = SerializerHelper.DeserializeAttributeBaseType <float>("amount", node["multiplier"]);
                    float        decay  = SerializerHelper.DeserializeAttributeBaseType <float>("value", node["decay"]);
                    PointLightPE pl     = new PointLightPE(pos, color, 200, amount);
                    pl.Name = name;
                    pl.UsePointLightQuadraticAttenuation = true;
                    elements.LightsInfo.Add(pl);
                }
                else if (node.Name == "spotlight")
                {
                    String  name = SerializerHelper.DeserializeAttributeBaseType <String>("name", node);
                    Vector3 pos  = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    Vector3 vColor     = SerializerHelper.DeserializeVector3("color", node);
                    float   fallof     = SerializerHelper.DeserializeBaseType <float>("fallof", node);
                    Color   color      = new Color(vColor.X / 255, vColor.Y / 255, vColor.Z / 255);
                    float   amount     = SerializerHelper.DeserializeAttributeBaseType <float>("amount", node["multiplier"]);
                    float   decay      = SerializerHelper.DeserializeAttributeBaseType <float>("value", node["decay"]);
                    bool    castShadow = SerializerHelper.DeserializeBaseType <bool>("castShadows", node);

                    SpotLightInformation spi = new SpotLightInformation();
                    spi.angle      = MathHelper.ToRadians(fallof);
                    spi.color      = color;
                    spi.decay      = decay;
                    spi.multiplier = amount;
                    spi.name       = name;
                    spi.pos        = pos;
                    spi.castShadow = castShadow;
                    spotLights.Add(spi.name, spi);
                }
                else if (node.Name == "target")
                {
                    String  name = SerializerHelper.DeserializeAttributeBaseType <String>("name", node);
                    Vector3 pos  = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    targetInfo ti = new targetInfo();
                    ti.targetPos = pos;
                    ti.name      = name;
                    targets.Add(ti.name, ti);
                }
                else if (node.Name == "camera")
                {
                    String  name = SerializerHelper.DeserializeAttributeBaseType <String>("name", node);
                    Vector3 pos  = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    CameraInfo co = new CameraInfo();
                    co.Name     = name;
                    co.Position = pos;
                    cameras.Add(co.Name, co);
                }
                else if (node.Name == "dummy")
                {
                    String  name = SerializerHelper.DeserializeAttributeBaseType <String>("name", node);
                    Vector3 pos  = SerializerHelper.DeserializeVector3("position", node);
                    pos = new Vector3(pos.X, -pos.Y, -pos.Z);
                    DummyInfo di = new DummyInfo();
                    di.Name     = name;
                    di.Position = pos;
                    elements.DummyInfo.Add(di);
                }
            }

            ///////PROCCESS LIGHTS /////////////////////
            foreach (var item in spotLights)
            {
                SpotLightInformation si = item.Value;
                targetInfo           ti = targets[item.Key + ".Target"];
                SpotLightPE          sl = new SpotLightPE(si.pos, Vector3.Normalize(ti.targetPos - si.pos), si.color, si.decay, (ti.targetPos - si.pos).Length() * 10f, (float)Math.Cos(si.angle / 2), si.multiplier);
                sl.CastShadown = si.castShadow;
                sl.Name        = si.name;
                elements.LightsInfo.Add(sl);
            }

            ///////PROCCESS CAMERAS/////////////////////
            foreach (var item in cameras)
            {
                CameraInfo ci = item.Value;
                targetInfo ti = targets[item.Key + ".Target"];
                ci.Target = ti.targetPos;
                elements.CameraInfo.Add(ci);
            }


            Model model = factory.GetModel(modelPath + Name);

            modelNames.Add(modelPath + Name);
            Matrix[] m = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(m);

            ////////////EXTRAINDO MESHES
            for (int i = 0; i < model.Meshes.Count; i++)
            {
                String name = model.Meshes[i].Name.Substring(5);
                if (infos.ContainsKey(name))
                {
                    for (int j = 0; j < model.Meshes[i].MeshParts.Count; j++)
                    {
                        XmlModelMeshInfo inf = infos[name];
                        Matrix           tr  = m[model.Meshes[i].ParentBone.Index];

                        Vector3    scale;
                        Vector3    pos;
                        Quaternion ori;
                        tr.Decompose(out scale, out ori, out pos);

                        ObjectInformation mi = new ObjectInformation();
                        mi.modelName     = inf.modelName;
                        mi.meshPartIndex = j;
                        mi.meshIndex     = i;
                        mi.position      = pos;
                        mi.scale         = scale;
                        mi.rotation      = ori;

                        ModelBuilderHelper.Extract(m, model.Meshes[i].MeshParts[j], out mi.batchInformation);
                        mi.ellasticity     = inf.ellasticity;
                        mi.dinamicfriction = inf.dinamicfriction;
                        mi.staticfriction  = inf.staticfriction;
                        mi.collisionType   = inf.collisionType;
                        mi.mass            = inf.mass;

                        mi.batchInformation.ModelLocalTransformation = m[model.Meshes[i].ParentBone.Index];

                        mi.textureInformation = new TextureInformation(false, factory);


                        if (inf.material.reflectionName != null)
                        {
                            mi.textureInformation.SetCubeTexture(factory.GetTextureCube(texturePath + inf.material.reflectionName), TextureType.ENVIRONMENT);
                            texturesNames.Add(texturePath + inf.material.reflectionName);
                        }

                        else
                        {
                            if (inf.material.difuseName != null)
                            {
                                mi.textureInformation.SetTexture(factory.GetTexture2D(texturePath + inf.material.difuseName), TextureType.DIFFUSE);
                                texturesNames.Add(texturePath + inf.material.difuseName);
                            }

                            if (inf.material.glowName != null)
                            {
                                mi.textureInformation.SetTexture(factory.GetTexture2D(texturePath + inf.material.glowName), TextureType.GLOW);
                                texturesNames.Add(texturePath + inf.material.glowName);
                            }

                            if (inf.material.specularName != null)
                            {
                                mi.textureInformation.SetTexture(factory.GetTexture2D(texturePath + inf.material.specularName), TextureType.SPECULAR);
                                texturesNames.Add(texturePath + inf.material.specularName);
                            }

                            if (inf.material.bumpName != null)
                            {
                                mi.textureInformation.SetTexture(factory.GetTexture2D(texturePath + inf.material.bumpName), TextureType.BUMP);
                                texturesNames.Add(texturePath + inf.material.bumpName);
                            }
                        }

                        if (inf.collisionType != null)
                        {
                            if (inf.collisionType.Contains("Water"))
                            {
                                mi.extra = inf.material.extrainformation;
                            }
                        }

                        mi.textureInformation.LoadTexture();
                        elements.ModelMeshesInfo.Add(mi);
                    }
                }
            }

            SerializerHelper.ChangeDecimalSymbolToSystemDefault();
            //Clear Stuffs
            infos.Clear();
            targets.Clear();
            spotLights.Clear();
            cameras.Clear();

            return(elements);
        }