private static GeoSet findAndPrepareGeoSet(string fname, string base_path) { GeoSet geoset = null; string name_fixed = fname.Replace(".anm", ".geo"); string true_path = Tools.getFilepathCaseInsensitive(base_path + name_fixed); FileStream fp; try { fp = File.Open(true_path, FileMode.Open); } catch (Exception) { Debug.LogError("Can't find .geo file" + fname); return(null); } geoset = new GeoSet(); if (true_path.StartsWith(base_path)) { geoset.geopath = true_path.Substring(base_path.Length); } else { throw new InvalidOperationException("True path is not a sub-path of base directory"); } geoset.geosetLoadHeader(fp); geoset.full_geo_path = true_path; fp.Close(); RuntimeData rd = RuntimeData.get(); rd.s_name_to_geoset[fname] = geoset; return(geoset); }
public static SceneGraph loadWholeMap(string filename) { RuntimeData rd = RuntimeData.get(); SceneGraph m_scene_graph = new SceneGraph(); LoadingContext ctx = new LoadingContext(0); ctx.m_target = m_scene_graph; int geobin_idx = filename.IndexOf("geobin"); int maps_idx = filename.IndexOf("maps"); ctx.m_base_path = filename.Substring(0, geobin_idx); Debug.Assert(rd.m_prefab_mapping != null); string upcase_city = filename; upcase_city = upcase_city.Replace("city_", "City_"); upcase_city = upcase_city.Replace("hazard_", "Hazard_"); upcase_city = upcase_city.Replace("/trial_", "/Trial_"); if (upcase_city.StartsWith("trial_")) { upcase_city = "Trial_" + upcase_city.Substring(6); } upcase_city = upcase_city.Replace("zones_", "Zones_"); rd.m_prefab_mapping.sceneGraphWasReset(); bool res = ctx.loadSceneGraph(maps_idx == -1 ? upcase_city : upcase_city.Substring(maps_idx), rd.m_prefab_mapping); if (!res) { return(null); } return(m_scene_graph); }
public void createEngineModelsFromPrefabSet() { var model_textures = getModelTextures(tex_names); RuntimeData rd = RuntimeData.get(); foreach (Model model in subs) { rd.s_coh_model_to_engine_model[model] = model.modelCreateObjectFromModel(model_textures); } }
/// load the given geoset, used when loading scene-subgraph and nodes public static GeoSet Load(string m, string base_path) { RuntimeData rd = RuntimeData.get(); GeoSet res; if (rd.s_name_to_geoset.TryGetValue(m, out res)) { return(res); } return(findAndPrepareGeoSet(m, base_path)); }
void addModelStubs(GeoSet geoset) { RuntimeData rd = RuntimeData.get(); foreach (Model m in geoset.subs) { GeometryModifiersData gmod = rd.m_modifiers.findGeomModifier(m.name, ""); if (gmod != null) { if (null == m.trck_node) { m.trck_node = new ModelModifiers(); } if (m.name == "_FLRSHPS_WIN_H__FLRSHPS_Window") { Debug.LogFormat("GMod for geoset model {0}", gmod); } m.trck_node = gmod.node.clone(); m.src_mod = gmod; } } }
/// /// \brief Will split the \arg texpath into directories, and finds the closest TextureModifiers /// that matches a directory /// \param texpath contains a full path to the texture /// \return texture modifier object, if any /// static TextureModifiers_Data modFromTextureName(string texpath) { RuntimeData rd = RuntimeData.get(); List <string> split = texpath.Split('/').ToList(); while (split.Count != 0) { if (split[0] == "texture_library") { split.RemoveAt(0); break; } split.RemoveAt(0); } SceneModifiers mods = rd.m_modifiers; var texmods = mods.m_texture_path_to_mod; // scan from the back of the texture path, until a modifier is found. if (texpath.Contains("shape")) { Debug.LogFormat("Mod for {0} -{1}", texpath, string.Join(",", split)); } while (split.Count != 0) { TextureModifiers_Data texmod_val; if (texmods.TryGetValue(split[split.Count - 1].ToLower(), out texmod_val)) { return(texmod_val); } split.RemoveAt(split.Count - 1); } return(null); }
static public TextureWrapper loadTexHeader(string tex_name) { string fname = getNamedTexturePath(tex_name); if (String.IsNullOrEmpty(fname)) { Debug.LogFormat("LoadTexHeader failed for asset {0}->{1}", tex_name, fname); return(null); } RuntimeData rd = RuntimeData.get(); TextureWrapper res; FileInfo tex_path = new FileInfo(fname); string lookupstring = Path.GetFileNameWithoutExtension(tex_path.Name).ToLower(); if (rd.m_loaded_textures.TryGetValue(lookupstring, out res)) { return(res); } res = new TextureWrapper(); res.tex = AssetDatabase.LoadAssetAtPath <Texture>(fname); res.info = modFromTextureName(Path.GetDirectoryName(fname) + "/" + Path.GetFileNameWithoutExtension(fname)); TexOpt texopt_flags = 0; if (res.info != null) { texopt_flags = (TexOpt)res.info.Flags; } string upname = fname.ToUpper(); if (upname.Contains("PLAYERS/") || upname.Contains("ENEMIES/") || upname.Contains("NPCS/")) { res.flags |= TextureWrapper.TexFlag.BUMPMAP_MIRROR | TextureWrapper.TexFlag.CLAMP; } if (upname.Contains("MAPS/")) { res.flags |= TextureWrapper.TexFlag.CLAMP; } if (texopt_flags.HasFlag(TexOpt.REPLACEABLE)) { res.flags |= TextureWrapper.TexFlag.REPLACEABLE; } if (texopt_flags.HasFlag(TexOpt.BUMPMAP)) { res.flags |= TextureWrapper.TexFlag.BUMPMAP; } res.scaleUV0 = new Vector2(1, 1); res.scaleUV1 = new Vector2(1, 1); if (res.info != null && 0 != res.info.BumpMap.Length) { res.bumpmap = res.info.BumpMap; } string detailname; if (texopt_flags.HasFlag(TexOpt.DUAL)) { if (res.info.Blend.Length != 0) { res.flags |= TextureWrapper.TexFlag.DUAL; res.BlendType = (CoHBlendMode)res.info.BlendType; res.scaleUV0 = res.info.ScaleST0; res.scaleUV1 = res.info.ScaleST1; res.detailname = res.info.Blend; if (res.BlendType == CoHBlendMode.ADDGLOW && res.detailname.ToLower() == "grey") { res.detailname = "black"; } // copy the 'res' into the handle based storage, and record the handle rd.m_loaded_textures[lookupstring] = res; return(res); } Debug.Log("Detail texture " + res.info.Blend + " does not exist for texture mod" + res.info.name); detailname = "grey"; } else if (lookupstring.ToLower() == "invisible") { detailname = "invisible"; } else { detailname = "grey"; } if (res.BlendType == CoHBlendMode.ADDGLOW && detailname.ToLower() == "grey") { detailname = "black"; } res.detailname = detailname; // copy the 'res' into the handle based storage, and record the handle rd.m_loaded_textures[lookupstring] = res; return(res); }
public void groupApplyModifiers() { RuntimeData rd = RuntimeData.get(); Model model = m_model; if (null == model) { return; } GeometryModifiersData mods = rd.m_modifiers.findGeomModifier(model.name, m_dir); if (null == mods) { return; } if (mods.LodNear != 0.0f) { lod_near = mods.LodNear; } if (mods.LodFar != 0.0f) { lod_far = mods.LodFar; } if (mods.LodNearFade != 0.0f) { lod_near_fade = mods.LodNearFade; } if (mods.LodFarFade != 0.0f) { lod_far_fade = mods.LodFarFade; } if (mods.LodScale != 0.0f) { lod_scale = mods.LodScale; } GroupFlags v1 = (GroupFlags)mods.GroupFlags; shadow_dist = mods.ShadowDist; parent_fade = v1.HasFlag(GroupFlags.ParentFade); region_marker = v1.HasFlag(GroupFlags.RegionMarker); volume_trigger = v1.HasFlag(GroupFlags.VolumeTrigger); water_volume = v1.HasFlag(GroupFlags.WaterVolume); lava_volume = v1.HasFlag(GroupFlags.LavaVolume); sewer_volume = v1.HasFlag(GroupFlags.SewerWaterVolume); door_volume = v1.HasFlag(GroupFlags.DoorVolume); key_light = v1.HasFlag(GroupFlags.KeyLight); tray = v1.HasFlag(GroupFlags.VisTray) | v1.HasFlag(GroupFlags.VisOutside); if (mods.LodNear != 0.0f || mods.LodFar != 0.0f || mods.LodNearFade != 0.0f || mods.LodFarFade != 0.0f || mods.LodScale != 0.0f) { lod_fromtrick = true; } /* * if (mods.node._TrickFlags.HasFlag(TrickFlags.NoColl)) * ; //TODO: disable collisions for this node * if (mods.node._TrickFlags.HasFlag(TrickFlags.SelectOnly)) * ; // set the model's triangles as only selectable ?? ( selection mesh ? ) * if (mods.node._TrickFlags.HasFlag(TrickFlags.NotSelectable)) * ; // */ }