本文整理汇总了C#中Model.SetName方法的典型用法代码示例。如果您正苦于以下问题:C# Model.SetName方法的具体用法?C# Model.SetName怎么用?C# Model.SetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model.SetName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessCNT
static void ProcessCNT(CNT cnt, Model model, int ParentBoneIndex = 0)
{
int boneIndex;
SceneManager.Current.UpdateProgress(string.Format("Processing {0}", cnt.Name));
if (cnt.Section == CNT.NodeType.MODL || cnt.Section == CNT.NodeType.SKIN)
{
var m = SceneManager.Current.Content.Load<Model, MDLImporter>(cnt.Model, rootPath);
boneIndex = model.AddMesh(m.Meshes[0], ParentBoneIndex);
}
else
{
boneIndex = model.AddMesh(null, ParentBoneIndex);
switch (cnt.Section)
{
case CNT.NodeType.LITg:
model.Bones[boneIndex].Type = BoneType.Light;
if (cnt.EmbeddedLight)
{
model.Bones[boneIndex].Attachment = cnt.Light;
}
else
{
model.Bones[boneIndex].Attachment = SceneManager.Current.Content.Load<Model, LIGHTImporter>(cnt.LightName, rootPath).Bones[0].Attachment;
model.Bones[boneIndex].AttachmentFile = cnt.LightName;
}
break;
case CNT.NodeType.VFXI:
model.Bones[boneIndex].Type = BoneType.VFX;
model.Bones[boneIndex].AttachmentFile = cnt.VFXFile;
break;
}
}
model.SetName(cnt.Name, boneIndex);
model.SetTransform(
new Matrix4 (
cnt.Transform.M11, cnt.Transform.M12, cnt.Transform.M13, 0,
cnt.Transform.M21, cnt.Transform.M22, cnt.Transform.M23, 0,
cnt.Transform.M31, cnt.Transform.M32, cnt.Transform.M33, 0,
cnt.Transform.M41, cnt.Transform.M42, cnt.Transform.M43, 1
), boneIndex);
foreach (CNT subcnt in cnt.Children)
{
ProcessCNT(subcnt, model, boneIndex);
}
}
示例2: Import
public override Asset Import(string path)
{
MSHS mshs = MSHS.Load(path);
Model model = new Model();
string name = Path.GetFileNameWithoutExtension(path);
int meshnum = 0;
foreach (var tdrmesh in mshs.Meshes)
{
ModelMesh mesh = new ModelMesh();
mesh.Name = name + meshnum++.ToString("0000");
ModelMeshPart meshpart = new ModelMeshPart();
meshpart.PrimitiveType = OpenTK.Graphics.OpenGL.PrimitiveType.Triangles;
SceneManager.Current.UpdateProgress(string.Format("Processing {0}", mesh.Name));
for (int i = 0; i < tdrmesh.Faces.Count; i++)
{
var face = tdrmesh.Faces[i];
var v1 = tdrmesh.Vertexes[face.V1];
var v2 = tdrmesh.Vertexes[face.V2];
var v3 = tdrmesh.Vertexes[face.V3];
meshpart.AddFace(
new OpenTK.Vector3[] {
new OpenTK.Vector3(v1.Position.X, v1.Position.Y, v1.Position.Z),
new OpenTK.Vector3(v2.Position.X, v2.Position.Y, v2.Position.Z),
new OpenTK.Vector3(v3.Position.X, v3.Position.Y, v3.Position.Z)
},
new OpenTK.Vector3[] {
new OpenTK.Vector3(v1.Normal.X, v1.Normal.Y, v1.Normal.Z),
new OpenTK.Vector3(v2.Normal.X, v2.Normal.Y, v2.Normal.Z),
new OpenTK.Vector3(v3.Normal.X, v3.Normal.Y, v3.Normal.Z)
},
new OpenTK.Vector2[] {
new OpenTK.Vector2(v1.UV.X, v1.UV.Y),
new OpenTK.Vector2(v2.UV.X, v2.UV.Y),
new OpenTK.Vector2(v3.UV.X, v3.UV.Y)
}
);
}
mesh.AddModelMeshPart(meshpart);
model.SetName(mesh.Name, model.AddMesh(mesh));
}
return model;
}
示例3: Import
public override Asset Import(string path)
{
LIGHT light = LIGHT.Load(path);
Model model = new Model();
SceneManager.Current.UpdateProgress(string.Format("Processing {0}", Path.GetFileName(path)));
int boneIndex = model.AddMesh(null, 0);
model.SetName(Path.GetFileNameWithoutExtension(path), boneIndex);
model.Bones[boneIndex].Type = BoneType.Light;
model.Bones[boneIndex].Attachment = light;
SceneManager.Current.UpdateProgress(string.Format("Loaded {0}", Path.GetFileName(path)));
return model;
}
示例4: Import
//.........这里部分代码省略.........
processedGroupCount++;
}
}
}
components.Add((long)element.Properties[0].Value, parts);
SceneManager.Current.UpdateProgress(string.Format("Processed {0}", element.Properties[1].Value));
}
string[] connectionOrder = new string[] { "System.Collections.Generic.List`1[Flummery.ModelMeshPart]", "Flummery.Texture", "Flummery.Material", "Flummery.ModelMesh" };
var connections = fbx.Elements.Find(e => e.ID == "Connections");
HashSet<long> loaded = new HashSet<long>();
foreach (var connectionType in connectionOrder)
{
var connectionsOfType = connections.Children.Where(c => components.ContainsKey((long)c.Properties[1].Value) && components[(long)c.Properties[1].Value].GetType().ToString() == connectionType);
foreach (var connection in connectionsOfType)
{
long keyA = (long)connection.Properties[1].Value;
long keyB = (long)connection.Properties[2].Value;
Console.WriteLine("{0} is connected to {1} :: {2}", keyA, keyB, connectionType);
switch (connectionType)
{
case "Flummery.ModelMesh":
int boneID;
if (keyB == 0)
{
boneID = model.AddMesh((ModelMesh)components[keyA]);
model.SetName(((ModelMesh)components[keyA]).Name, boneID);
if (transforms.ContainsKey(keyA)) { model.SetTransform(transforms[keyA], boneID); }
}
else
{
var parent = model.FindMesh(keyB);
if (parent != null)
{
boneID = model.AddMesh((ModelMesh)components[keyA], parent.Parent.Index);
model.SetName(((ModelMesh)components[keyA]).Name, boneID);
if (transforms.ContainsKey(keyA)) { model.SetTransform(transforms[keyA], boneID); }
}
else
{
if (!components.ContainsKey(keyB))
{
Console.WriteLine("Components doesn't contain {0}", keyB);
}
else
{
Console.WriteLine("Couldn't find {0}", ((ModelMesh)components[keyB]).Name);
}
}
}
break;
case "Flummery.Texture":
if (components.ContainsKey(keyB) && components[keyB].GetType().ToString() == "Flummery.Material")
{
if (loaded.Add(keyB))
{
((Material)components[keyB]).Texture = (Texture)components[keyA];
SceneManager.Current.Add((Material)components[keyB]);
示例5: Import
public override Asset Import(string path)
{
ACT act = ACT.Load(path);
Model model = new Model();
int boneIndex = 0;
string fileName = path.Substring(path.LastIndexOf("\\") + 1);
path = path.Replace(fileName, "");
Model dat = SceneManager.Current.Content.Load<Model, DATImporter>(fileName.Replace(".act", ".dat", StringComparison.OrdinalIgnoreCase), path);
Material material = null;
foreach (var section in act.Sections)
{
switch (section.Section)
{
case Section.Name:
boneIndex = model.AddMesh(null, boneIndex);
model.SetName(section.Identifier, boneIndex);
material = null;
break;
case Section.Material:
material = (Material)SceneManager.Current.Materials.Entries.Find(m => m.Name == section.Material);
if (material == null)
{
material = new Material() { Name = section.Material };
SceneManager.Current.Add(material);
}
break;
case Section.Model:
model.SetMesh(new ModelMesh(dat.FindMesh((section.Model.Contains(".") ? section.Model.Substring(0, section.Model.IndexOf(".")) : section.Model))), boneIndex);
if (material != null)
{
foreach (var modelmesh in model.Meshes)
{
foreach (var meshpart in modelmesh.MeshParts)
{
if (meshpart.Material == null) { meshpart.Material = material; }
}
}
}
break;
case Section.Matrix:
model.SetTransform(
new Matrix4(
section.Transform.M11, section.Transform.M12, section.Transform.M13, 0,
section.Transform.M21, section.Transform.M22, section.Transform.M23, 0,
section.Transform.M31, section.Transform.M32, section.Transform.M33, 0,
section.Transform.M41, section.Transform.M42, section.Transform.M43, 1
), boneIndex
);
break;
case Section.SubLevelBegin:
break;
case Section.SubLevelEnd:
boneIndex = model.Bones[boneIndex].Parent.Index;
break;
}
}
SceneManager.Current.UpdateProgress(string.Format("Loaded {0}", fileName));
return model;
}
示例6: Import
public override Asset Import(string path)
{
BOM bom = BOM.Load(path);
Model model = new Model();
model.SupportingDocuments["Source"] = bom;
for (int i = 0; i < bom.Meshes.Count; i++)
{
var bommesh = bom.Meshes[i];
ModelMesh mesh = new ModelMesh();
ModelMeshPart meshpart = new ModelMeshPart();
if (i < 4)
{
for (int j = 0; j < bommesh.IndexBuffer.Count; j += 3)
{
int p0 = bommesh.IndexBuffer[j + 0];
int p1 = bommesh.IndexBuffer[j + 1];
int p2 = bommesh.IndexBuffer[j + 2];
meshpart.AddFace(
new Vector3[] {
new Vector3(bom.Verts[p0].Position.X, bom.Verts[p0].Position.Y, bom.Verts[p0].Position.Z),
new Vector3(bom.Verts[p1].Position.X, bom.Verts[p1].Position.Y, bom.Verts[p1].Position.Z),
new Vector3(bom.Verts[p2].Position.X, bom.Verts[p2].Position.Y, bom.Verts[p2].Position.Z),
},
new Vector3[] {
new Vector3(bom.Verts[p0].Normal.X, bom.Verts[p0].Normal.Y, bom.Verts[p0].Normal.Z),
new Vector3(bom.Verts[p1].Normal.X, bom.Verts[p1].Normal.Y, bom.Verts[p1].Normal.Z),
new Vector3(bom.Verts[p2].Normal.X, bom.Verts[p2].Normal.Y, bom.Verts[p2].Normal.Z),
},
new Vector2[] {
Vector2.Zero,
Vector2.Zero,
Vector2.Zero
}
);
}
}
else
{
// Process triangle strip
for (int j = 0; j < bommesh.IndexBuffer.Count - 2; j++)
{
BOMVertex v0, v1, v2;
v0 = bom.Verts[bommesh.IndexBuffer[j + 0]];
if (j % 2 != 0)
{
v1 = bom.Verts[bommesh.IndexBuffer[j + 1]];
v2 = bom.Verts[bommesh.IndexBuffer[j + 2]];
}
else
{
v1 = bom.Verts[bommesh.IndexBuffer[j + 2]];
v2 = bom.Verts[bommesh.IndexBuffer[j + 1]];
}
meshpart.AddFace(
new Vector3[] {
new Vector3(v0.Position.X, v0.Position.Y, v0.Position.Z),
new Vector3(v1.Position.X, v1.Position.Y, v1.Position.Z),
new Vector3(v2.Position.X, v2.Position.Y, v2.Position.Z)
},
new Vector3[] {
new Vector3(v0.Normal.X, v0.Normal.Y, v0.Normal.Z),
new Vector3(v1.Normal.X, v1.Normal.Y, v1.Normal.Z),
new Vector3(v2.Normal.X, v2.Normal.Y, v2.Normal.Z)
},
new Vector2[] {
Vector2.Zero,
Vector2.Zero,
Vector2.Zero
}
);
}
}
mesh.AddModelMeshPart(meshpart);
mesh.Name = bom.Name + "_" + i;
model.SetName(bom.Name, model.AddMesh(mesh));
}
return model;
}
示例7: Import
public override Asset Import(string path)
{
DAT dat = DAT.Load(path);
SceneManager.Current.Content.LoadMany<MaterialList, MaterialImporter>(Path.GetFileName(path).Replace(".dat", ".mat", StringComparison.OrdinalIgnoreCase), Path.GetDirectoryName(path) + "\\", true);
Model model = new Model();
foreach (var datmesh in dat.DatMeshes)
{
Console.WriteLine(datmesh.Name);
datmesh.Mesh.GenerateNormals();
ModelMesh mesh = new ModelMesh();
mesh.Name = (datmesh.Name.Contains(".") ? datmesh.Name.Substring(0, datmesh.Name.IndexOf(".")) : datmesh.Name);
SceneManager.Current.UpdateProgress(string.Format("Processing {0}", mesh.Name));
for (int i = -1; i < datmesh.Mesh.Materials.Count; i++)
{
var meshpart = new ModelMeshPart();
if (i > -1)
{
var material = SceneManager.Current.Materials.Entries.Find(m => m.Name == datmesh.Mesh.Materials[i]);
if (material == null)
{
material = new Material { Name = datmesh.Mesh.Materials[i] };
SceneManager.Current.Add(material);
}
meshpart.Material = (Material)material;
}
foreach (var face in datmesh.Mesh.Faces.Where(f => f.MaterialID == i))
{
int smoothingGroup = (face.SmoothingGroup << 8);
meshpart.AddFace(
new OpenTK.Vector3[] {
new OpenTK.Vector3(datmesh.Mesh.Verts[face.V1].X, datmesh.Mesh.Verts[face.V1].Y, datmesh.Mesh.Verts[face.V1].Z),
new OpenTK.Vector3(datmesh.Mesh.Verts[face.V2].X, datmesh.Mesh.Verts[face.V2].Y, datmesh.Mesh.Verts[face.V2].Z),
new OpenTK.Vector3(datmesh.Mesh.Verts[face.V3].X, datmesh.Mesh.Verts[face.V3].Y, datmesh.Mesh.Verts[face.V3].Z)
},
new OpenTK.Vector3[] {
new OpenTK.Vector3(datmesh.Mesh.Normals[smoothingGroup + face.V1].X, datmesh.Mesh.Normals[smoothingGroup + face.V1].Y, datmesh.Mesh.Normals[smoothingGroup + face.V1].Z),
new OpenTK.Vector3(datmesh.Mesh.Normals[smoothingGroup + face.V2].X, datmesh.Mesh.Normals[smoothingGroup + face.V2].Y, datmesh.Mesh.Normals[smoothingGroup + face.V2].Z),
new OpenTK.Vector3(datmesh.Mesh.Normals[smoothingGroup + face.V3].X, datmesh.Mesh.Normals[smoothingGroup + face.V3].Y, datmesh.Mesh.Normals[smoothingGroup + face.V3].Z)
},
new OpenTK.Vector2[] {
(datmesh.Mesh.HasUVs ? new OpenTK.Vector2(datmesh.Mesh.UVs[face.UV1].X, datmesh.Mesh.UVs[face.UV1].Y) : OpenTK.Vector2.Zero),
(datmesh.Mesh.HasUVs ? new OpenTK.Vector2(datmesh.Mesh.UVs[face.UV2].X, datmesh.Mesh.UVs[face.UV2].Y) : OpenTK.Vector2.Zero),
(datmesh.Mesh.HasUVs ? new OpenTK.Vector2(datmesh.Mesh.UVs[face.UV3].X, datmesh.Mesh.UVs[face.UV3].Y) : OpenTK.Vector2.Zero)
}
);
}
mesh.AddModelMeshPart(meshpart, false);
}
for (int i = mesh.MeshParts.Count - 1; i >= 0; i--)
{
if (mesh.MeshParts[i].VertexCount == 0)
{
mesh.MeshParts.RemoveAt(i);
}
else
{
mesh.MeshParts[i].Finalise();
}
}
model.SetName(mesh.Name, model.AddMesh(mesh));
}
return model;
}
示例8: ProcessNode
static void ProcessNode(TDRNode node, Model model, Model mshses, HIE hie, int ParentBoneIndex = 0)
{
int boneIndex = ParentBoneIndex;
if (exit) { return; }
switch (node.Type)
{
case TDRNode.NodeType.Matrix:
boneIndex = model.AddMesh(null, boneIndex);
model.SetName(node.Name, boneIndex);
model.SetTransform(
new Matrix4 (
node.Transform.M11, node.Transform.M12, node.Transform.M13, 0,
node.Transform.M21, node.Transform.M22, node.Transform.M23, 0,
node.Transform.M31, node.Transform.M32, node.Transform.M33, 0,
node.Transform.M41, node.Transform.M42, node.Transform.M43, 1
), boneIndex);
break;
case TDRNode.NodeType.Mesh:
int index = node.Index;
mshses.Meshes[index].MeshParts[0].Material = material;
if (model.Bones[ParentBoneIndex].Mesh == null)
{
model.SetMesh(mshses.Meshes[index], boneIndex);
//exit = true;
//Console.WriteLine("Adding mesh #{0} \"{1}\" to bone #{2} \"{3}\"", index, mshses.Meshes[index].Name, boneIndex, model.Bones[boneIndex].Name);
}
else
{
boneIndex = model.AddMesh(mshses.Meshes[index], ParentBoneIndex);
model.SetName(mshses.Meshes[index].Name, boneIndex);
//model.SetName(mshses.Meshes[index].Name, model.AddMesh(mshses.Meshes[index], ParentBoneIndex));
//Console.WriteLine("Adding mesh #{0} \"{1}\" to brand new bone", index, mshses.Meshes[index].Name);
}
break;
case TDRNode.NodeType.Texture:
if (node.Index > -1)
{
material = SceneManager.Current.Content.Load<Material, TXImporter>(hie.Textures[node.Index]);
}
else
{
material = null;
}
break;
}
foreach (var child in node.Children)
{
ProcessNode(child, model, mshses, hie, boneIndex);
}
}
示例9: Import
//.........这里部分代码省略.........
ModelMeshPart meshpart = new ModelMeshPart();
var mdlmesh = mdl.GetMesh(i);
meshpart.Material = SceneManager.Current.Content.Load<Material, MaterialImporter>(mdlmesh.Name, Path.GetDirectoryName(path), true);
if (bUsePrepData)
{
foreach (var f in mdl.Faces.Where(f => f.MaterialID == i))
{
for (int j = 0; j < 3; j++)
{
if (!newIndex.ContainsKey(f.Verts[j]))
{
var v = mdl.Vertices[f.Verts[j]];
int index = meshpart.AddVertex(new Vector3(v.Position.X, v.Position.Y, v.Position.Z), new Vector3(v.Normal.X, v.Normal.Y, v.Normal.Z), new Vector2(v.UV.X, v.UV.Y), new Vector2(v.UV2.X, v.UV2.Y), v.Colour, false);
newIndex.Add(f.Verts[j], index);
}
}
meshpart.AddFace(
newIndex[f.Verts[0]],
newIndex[f.Verts[1]],
newIndex[f.Verts[2]]
);
}
}
else
{
int[] verts = new int[3];
for (int j = 0; j < mdlmesh.StripList.Count - 2; j++)
{
if (mdlmesh.StripList[j + 2].Degenerate) { continue; }
verts[0] = mdlmesh.StripList[j + 0].Index;
if (j % 2 == 0)
{
verts[1] = mdlmesh.StripList[j + 1].Index;
verts[2] = mdlmesh.StripList[j + 2].Index;
}
else
{
verts[1] = mdlmesh.StripList[j + 2].Index;
verts[2] = mdlmesh.StripList[j + 1].Index;
}
for (int k = 0; k < 3; k++)
{
if (!newIndex.ContainsKey(verts[k]))
{
var v = mdl.Vertices[verts[k]];
int index = meshpart.AddVertex(new Vector3(v.Position.X, v.Position.Y, v.Position.Z), new Vector3(v.Normal.X, v.Normal.Y, v.Normal.Z), new Vector2(v.UV.X, v.UV.Y), new Vector2(v.UV2.X, v.UV2.Y), v.Colour, false);
newIndex.Add(verts[k], index);
}
}
meshpart.AddFace(
newIndex[verts[0]],
newIndex[verts[1]],
newIndex[verts[2]]
);
}
// Process patch list
for (int j = 0; j < mdlmesh.TriList.Count; j += 3)
{
verts[0] = mdlmesh.TriList[j + 0].Index;
verts[1] = mdlmesh.TriList[j + 1].Index;
verts[2] = mdlmesh.TriList[j + 2].Index;
for (int k = 0; k < 3; k++)
{
if (!newIndex.ContainsKey(verts[k]))
{
var v = mdl.Vertices[verts[k]];
int index = meshpart.AddVertex(new Vector3(v.Position.X, v.Position.Y, v.Position.Z), new Vector3(v.Normal.X, v.Normal.Y, v.Normal.Z), new Vector2(v.UV.X, v.UV.Y), new Vector2(v.UV2.X, v.UV2.Y), v.Colour, false);
newIndex.Add(verts[k], index);
}
}
meshpart.AddFace(
newIndex[verts[0]],
newIndex[verts[1]],
newIndex[verts[2]]
);
}
}
mesh.AddModelMeshPart(meshpart);
Console.WriteLine(meshpart.VertexCount / 3);
}
mesh.Name = mdl.Name;
model.SetName(mdl.Name, model.AddMesh(mesh));
return model;
}