Jump to content

How to stich together a weapon PZMesh


DIrtbag

Recommended Posts

Update: This is old stuff, it's this way for Jab awesome export/import blender script.
 
First of all, i'm not a programmer so you won't find a one-click export tool in this thread. It involve some manipulation in the files and is mostly for test purpose since you can't add custom models yet anyway.
 
In this tutorial I will be using the following tool:

  • Microsoft Office Excel
  • Notepad++
  • greentoken.de online 3D model converter

Step 1 : 3D model compatibility
 
Your 3d model must meet the following requirement to be compatible:

  • All face must be triangle
  • All face must have UV coordinate
  • All part must be merged together

It also can be very low poly since the game redraw the whole thing anyway. You can check out Kind-Sir mesh converter python script if you want to import weapons models and compare size and poly count. I added to the attached file a copy of the original fire axe in obj format converted using this script if you want a quick reference.
 
Step 2 : Convert into the directX format
 
Now you need to convert your model into the .X format. For this I use  http://www.greentoken.de/onlineconv/ online converter and convert from 3ds to x. If you use wings 3D do not use the build-in .X exporter, it mess up everything. If you use another converter, make sure no value is like that in the finished result:

-4.85722573273506e-17

Because if it the case, it won't work. You can do a quick check of the file with a text editor.
 
Step 3 : Prepare your X file for conversion
 
For this step i'm going to assume you converted your file from 3DS to X using the link provided above. If you didn't, this step might be slightly different (see "For other conversion source").
 
Open your X file with notepad++ (any other notepad application should do). You can record the next steps in a macro so you don't have to do it again if you want. Unfortunately there is no easy way to share notepad++ macro so I won't provide any file for that.
 
Replace all the following, in this order, by nothing (the second line is not blank):

        3;        ;,;;

 
 
 

Replace all the following:

;

By (there's a space after the comma):

, 

You can stop recording your macro now. 
 
 
For other conversion source
If you didn't convert your file from greentoken, the idea of this step is to remove indention and have your vertexes on the following format:

0.00133600, 0.13244500, 0.01815900

and your faces on this one:

74, 76, 75

Step 4 : Stitch together a PZMesh txt file
 
Create a blank txt file and copy this blank model:



# Project Zomboid Mesh# File Version:1.00000000# Model Name:weapons_blank# Vertex Stride Element Count:3# Vertex Stride Size (in bytes):76# Vertex Stride Data:# (Int)    Offset# (String) Type0VertexArray12NormalArray24TextureCoordArray# Vertex Count:0 <----EDIT THIS# Vertex Buffer:VERTEX NORMAL AND UV GO HERE (COLUMN I IN LIST MERGER.XLSM)# Number of Faces:0 <----EDIT THIS# Face Data:FACE GO HERE

The main problem here is the vertex, the normal and the texture are merged into one list while in X, they are in 3 lists. For this issue, I made an excel sheet with macro (you need to activate them) who save you from manually merging the three list. The worksheet is in the attached files.
 
 
Here I made a simplified versions (with comment) of what you must copy from the X file. You will have other lines (not include in the exemple) between these block, just ignore them you don't need them.

Mesh SHAPE_NAME_SOMTHING {4,                               VERTEX COUNT YOU NEED THIS-0.006535, 0.004339, -0.488333   FIRST LIST COPY TO LIST MERGER.XLSM COLUMN A-0.001275, 0.000217, -0.509612   |-0.006535, 0.004339, -0.488333   |-0.001275, 0.000217, -0.509612   L3,                               FACE COUNT YOU NEED THIS (don't copy with mesh data)2,1,0                            FACE DATAS COPY TO PZMESH1,4,3                            |6,4,5                            L}MeshNormals {4,                              VERTEX COUNT YOU ALREADY HAVE THIS0.960664, -0.272644, 0.052814   SECOND LIST COPY TO LIST MERGER.XLSM COLUMN B-0.966578, -0.251695, 0.048757  |0.960664, -0.272644, 0.052814   |-0.966578, -0.251695, 0.048757  L3,                              FACE COUNT MIRROR DON'T COPY AT ALL2,1,0                           FACE DATA MIRROR DON'T COPY AT ALL1,4,3                           |6,4,5                           L}MeshTextureCoords {4,                     VERTEX COUNT YOU ALREADY HAVE THIS0.525091, 0.201185     THIRD LIST COPY TO LIST MERGER.XLSM COLUMN C0.517473, 0.169795     |0.525091, 0.201185     |0.517473, 0.169795     L}

Now you can go back and copy in your blank pzmesh the data from your X file. You should now have a working weapons mesh, you can try it by replacing another one.
 
axXMTMv.pngNhIsIT5.png
 
So this is it, thank for reading and if i'm unclear or wrong on any point, feel free to leave a comment.

weapons_fireaxe.zip

list merger.zip

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...