public void FillData(string _filename, ref Entity _entity) { filename = _filename; entity = _entity; components = new List<ModelComponent>(); ModelComponent m; Pass p; String foundPath = ""; FileInfoListPtr fileInfos; FileInfoList.Iterator it; Mesh.Const_SubMeshNameMap map = entity.GetMesh().GetSubMeshNameMap(); for (uint i = 0; i < map.Count; i++) { for (Mesh.Const_SubMeshNameMap.ConstIterator start = map.Begin(); start != map.End(); start++) { if (start.Value == i) { // Name m = new ModelComponent(start.Key); // SubEntity m.SubEntity = entity.GetSubEntity(start.Key); // Type (Button, Joystick, Body?) if(start.Key.Contains("Button") || start.Key.Contains("Plunger") || start.Key.Contains("Cylinder")) m.Type = FragmentType.BUTTON; else if(start.Key.Contains("Balltop") || start.Key.Contains("Shaft") || start.Key.Contains("Dust")) m.Type = FragmentType.JOYSTICK; else m.Type = FragmentType.MODEL; //m.Parent =; // Texture p = m.SubEntity.GetMaterial().GetBestTechnique().GetPass(0); if(p.NumTextureUnitStates > 0) { // Set the texture m.Texture = TextureManager.Singleton.GetByName(p.GetTextureUnitState(0).TextureName); // Get a bitmap version to display foundPath = m.Texture.Name; fileInfos = ResourceGroupManager.Singleton.FindResourceFileInfo("General", foundPath ); it = fileInfos.Begin(); if(it != fileInfos.End()) foundPath = it.Value.archive.Name + "/" + foundPath; else foundPath = ""; m.TextureImage = new Bitmap(foundPath); } else { m.Texture = null; // TODO: Put in a no texture image m.TextureImage = null; } // Color m.Color = Color.White; components.Add(m); break; } } } }
public void AddComponent(ModelComponent frag) { AddComponent(frag.Name, frag.Type, frag.Parent); }
public bool LoadModel(string modelPath) { mainStick = sceneMgr.CreateEntity("Stick", modelPath); mainStick.CastShadows = true; SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("StickNode"); node.AttachObject(mainStick); node.Position = new Mogre.Vector3(0, 10, 0); //node.Rotate(Mogre.Vector3.UNIT_X, Mogre.Math.PI); //node.Rotate(Mogre.Vector3.UNIT_Y, Mogre.Math.PI); ArcadeStickData.Instance.FillData(modelPath, ref mainStick); Mesh.Const_SubMeshNameMap map = mainStick.GetMesh().GetSubMeshNameMap(); ModelComponent frag; for (uint i = 0; i < map.Count; i++) { for (Mesh.Const_SubMeshNameMap.ConstIterator start = map.Begin(); start != map.End(); start++) { if (start.Value == i) { frag = new ModelComponent(start.Key); Messenger<ModelComponent>.Broadcast("AddFragment", frag); break; } } } return true; }