public void FbxAnimStack_Create_HasNamespacePrefix() { // given: var obj = new AnimStack("asdf"); // then: Assert.AreEqual("AnimStack::", obj.GetNameSpacePrefix()); }
static FbxObject CreateAnimStackObject(AnimStack Anim, FbxObjectManager ObjectManager) { var Name = "AnimStack::" + Anim.Name; var Object = ObjectManager.CreateObject("AnimationStack", Name); var Def = Object.Definition; Def.AddValue(Object.Ident); Def.AddValue(Name); Def.AddValue(""); var Properties = Def.AddProperty("Properties70"); var LocalStart = Properties.AddProperty("P"); LocalStart.AddValue("LocalStart"); LocalStart.AddValue("KTime"); LocalStart.AddValue("Time"); LocalStart.AddValue(""); LocalStart.AddValue(FbxHelper.GetFbxSeconds(Anim.LocalStartTime)); var LocalStop = Properties.AddProperty("P"); LocalStop.AddValue("LocalStop"); LocalStop.AddValue("KTime"); LocalStop.AddValue("Time"); LocalStop.AddValue(""); LocalStop.AddValue(FbxHelper.GetFbxSeconds(Anim.LocalEndTime)); var ReferenceStart = Properties.AddProperty("P"); ReferenceStart.AddValue("ReferenceStart"); ReferenceStart.AddValue("KTime"); ReferenceStart.AddValue("Time"); ReferenceStart.AddValue(""); ReferenceStart.AddValue(FbxHelper.GetFbxSeconds(Anim.ReferenceStartTime)); var ReferenceStop = Properties.AddProperty("P"); ReferenceStop.AddValue("ReferenceStop"); ReferenceStop.AddValue("KTime"); ReferenceStop.AddValue("Time"); ReferenceStop.AddValue(""); ReferenceStop.AddValue(FbxHelper.GetFbxSeconds(Anim.ReferenceEndTime)); /* * AnimationStack: 362632224, "AnimStack::Take 001", "" { * Properties70: * { * P: "LocalStart", "KTime", "Time", "",0 * P: "LocalStop", "KTime", "Time", "", 46186158000 * P: "ReferenceStart", "KTime", "Time", "",0 * P: "ReferenceStop", "KTime", "Time", "", 46186158000 * } */ return(Object); }
public void Property_AttachCurveNode_IsAnimated() { // given: var node = new Node("node"); var acn = new AnimCurveNode("acn"); var x = new AnimCurve("x"); var scene = new Scene("scene"); var layer = new AnimLayer("layer"); var stack = new AnimStack("stack"); var time = new FbxTime(0); var key = new AnimCurveKey(time, 1.0f); x.KeyAdd(time, key); scene.ConnectSrcObject(node); scene.ConnectSrcObject(acn); scene.ConnectSrcObject(x); scene.ConnectSrcObject(layer); scene.ConnectSrcObject(stack); layer.ConnectSrcObject(acn); stack.ConnectSrcObject(layer); acn.AddChannel <double>("x", 1.0); acn.ConnectToChannel(x, 0U); // require: Assert.False(node.LclTranslation.IsAnimated()); // when: node.LclTranslation.ConnectSrcObject(acn); // then: Assert.True(node.LclTranslation.IsAnimated()); }
public void Property_MultipleStacks_GetCurveNodeOnlyGetsCurvesOnTheCurrentStack() { // given: var node = new Node("node"); var scene = new Scene("scene"); var acn1 = new AnimCurveNode("acn1"); var ac1 = new AnimCurve("ac1"); var layer1 = new AnimLayer("layer1"); var stack1 = new AnimStack("stack1"); var acn2 = new AnimCurveNode("acn2"); var ac2 = new AnimCurve("ac2"); var layer2 = new AnimLayer("layer2"); var stack2 = new AnimStack("stack2"); var time = new FbxTime(0); var key = new AnimCurveKey(time, 1.0f); ac1.KeyAdd(time, key); var time2 = new FbxTime(0); var key2 = new AnimCurveKey(time2, 1.0f); ac2.KeyAdd(time2, key2); scene.ConnectSrcObject(node); scene.ConnectSrcObject(acn1); scene.ConnectSrcObject(ac1); scene.ConnectSrcObject(layer1); scene.ConnectSrcObject(stack1); scene.ConnectSrcObject(acn2); scene.ConnectSrcObject(ac2); scene.ConnectSrcObject(layer2); scene.ConnectSrcObject(stack2); acn1.AddChannel <double>("x", 1.0); acn1.ConnectToChannel(ac1, 0U); layer1.ConnectSrcObject(acn1); stack1.ConnectSrcObject(layer1); acn2.AddChannel <double>("y", -1.0); acn2.ConnectToChannel(ac2, 0U); layer2.ConnectSrcObject(acn2); stack2.ConnectSrcObject(layer2); scene.SetCurrentAnimationStack(stack1); node.LclTranslation.ConnectSrcObject(acn1); node.LclRotation.ConnectSrcObject(acn2); // require: Assert.AreSame(stack1, scene.GetCurrentAnimationStack()); Assert.AreSame(acn1, node.LclTranslation.GetCurveNode()); Assert.Null(node.LclRotation.GetCurveNode()); // when: scene.SetCurrentAnimationStack(stack2); // then: Assert.Null(node.LclTranslation.GetCurveNode()); Assert.AreSame(acn2, node.LclRotation.GetCurveNode()); }
public static void Export(System.Action <string> WriteLine, Mesh mesh, Matrix4x4 transform, List <string> Comments = null) { // temp objects var MeshAnim = new AnimObject(); MeshAnim.AddFrame(new Vector3(0, 0, 0), Quaternion.identity, 0); MeshAnim.AddFrame(new Vector3(0, 1000, 0), Quaternion.Euler(0, 90, 0), 1); MeshAnim.AddFrame(new Vector3(0, 0, 0), Quaternion.Euler(0, 180, 0), 2); MeshAnim.AddFrame(new Vector3(0, 1000, 0), Quaternion.Euler(0, 270, 0), 3); MeshAnim.AddFrame(new Vector3(0, 0, 0), Quaternion.Euler(0, 359, 0), 4); var AnimStack = new AnimStack("Take001", MeshAnim.GetStartTime(), MeshAnim.GetEndTime()); var Cam = new FbxCamera("Camera1"); Pop.AllocIfNull(ref Comments); Comments.Add("Using WIP PopX.FbxAscii exporter from @soylentgraham"); var Header = GetHeaderProperty(); Header.AddComment(Comments); Export(WriteLine, Header); var ConnectionManager = new FbxConnectionManager(); var ObjectManager = new FbxObjectManager(); //var MeshObject = CreateFbxObject(mesh, transform, ObjectManager); var CameraObject = CreateFbxObject(Cam, transform, ObjectManager, ConnectionManager); var AnimLayerObject = CreateAnimLayerObject(ObjectManager); var AnimStackObject = CreateAnimStackObject(AnimStack, ObjectManager); MakeAnimationNode(MeshAnim, CameraObject, AnimLayerObject, ObjectManager, ConnectionManager); ConnectionManager.Add(new FbxConnection(AnimLayerObject.TypeName, AnimLayerObject.ObjectName, AnimLayerObject, AnimStackObject.TypeName, AnimStackObject.ObjectName, AnimStackObject, FbxRelationType.OO)); var Definitions = GetDefinitionsProperty(ObjectManager); Export(WriteLine, Definitions); Export(WriteLine, ObjectManager); // fake connections after we've exported ObjectManager var SceneMesh = new Mesh(); SceneMesh.name = "Root"; var SceneMeshObject = CreateFbxObject(SceneMesh, Matrix4x4.identity, ObjectManager, FbxObjectManager.RootNodeIdent); //var MeshMaterialObject = CreateFbxObject_Material("DummyMaterial", ObjectManager); //ConnectionManager.Add(new FbxConnection( MeshObject, SceneMeshObject, FbxRelationType.OO)); ConnectionManager.Add(new FbxConnection(CameraObject, SceneMeshObject, FbxRelationType.OO)); //ConnectionManager.Add(new FbxConnection( MeshMaterialObject.TypeName, MeshMaterialObject.ObjectName, MeshMaterialObject, MeshObject.TypeName, MeshObject.ObjectName, MeshObject, FbxRelationType.OO)); Export(WriteLine, ConnectionManager); }