-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FXCompiler made the program crash on start if Microsoft SDK is not installed.
- Loading branch information
Showing
14 changed files
with
483 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package sporemodder.file.anim; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import emord.filestructures.MemoryStream; | ||
import emord.filestructures.StreamReader; | ||
import sporemodder.MainApp; | ||
import sporemodder.file.argscript.ArgScriptWriter; | ||
|
||
public class Animation { | ||
|
||
private static final int MAGIC = 0x4D494E41; | ||
|
||
private final List<AnimationChannel> channels = new ArrayList<>(); | ||
|
||
public void read(StreamReader stream) throws IOException { | ||
int magic = stream.readLEInt(); | ||
if (magic != MAGIC) { | ||
throw new IOException("Unsupported animation magic: 0x" + Integer.toHexString(magic)); | ||
} | ||
|
||
DataStructure data = new DataStructure(stream); | ||
data.setPointer(0); | ||
|
||
int channelCount = data.getInt(0x144); | ||
long channelPtr = data.getUInt(0x148); | ||
|
||
for (int i = 0; i < channelCount; ++i) { | ||
data.setPointer(channelPtr); | ||
long ptr = data.getUInt(4 * i); | ||
|
||
data.setPointer(ptr); | ||
AnimationChannel channel = new AnimationChannel(); | ||
channel.read(data); | ||
channels.add(channel); | ||
} | ||
} | ||
|
||
public void toArgScript(ArgScriptWriter writer, StreamReader stream) throws IOException { | ||
DataStructure data = new DataStructure(stream); | ||
data.setPointer(0); | ||
|
||
for (AnimationChannel channel : channels) { | ||
channel.toArgScript(writer, data); | ||
writer.blankLine(); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
String path = "C:\\Users\\Eric\\Desktop\\#30EF4216.animation"; | ||
MainApp.testInit(); | ||
|
||
try (MemoryStream stream = new MemoryStream(Files.readAllBytes(new File(path).toPath()))) { | ||
|
||
Animation animation = new Animation(); | ||
animation.read(stream); | ||
|
||
ArgScriptWriter writer = new ArgScriptWriter(); | ||
animation.toArgScript(writer, stream); | ||
|
||
System.out.println(writer.toString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package sporemodder.file.anim; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import emord.filestructures.Stream.StringEncoding; | ||
import sporemodder.file.argscript.ArgScriptWriter; | ||
|
||
public class AnimationChannel { | ||
|
||
private final static int MAGIC = 0x4E414843; | ||
|
||
public String name; | ||
public int field_8C; | ||
public int keyframeCount; | ||
public long keyframePtr; | ||
public final List<ChannelComponent> components = new ArrayList<>(); | ||
|
||
public void read(DataStructure stream) throws IOException { | ||
stream.getStream().seek(stream.getPointer()); | ||
|
||
int magic = stream.getStream().readLEInt(); | ||
if (magic != MAGIC) { | ||
throw new IOException("Unsupported channel magic: 0x" + Integer.toHexString(magic)); | ||
} | ||
|
||
stream.getStream().skip(4); | ||
name = stream.getStream().readCString(StringEncoding.ASCII); | ||
|
||
field_8C = stream.getInt(0x8C); | ||
|
||
keyframeCount = stream.getInt(0xD4); // ? | ||
keyframePtr = stream.getUInt(0xD8); | ||
int count = stream.getInt(0xDC); | ||
long ptr = stream.getUInt(0xE0); | ||
System.out.println(name + " " + field_8C + "\tkeyframes[" + keyframeCount + "] 0x" + Integer.toHexString(stream.getInt(0xD8))); | ||
|
||
// each item of size 32 | ||
|
||
for (int i = 0; i < count; ++i) { | ||
stream.setPointer(ptr + 32*i); | ||
|
||
ChannelComponent comp = new ChannelComponent(); | ||
comp.read(stream, keyframePtr); | ||
components.add(comp); | ||
} | ||
|
||
System.out.println(); | ||
} | ||
|
||
public void toArgScript(ArgScriptWriter writer, DataStructure stream) throws IOException { | ||
writer.command("channel").arguments(name).startBlock(); | ||
|
||
for (int i = 0; i < components.size(); ++i) { | ||
ChannelComponent comp = components.get(i); | ||
|
||
writer.command("component"); | ||
if (comp.id == ChannelComponent.TYPE_POS) { | ||
writer.arguments("POS").startBlock(); | ||
|
||
for (int j = 0; j < keyframeCount; ++j) { | ||
stream.getStream().seek(keyframePtr + comp.keyframeStride*j + comp.keyframeOffset); | ||
float[] dst = new float[3]; | ||
stream.getStream().readLEFloats(dst); | ||
|
||
writer.command("").vector(dst).floats(stream.getStream().readLEFloat(), stream.getStream().readLEFloat()); | ||
} | ||
|
||
writer.endBlock().commandEND(); | ||
} | ||
} | ||
|
||
writer.endBlock().commandEND(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package sporemodder.file.anim; | ||
|
||
import java.io.IOException; | ||
|
||
public class ChannelComponent { | ||
|
||
public static final int TYPE_INFO = 0x4F464E49; | ||
public static final int TYPE_POS = 0x534F50; | ||
public static final int TYPE_ROT = 0x544F52; | ||
|
||
public int id; | ||
public int keyframeOffset; | ||
public int keyframeStride; | ||
|
||
public void read(DataStructure stream, long dataPtr) throws IOException { | ||
id = stream.getInt(4); | ||
keyframeOffset = stream.getInt(8); | ||
keyframeStride = stream.getInt(12); | ||
|
||
System.out.println("\t0x" + Long.toHexString(dataPtr + keyframeOffset) + "\tid: 0x" + Integer.toHexString(id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package sporemodder.file.anim; | ||
|
||
import java.io.IOException; | ||
|
||
import emord.filestructures.StreamReader; | ||
|
||
/** | ||
* A convenience class used to read data from a file without any order. It is meant | ||
* to be equivalent to accessing certain fields of an structure. | ||
*/ | ||
public class DataStructure { | ||
|
||
private final StreamReader stream; | ||
private long pointer; | ||
|
||
public DataStructure(StreamReader stream) { | ||
this.stream = stream; | ||
} | ||
|
||
public StreamReader getStream() { | ||
return stream; | ||
} | ||
|
||
public long getPointer() { | ||
return pointer; | ||
} | ||
|
||
public void setPointer(long pointer) { | ||
this.pointer = pointer; | ||
} | ||
|
||
public long getUInt(int offset) throws IOException { | ||
stream.seek(pointer + offset); | ||
return stream.readLEUInt(); | ||
} | ||
|
||
public int getInt(int offset) throws IOException { | ||
stream.seek(pointer + offset); | ||
return stream.readLEInt(); | ||
} | ||
|
||
public float getFloat(int offset) throws IOException { | ||
stream.seek(pointer + offset); | ||
return stream.readLEFloat(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.