/// <summary> /// Called when an object is found ///Return the object, return null to not add this object /// </summary> /// <param name="world">The world.</param> /// <param name="factory">The factory.</param> /// <param name="ginfo">The ginfo.</param> /// <param name="mi">The mi.</param> /// <returns></returns> IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] mi) { ///Do what default would do. IObject[] objs = WorldLoader.CreateOBJ(world, factory, ginfo, mi); ///Change object property here !!! foreach (var obj in objs) { DeferredCustomShader cd = (obj.Material.Shader as DeferredCustomShader); ///the world loader uses deferredCustomShader for all objects System.Diagnostics.Debug.Assert(cd != null); ///if the obj does not use specular map if (!cd.UseSpecular) { ///set a constant specular for all the object cd.SpecularIntensity = 0.3f; cd.SpecularPower = 150; } } ///If you want, create the object on your own, without using the World Loader, ///THIS IS WHAT WorldLoader.CreateOBJ DOES //IModelo model = new CustomModel(factory, mi.modelName, new BatchInformation[] { mi.batchInformation}, mi.difuse, mi.bump, mi.specular, mi.glow); //IPhysicObject po = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); //IShader shader = new DeferredCustomShader(mi.HasTexture(TextureType.GLOW), mi.HasTexture(TextureType.BUMP), mi.HasTexture(TextureType.SPECULAR), mi.HasTexture(TextureType.PARALAX)); //DeferredMaterial dm = new DeferredMaterial(shader); //return new IObject(dm, model, po); return(objs); }
IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] oi) { foreach (var mi in oi) { mi.batchInformation.ModelLocalTransformation = mi.batchInformation.ModelLocalTransformation * Matrix.CreateScale(0.5f); } return(WorldLoader.CreateOBJ(world, factory, ginfo, oi)); }
IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] oi) { foreach (var mi in oi) { if (!mi.HasTexture(TextureType.DIFFUSE)) { mi.textureInformation.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE); } //if (mi.HasTexture(TextureType.BUMP)) //{ // mi.textureInformation.SetNullTexture(TextureType.BUMP); //} } return WorldLoader.CreateOBJ(world, factory, ginfo, oi); }
/// <summary> /// Called when an object is found ///Return the object, return null to not add this object /// </summary> /// <param name="world">The world.</param> /// <param name="factory">The factory.</param> /// <param name="ginfo">The ginfo.</param> /// <param name="mi">The mi.</param> /// <returns></returns> IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] mi) { ///Do what default would do. IObject[] objs = WorldLoader.CreateOBJ(world, factory, ginfo, mi); ///Change object property here !!! foreach (var obj in objs) { DeferredCustomShader cd = (obj.Material.Shader as DeferredCustomShader); ///the world loader uses deferredCustomShader for all objects System.Diagnostics.Debug.Assert(cd != null); ///if the obj does not use specular map if (!cd.UseSpecular) { ///No Specular this time cd.SpecularIntensity = 0f; } } return(objs); }
IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] mi) { return(WorldLoader.CreateOBJ(world, factory, ginfo, mi)); }