public Mesh(ICore core, ProgramSettings settings, string fileName) : base(core) { this.core = core; this.settings = settings; mass = 0f; staticFriction = 0.9f; kineticFriction = 0.5f; softness = 0.1f; bounciness = 0.1f; materialIdx = -1; SetMaterialToCustom(); FileName = fileName; customTexture = string.Empty; //Name = fileName.Split(new[] { '\\' }).Last(); PhysicsId = -1; enableLightning = true; Name = core.GetName<Mesh>(); string ending = fileName.Split(new[] { '\\' }).Last().ToUpper(); mesh = core.Scene.CreateMeshBuilder(); if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.TVM))) { mesh.LoadTVM(fileName, true, false); } else if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.X))) { mesh.LoadXFile(fileName, true, false); } else if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.TVA))) { TVActor actor = core.Scene.CreateActor(); actor.Load(fileName, true, false); mesh = actor.GetDeformedMesh(); core.Scene.DestroyAllActors(); IsAnimated = true; } else return; mesh.EnableFrustumCulling(true, true); mesh.ComputeNormals(); mesh.ComputeBoundings(); mesh.ComputeOctree(); mesh.SetCullMode(CONST_TV_CULLING.TV_BACK_CULL); mesh.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA); mesh.SetAlphaTest(true); mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); mesh.SetShadowCast(true, true); lightmapIdx = mesh.GetTextureEx((int)CONST_TV_LAYER.TV_LAYER_LIGHTMAP); textureScale = new UV(1.0f, 1.0f); LoadTextures(); UniqueId = mesh.GetMeshName(); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var sValue = value as string; object retVal = null; if (sValue != null) { sValue = sValue.Trim(); if (sValue.Length != 0) { if (null == culture) culture = CultureInfo.CurrentCulture; string[] parms = sValue.Split(new char[] {culture.TextInfo.ListSeparator[0]}); if (parms.Length == 1) { float u = float.Parse(parms[0]); retVal = new UV(u, u); } else if (parms.Length == 2) { float u = float.Parse(parms[0]); float v = float.Parse(parms[1]); retVal = new UV(u, v); } } } else retVal = ConvertFrom(context, culture, value); return retVal; }