本文整理汇总了C#中Model.SetTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Model.SetTransform方法的具体用法?C# Model.SetTransform怎么用?C# Model.SetTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model.SetTransform方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
//.........这里部分代码省略.........
}
}
}
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]);
}
示例3: 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;
}
示例4: 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);
}
}