private void ReadTextureInfo(ref SourceTexInfo sourceTexInfo) { sourceTexInfo.vectorS.X = this.Stream.ReadSingle(); sourceTexInfo.vectorS.Y = this.Stream.ReadSingle(); sourceTexInfo.vectorS.Z = this.Stream.ReadSingle(); sourceTexInfo.distS = this.Stream.ReadSingle(); sourceTexInfo.vectorT.X = this.Stream.ReadSingle(); sourceTexInfo.vectorT.Y = this.Stream.ReadSingle(); sourceTexInfo.vectorT.Z = this.Stream.ReadSingle(); sourceTexInfo.distT = this.Stream.ReadSingle(); sourceTexInfo.lm_vectorS.X = this.Stream.ReadSingle(); sourceTexInfo.lm_vectorS.Y = this.Stream.ReadSingle(); sourceTexInfo.lm_vectorS.Z = this.Stream.ReadSingle(); sourceTexInfo.lm_distS = this.Stream.ReadSingle(); sourceTexInfo.lm_vectorT.X = this.Stream.ReadSingle(); sourceTexInfo.lm_vectorT.Y = this.Stream.ReadSingle(); sourceTexInfo.lm_vectorT.Z = this.Stream.ReadSingle(); sourceTexInfo.lm_distT = this.Stream.ReadSingle(); sourceTexInfo.flags = this.Stream.ReadInt32(); sourceTexInfo.texdata = this.Stream.ReadInt32(); }
//private void BuildSubmeshes(int maxTextures) //{ // int[] textureToMaterial = new int[maxTextures]; // foreach (var quake3Face in this.faces) // { // ++textureToMaterial[this.texInfo[quake3Face.texinfo].texdata]; // } // for (int i = 0; i < maxTextures; ++i) // { // if (textureToMaterial[i] > 0) // { // int index = this.Scene.Materials.Count; // var baseFileName = this.GetMaterialFileName(i); // var imagePath = baseFileName; // var texture = new FileReferenceImage { Path = imagePath }; // this.Scene.Images.Add(texture); // var effect = new SceneEffect // { // //Diffuse = new ImageColorSource { Image = texture } // }; // this.Scene.Effects.Add(effect); // var sceneMaterial = new SceneMaterial { Effect = effect }; // this.Scene.Materials.Add(sceneMaterial); // submeshes[i].Material = sceneMaterial; // textureToMaterial[i] = index; // } // } //} //private void BuildVisibilityList() //{ // for (int i = 0; i < leaves.Length; ++i) // { // Dictionary<int, bool> map = new Dictionary<int, bool>(); // if (leaves[i].cluster >= 0) // foreach (var c in clusters[leaves[i].cluster].visiblity) // foreach (var l in clusters[c].lists) // map[l] = true; // leaves[i].VisibleLeaves = new List<int>(); // foreach (var j in map.Keys) // if (i != j) // leaves[i].VisibleLeaves.Add(j); // } //} private void BuildVertex(Float3 vector3, Float3 n, SourceFace f, ref SourceTexInfo surf, out Vertex res) { res = new Vertex { Position = vector3, Normal = n, Color = Color.White, UV0 = new Float3( Float3.Dot(surf.vectorS, vector3) + surf.distS, Float3.Dot(surf.vectorT, vector3) + surf.distT, 0.0f), UV1 = new Float3( Float3.Dot(surf.lm_vectorS, vector3) + surf.lm_distS - f.LightmapTextureMinsInLuxels[0], Float3.Dot(surf.lm_vectorT, vector3) + surf.lm_distT - f.LightmapTextureMinsInLuxels[1], 0.0f) }; //if (f.LightmapTextureSizeInLuxels[0] == 0) res.UV1.X = (res.UV1.X + this.safeOffset) / (f.LightmapTextureSizeInLuxels[0] + 1.0f + this.safeBorderWidth); res.UV1.Y = (res.UV1.Y + this.safeOffset) / (f.LightmapTextureSizeInLuxels[1] + 1.0f + this.safeBorderWidth); SourceTexData tex = this.textures[surf.texdata]; res.UV0 = new Float3( res.UV0.X / ((tex.width != 0) ? tex.width : 256.0f), res.UV0.Y / ((tex.height != 0) ? tex.height : 256.0f), 0.0f); }