26
FF8 Tools / Re: [FF8] Rinoa's Toolset - BS, WMSET, WMX, GF, RAIL - Ripping, editing, analyzing
« on: 2016-07-19 20:57:32 »
battle stage editor sounds really cool, I also like Halfers idea(unless it is already in there somewhere?).
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
this.faceIndexOffset = faceIndexOffset;
inside block?int vertexIndexOffset = 0;
int textureIndexOffset = 6;
for(Iterator iterator = segments.iterator(); iterator.hasNext();)
{
Segment segment = (Segment)iterator.next();
segment.generateBlocks(data, vertexIndexOffset, textureIndexOffset);
vertexIndexOffset = segment.getFaceIndexOffset();
}
That's totally okay, after all I did say that I will publish the source if anyone wants it. Didn't just do it because I thought I would pull out next version out pretty quickly . It's in github though soI also haven't seen any section near that number.I can just link it if neededhttps://github.com/Halferi/wmx2obj Well there you have it , that's the same version as the compiled one though.
Well you can say that from the whole code. I never intended it to be final yet because I knew that I still have to change things for optimization. That also includes the rearranging of functions to easier upgrades in future once the program is "ready". But don't get me wrong, I do really appreciate that you do these optimization checks, also saves time from me .
I don't think that there is any limitation to it technically. Problems that may occur though is the performance, but testing that comes later. Each section can hold technically 0x9000 bytes which is 36864 bytes in decimals. The world map currently hardly utilizes this space fully at all, in fact I don't seem to remember any section to take over half of the maximum size.
Yeah.. like many others here do what they do for the same reason.. because they are too lazy to ask Square for source code
void findTexturePage(byte data[], int offset, int faceIndexOffset, int textureIndexOffset)
is only called oncepublic String getPage()
{
return (String)texturepages.get(texturepages.size() - 1);
}
it still just sends the last created one, which means all other data stored in faces are of no use. or is this just for debugging code and that code will be changed?public class Texture
{
public Texture(int id,double X,double Y)
{
this.id = id;
this.X=X;
this.Y=Y;
}
public int getId()
{
return id;
}
public double getX()
{
return X;
}
public double getY()
{
return Y;
}
public int getPage()
{
return ((Integer)texturepages.get(texturepages.size() - 1)).intValue();
}
public void print()
{
System.out.print(texturepages);
}
public static final int COORDINATE_BYTES = 1;
public static final int p = 0;
private final int id;
private double X;
private double Y;
private final ArrayList texturepages = new ArrayList();
}
in Blockpublic void findTextureIndices(byte data[], int offset)
{
textures.add(new Texture(textures.size(),(data[offset + 6] & 0xff) + 0.5D) / 256D,(data[offset + 7] & 0xff) + 0.5D) / 256D)
textures.add(new Texture(textures.size(),(data[offset + 8] & 0xff) + 0.5D) / 256D,(data[offset + 9] & 0xff) + 0.5D) / 256D)
textures.add(new Texture(textures.size(),(data[offset + 10] & 0xff) + 0.5D) / 256D,(data[offset + 11] & 0xff) + 0.5D) / 256D)
}
public void generateTextures(byte data[], int faceIndexOffset, int textureIndexOffset)
{
for(int texture = 0; texture < faceCount; texture++) findTextureIndices(data, offset + texture * 16))
}
ArrayList<String> texturepages;
String texturepage;
and doString getPage(){return texturepage;}
replace alltexturepages.add("***");
with texturepage="***";
CustomComparator {
public boolean compare(Face a, Face b) {
return a.texturepage.before(b.texturepage);
}
}
Then we can after the loop in GenerateFaces dofaces.sort(CustomComparator);
public void generateFaces(byte[] data, int vertexIndexOffset) {
// initialize face instances
for (int face = 0; face < faceCount; face++) {
addFace(new Face(face));
}
// find vertex indices of the face instances
for (Face face : faces) {
face.findVertexIndices(
data,
offset + face.getId() * FACE_BYTES,
vertexIndexOffset
);
}
}
public void generateVertices(byte[] data, int segmentX, int segmentZ) {
// initialize vertex instances
for (int vertex = 0; vertex < vertexCount; vertex++) {
addVertex(new Vertex(vertex));
}
// find vertex coordinates of the vertex instances
for (Vertex vertex : vertices) {
vertex.findCoordinates(
data,
offset + faceCount * FACE_BYTES
+ vertex.getId() * VERTEX_BYTES,
offsetX,
offsetZ,
segmentX,
segmentZ
);
}
}
in C++ containers similar to ArrayList in java allows public void generateFaces(byte[] data, int vertexIndexOffset) {
// find vertex indices of the face instances
for (int face = 0; face < faceCount; face++) {
Face ref=faces.add(new Face(face));
ref.findVertexIndices(
data,
offset + ref.getId() * FACE_BYTES,
vertexIndexOffset
);
}
}
public void generateVertices(byte[] data, int segmentX, int segmentZ) {
// initialize vertex instances
// find vertex coordinates of the vertex instances
for (Vertex vertex : vertices) {
Vertex ref=vertices.add(new Vertex(vertex));
ref.findCoordinates(
data,
offset + faceCount * FACE_BYTES
+ ref.getId() * VERTEX_BYTES,
offsetX,
offsetZ,
segmentX,
segmentZ
);
}
}
Face ref=faces.get(face);
I'd still say the addVertex and addFace amongst other functionspublic void addFace(Face face) {
if (faces.size() < faceCount) {
faces.add(face);
}
}
public void addVertex(Vertex vertex) {
if (vertices.size() < vertexCount) {
vertices.add(vertex);
}
}
ArrayList size checks, as the faceCount and vertexCount loop is always the same, meaning these branching if statements are just wasting CPU cycles.
for loop (segments){
WriteVertices(segments[i],PrintWriter);
WriteTextures(segments[i],PrintWriter);
WriteFaces(segments[i],PrintWriter);
}
doing a loop over segments only once is 835 iterations max, as the range of world chunks is a total of 835 due to the interchangable parts.WriteVertices(PrintWriter);
WriteTextures(PrintWriter);
WriteFaces(PrintWriter);
Which loops segments 3 times over(one for each function call), so a total of 2505 loops, since these are seperate, each loop inside a loop adds complexity, for loop (segments){
for loop(blocks)
WriteVertices(blocks[j],PrintWriter);
WriteTextures(blocks[j],PrintWriter);
WriteFaces(blocks[j],PrintWriter);
}
Which didn't work as I wanted it to as it would make 3ds max tear the model to pieces(mangled mesh) on import, because the indices etc didn't match the segment.
usemtl 9
f 390519//1550113 390518//1550114 390524//1550115
usemtl 1
f 390517//1550116 390530//1550117 390499//1550118
f 390491//1550119 390517//1550120 390492//1550121
usemtl 9
f 390523//1550122 390512//1550123 390519//1550124
usemtl 8
f 390516//1550125 390512//1550126 390523//1550127
usemtl 9
f 390521//1550128 390522//1550129 390517//1550130
f 390520//1550131 390521//1550132 390491//1550133
f 390497//1550134 390495//1550135 390521//1550136
f 390506//1550137 390497//1550138 390520//1550139
f 390518//1550140 390520//1550141 390490//1550142
f 390512//1550143 390506//1550144 390518//1550145
usemtl 0
f 390517//1550146 390529//1550147 390532//1550148
usemtl 8
f 390515//1550149 390511//1550150 390516//1550151
f 390514//1550152 390510//1550153 390515//1550154
f 390514//1550155 390508//1550156 390509//1550157
f 390505//1550158 390511//1550159 390510//1550160
f 390503//1550161 390510//1550162 390509//1550163
f 390508//1550164 390503//1550165 390509//1550166
f 390496//1550167 390505//1550168 390503//1550169
usemtl water
f 390502//1550170 390498//1550171 390501//1550172
usemtl 9
f 390490//1550173 390491//1550174 390493//1550175
usemtl 0
f 390517//1550146 390529//1550147 390532//1550148
usemtl 1
f 390517//1550116 390530//1550117 390499//1550118
f 390491//1550119 390517//1550120 390492//1550121
usemtl 8
f 390516//1550125 390512//1550126 390523//1550127
f 390515//1550149 390511//1550150 390516//1550151
f 390514//1550152 390510//1550153 390515//1550154
f 390514//1550155 390508//1550156 390509//1550157
f 390505//1550158 390511//1550159 390510//1550160
f 390503//1550161 390510//1550162 390509//1550163
f 390508//1550164 390503//1550165 390509//1550166
f 390496//1550167 390505//1550168 390503//1550169
usemtl 9
f 390519//1550113 390518//1550114 390524//1550115
f 390523//1550122 390512//1550123 390519//1550124
f 390521//1550128 390522//1550129 390517//1550130
f 390520//1550131 390521//1550132 390491//1550133
f 390497//1550134 390495//1550135 390521//1550136
f 390506//1550137 390497//1550138 390520//1550139
f 390518//1550140 390520//1550141 390490//1550142
f 390512//1550143 390506//1550144 390518//1550145
f 390490//1550173 390491//1550174 390493//1550175
usemtl water
f 390502//1550170 390498//1550171 390501//1550172
iterate segments {
Segment seg = segmentiterator;
write("g "+seg.getID())
iterate blocks(j, seg.getBlocks()) {
Blocks b = blockiterator;
writeVertices(b, printWriter);
writeTextures(b, printWriter);
writeFaces(b, printWriter);
to save some processing time removing uneeded for loops, I noticed atleast for me that the textured version takes FOREVER to finish, reducing the amount of loops would probably help alot.
public void exportFile(File file) throws IOException {
PrintWriter printWriter = new PrintWriter(file);
printWriter.println("# Converted to Wavefront .obj with wmx2obj");
printWriter.println("# wmx2obj \u00A9 2015 Aleksanteri Hirvonen");
printWriter.println();
for (Segment segment : segments) {
printWriter.println("g " + segment.getID());
writeVertices(segment,printWriter);
writeFaces(segment,printWriter);
}
printWriter.close();
}
private void writeVertices(Segment segment,PrintWriter printWriter) {
// take the coordinate values of each vertex instance
// and write to file
printWriter.println("# List of geometric vertices");
for (Block block : segment.getBlocks()) {
for (Vertex vertex : block.getVertices()) {
printWriter.println(
"v "
+ vertex.getCoordinate(Vertex.X) + " "
+ -vertex.getCoordinate(Vertex.Y) + " "
+ -vertex.getCoordinate(Vertex.Z)
);
}
}
printWriter.println();
}
private void writeFaces(Segment segment,PrintWriter printWriter) {
// take the vertex index values of each face instance
// and write to file
printWriter.println("# Polygonal face elements");
for (Block block : segment.getBlocks()) {
for (Face face : block.getFaces()) {
printWriter.print("f ");
for (Integer vertexIndex : face.getVertexIndices()) {
printWriter.print(vertexIndex + " ");
}
printWriter.println();
}
}
}
a0stg001.x Whinhill Village?