public multiChannelCurve(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, parent, name) { NumChannels = new CUInt32(cr2w, this, nameof(NumChannels)); InterPolationType = new CEnum <EInterPolationType>(cr2w, this, nameof(InterPolationType)); LinkType = new CEnum <ELinkType>(cr2w, this, nameof(LinkType)); Alignment = new CUInt32(cr2w, this, nameof(Alignment)); Data = new CByteArray(cr2w, this, nameof(Data)); }
public override void Write(BinaryWriter file) { CUInt32 count = new CUInt32(cr2w, null, "") { val = (uint)Elements.Count }; count.Write(file); base.Write(file); }
public CEntityBufferType2(CR2WFile cr2w) : base(cr2w) { componentName = new CName(cr2w) { Name = "Name", }; sizeofdata = new CUInt32(cr2w) { Name = "Size", }; variables = new CBufferUInt32 <CVariableWrapper>(cr2w, _ => new CVariableWrapper(_)); }
/// <summary> /// Try to apply animation to rig. /// </summary> public void Apply(Rig rig) { bones.Clear(); Vector3Df current; for (int i = 0; i < orientations.Count; i++) { Bone bone = new Bone(); bones.Add(bone); var animBone = currentBones[i]; var positionVar = animBone.Position; CFloat dtPos = positionVar.Dt; CUInt32 dataAddrPos = positionVar.DataAddr; CUInt32 dataAddrFallbackPos = positionVar.DataAddrFallback; CUInt16 numframesPos = positionVar.NumFrames; if (dtPos != null) bone.position_dt = dtPos.val; if (dataAddrPos != null) bone.position_dataAddr = dataAddrPos.val; if (dataAddrFallbackPos != null) bone.position_dataAddrFallback = dataAddrFallbackPos.val; if (numframesPos != null) bone.position_numFrames = numframesPos.val; var orientationVar = animBone.Orientation; CFloat dtRot = orientationVar.Dt; CUInt32 dataAddrRot = orientationVar.DataAddr; CUInt32 dataAddrFallbackRot = orientationVar.DataAddrFallback; CUInt16 numframesRot = orientationVar.NumFrames; if (dtRot != null) bone.rotation_dt = dtRot.val; if (dataAddrRot != null) bone.rotation_dataAddr = dataAddrRot.val; if (dataAddrFallbackRot != null) bone.rotation_dataAddrFallback = dataAddrFallbackRot.val; if (numframesRot != null) bone.rotation_numFrames = numframesRot.val; var scaleVar = animBone.Scale; CFloat dtScale = scaleVar.Dt; CUInt32 dataAddrScale = scaleVar.DataAddr; CUInt32 dataAddrFallbackScale = scaleVar.DataAddrFallback; CUInt16 numframesScale = scaleVar.NumFrames; if (dtScale != null) bone.scale_dt = dtScale.val; if (dataAddrScale != null) bone.scale_dataAddr = dataAddrScale.val; if (dataAddrFallbackScale != null) bone.scale_dataAddrFallback = dataAddrFallbackScale.val; if (numframesScale != null) bone.scale_numFrames = numframesScale.val; bone.BoneName = rig.meshSkeleton.names[i]; for (int j = 0; j < positions[i].Count; j++) { bone.positionFrames.Add(new Vector(positions[i][j].X, positions[i][j].Y, positions[i][j].Z)); } for (int j = 0; j < orientations[i].Count; j++) { current = orientationsEuler[i][j]; bone.rotationFrames.Add(orientations[i][j]); } for (int j = 0; j < scales[i].Count; j++) { bone.scaleFrames.Add(new Vector(scales[i][j].X, scales[i][j].Y, scales[i][j].Z)); } } exportData.bones = bones; }
private void ReadBytes(int bytestart, BinaryReader reader) { reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CVector(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CVector"; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CUInt64(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CUInt64"; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CUInt32(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CUInt32"; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CUInt16(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CUInt16"; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CUInt8(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CUInt8"; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CDynamicInt(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CDynamicInt"; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CFloat(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CFloat"; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CName(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CName"; var valueTest = v.Value; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CHandle(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CHandle"; var valueTest = v.Value; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = new CSoft(File); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "CSoft"; var valueTest = v.Value; } catch { } reader.BaseStream.Seek(bytestart, SeekOrigin.Begin); try { var obj = File.ReadVariable(reader); obj.Read(reader, (uint)(bytes.Length - bytestart)); var v = CreatePropertyLayout(obj); v.Endpos = (int)reader.BaseStream.Position; v.HexValue = bytes[bytestart].ToString("X2"); v.Method = "ReadVariable"; } catch { } }
/// <summary> /// Try to apply animation to rig. /// </summary> public void Apply(Rig rig) { bones.Clear(); Vector3Df current; for (int i = 0; i < orientations.Count; i++) { Bone bone = new Bone(); bones.Add(bone); CVector animBone = currentBones[i]; CVector positionVar = animBone.GetVariableByName("position") as CVector; CFloat dtPos = positionVar.GetVariableByName("dt") as CFloat; CUInt32 dataAddrPos = positionVar.GetVariableByName("dataAddr") as CUInt32; CUInt32 dataAddrFallbackPos = positionVar.GetVariableByName("dataAddrFallback") as CUInt32; CUInt16 numframesPos = positionVar.GetVariableByName("numFrames") as CUInt16; if (dtPos != null) { bone.position_dt = dtPos.val; } if (dataAddrPos != null) { bone.position_dataAddr = dataAddrPos.val; } if (dataAddrFallbackPos != null) { bone.position_dataAddrFallback = dataAddrFallbackPos.val; } if (numframesPos != null) { bone.position_numFrames = numframesPos.val; } CVector orientationVar = animBone.GetVariableByName("orientation") as CVector; CFloat dtRot = orientationVar.GetVariableByName("dt") as CFloat; CUInt32 dataAddrRot = orientationVar.GetVariableByName("dataAddr") as CUInt32; CUInt32 dataAddrFallbackRot = orientationVar.GetVariableByName("dataAddrFallback") as CUInt32; CUInt16 numframesRot = orientationVar.GetVariableByName("numFrames") as CUInt16; if (dtRot != null) { bone.rotation_dt = dtRot.val; } if (dataAddrRot != null) { bone.rotation_dataAddr = dataAddrRot.val; } if (dataAddrFallbackRot != null) { bone.rotation_dataAddrFallback = dataAddrFallbackRot.val; } if (numframesRot != null) { bone.rotation_numFrames = numframesRot.val; } CVector scaleVar = animBone.GetVariableByName("scale") as CVector; CFloat dtScale = scaleVar.GetVariableByName("dt") as CFloat; CUInt32 dataAddrScale = scaleVar.GetVariableByName("dataAddr") as CUInt32; CUInt32 dataAddrFallbackScale = scaleVar.GetVariableByName("dataAddrFallback") as CUInt32; CUInt16 numframesScale = scaleVar.GetVariableByName("numFrames") as CUInt16; if (dtScale != null) { bone.scale_dt = dtScale.val; } if (dataAddrScale != null) { bone.scale_dataAddr = dataAddrScale.val; } if (dataAddrFallbackScale != null) { bone.scale_dataAddrFallback = dataAddrFallbackScale.val; } if (numframesScale != null) { bone.scale_numFrames = numframesScale.val; } bone.BoneName = rig.meshSkeleton.names[i]; for (int j = 0; j < positions[i].Count; j++) { bone.positionFrames.Add(new Vector(positions[i][j].X, positions[i][j].Y, positions[i][j].Z)); } for (int j = 0; j < orientations[i].Count; j++) { current = orientationsEuler[i][j]; bone.rotationFrames.Add(orientations[i][j]); } for (int j = 0; j < scales[i].Count; j++) { bone.scaleFrames.Add(new Vector(scales[i][j].X, scales[i][j].Y, scales[i][j].Z)); } } exportData.bones = bones; }