public Vector3 PropToCYPRVector3(byte[] buff)//Compressed YawPitchRoll { Vector3 v = new Vector3(0, 0, 0); if (buff == null || buff.Length < 12) { return(v); } UMath mat = new UMath(); UMath.Rotator r = mat.PropToRotator(buff); v = mat.RotatorToVector(r); return(v); }
public Vector3 PropToCYPRVector3(byte[] buff)//Compressed YawPitchRoll { Vector3 v = new Vector3(0, 0, 0); if (buff == null || buff.Length < 12) return v; UMath mat = new UMath(); UMath.Rotator r = mat.PropToRotator(buff); v = mat.RotatorToVector(r); return v; }
private void button13_Click(object sender, EventArgs e) { int source = refO.Level.UStat[refStat].LP.source; int entry = refO.Level.UStat[refStat].LP.sourceentry; int parent = refO.Level.UStat[refStat].index2; int parentidx = refO.Level.UStat[refStat].index3; UPropertyReader UPR = refO.Level.UPR; PCCFile pcc = refO.Level.pcc; UMath math = new UMath(); if (source == 0)//Static Actor { UStaticMeshActor u = new UStaticMeshActor(pcc.EntryToBuff(entry), pcc.names); u.UPR = UPR; u.Deserialize(); int ent = UPR.FindProperty("location", u.props); if(ent!=-1) { ent++; int off1 = (int)pcc.Export[entry].DataOffset; int off2 = u.props[ent].offset + u.props[ent].raw.Length - 12; Vector3 v = UPR.PropToVector3(u.props[ent].raw); v += loc; byte[] buff = BitConverter.GetBytes(v.X); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i] = buff[i]; buff = BitConverter.GetBytes(v.Y); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i + 4] = buff[i]; buff = BitConverter.GetBytes(v.Z); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i + 8] = buff[i]; } ent = UPR.FindProperty("Rotator", u.props); if (ent != -1) { int off1 = (int)pcc.Export[entry].DataOffset; int off2 = u.props[ent].offset + u.props[ent].raw.Length - 12; UMath.Rotator r = math.PropToRotator(u.props[ent].raw); UMath.Rotator r2 = math.IntVectorToRotator(rot); r = r + r2; byte[] buff = BitConverter.GetBytes(r.Pitch); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i] = buff[i]; buff = BitConverter.GetBytes(r.Roll); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i + 4] = buff[i]; buff = BitConverter.GetBytes(r.Yaw); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i + 8] = buff[i]; } } if (source == 1)//Collection { UStaticMeshComponent uc = refO.Level.UStatComp[parentidx]; UStaticMeshCollectionActor u = refO.Level.UStatColl[uc.index3]; int ent = UPR.FindProperty("Scale3D", uc.props); if (ent != -1) { Matrix m = current; Vector3 v = new Vector3(m.M41, m.M42, m.M43); Vector3 v2 = UPR.PropToVector3(uc.props[ent+1].raw); v2.X = 1 / v2.X; v2.Y = 1 / v2.Y; v2.Z = 1 / v2.Z; m.M41 = 0; m.M42 = 0; m.M43 = 0; m *= Matrix.Scaling(v2); m.M41 = v.X; m.M42 = v.Y; m.M43 = v.Z; current = m; } int ent2 = uc.index2; if (ent2 != -1) { int off = u.props[u.props.Count - 1].offset + u.props[u.props.Count - 1].raw.Length + (int)pcc.Export[entry].DataOffset + ent2 * 16 * 4; byte[] buff = BitConverter.GetBytes(current.M11); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M12); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M13); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M14); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M21); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M22); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M23); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M24); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M31); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M32); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M33); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M34); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M41); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M42); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M43); WriteMemory(off, buff); off += 4; buff = BitConverter.GetBytes(current.M44); WriteMemory(off, buff); off += 4; } } if (source == 2)//Interp Actor { UInterpActor u = new UInterpActor(pcc.EntryToBuff(entry), pcc.names); u.UPR = UPR; u.Deserialize(); int ent = UPR.FindProperty("location", u.props); if (ent != -1) { ent++; int off1 = (int)pcc.Export[entry].DataOffset; int off2 = u.props[ent].offset + u.props[ent].raw.Length - 12; Vector3 v = UPR.PropToVector3(u.props[ent].raw); v += loc; byte[] buff = BitConverter.GetBytes(v.X); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i] = buff[i]; buff = BitConverter.GetBytes(v.Y); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i + 4] = buff[i]; buff = BitConverter.GetBytes(v.Z); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i + 8] = buff[i]; } ent = UPR.FindProperty("Rotator", u.props); if (ent != -1) { int off1 = (int)pcc.Export[entry].DataOffset; int off2 = u.props[ent].offset + u.props[ent].raw.Length - 12; UMath.Rotator r = math.PropToRotator(u.props[ent].raw); UMath.Rotator r2 = math.IntVectorToRotator(rot); r = r + r2; byte[] buff = BitConverter.GetBytes(r.Pitch); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i] = buff[i]; buff = BitConverter.GetBytes(r.Roll); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i + 4] = buff[i]; buff = BitConverter.GetBytes(r.Yaw); for (int i = 0; i < 4; i++) pcc.memory[off1 + off2 + i + 8] = buff[i]; } } }