100s of Animals and Plants in Zoo Tycoon 2 format

dgm5555
Member
 
Posts: 244
Joined: Tue Apr 08, 2014 19:45

100s of Animals and Plants in Zoo Tycoon 2 format

by dgm5555 » Sun Dec 28, 2014 09:07

Would it be possible to create a script which would automatically convert from Zoo Tycoon 2 (zt2) format into a minetest mod. Then we would have access to fabulous meshes which would really enhance the wildlife in minetest.

There are a very large number of freely modifiable/distributable meshes and textures (including animals (both living and extinct) and plants) using the Zoo Tycoon 2 format (zt2).
These meshs and textures are extremely high quality and would be a fabulous way of adding in large numbers of new animals, including a massive number of dinosaurs. Check out some of the renders: https://www.google.co.uk/search?q=zt2&tbm=isch

The original game includes 100+ animals, which have often been modified heavily by end users, but there are also many texture packs created by users from scratch which are public domain in many websites (often easily found by searching for zt2 on google). eg:-
http://zootycoon.wikia.com/wiki/List_of_user-made_animals_for_Zoo_Tycoon_2
http://w11.zetaboards.com/The_Round_Table/forum/3624200/

The .zt2 file is a renamed zip file, so can easily be extracted.
And information about the file structure and how to edit and modify the files is also widely documented. eg:-
http://zt2modding.wikia.com/wiki/Coding_an_Animal
http://z14.invisionfree.com/ZT2_Designing_Center/index.php?showtopic=1390
http://www.zootycoonunleashed.com/ZTForums/index.php?showtopic=15808&st=0&p=249013&

I'm not sure if the file format is directly able to be displayed by Irrlicht, but the NIF meshes are able to be edited with Blender (amongst others) if not, so worst case might be needing a conversion step to generate b3d files. Some are BFB files which might be more challanging to convert.
The sound files are .wav format, so not an issue.

I would normally have 'had a go' at generating the script before asking the question, but will be rather busy over the coming weeks, so thought I'd put it out as general information to start with. Especially as I would probably have worked on it a long time ago if I'd realised such a resource existed.

The following is a relatively irrelevant python script, but it does use code to copy file and walk through directorys, so might be a starter for such a script

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
import os
import shutil

tgtDir = '/media/david/2TB_#2/'
srcDir = '/media/david/3TB#2/'
curLoop = 1

#generate checksums for the source directory
#os.chdir(srcDir)
#cmd = "tigerdeep -r -l -z -j1 -e * >> 'sourceAllFiles.tiger'"
#os.system(cmd)

'''
#copy files from source to target (cp overwrites without prompting)
print('***  Copying Files from Source to Target Directory:  ***\n')
os.chdir(srcDir)
cmd = "cp -r '"+srcDir+ "' '"+ tgtDir+ "'"
cmd = "rsync -r -R -I -l -H '"+srcDir+ "' '"+ tgtDir+ "'"
cmd = "gcp -r -f '"+srcDir+ "' '"+ tgtDir+ "'"         # using GCP provides a progress bar
print(cmd)
os.system(cmd)

'''

print("Counting files to be copied")
totalFileCnt = 0
curFileCnt = 0
for src_dir, dirs, files in os.walk(srcDir):
   totalFileCnt = totalFileCnt+len(files)
   if len(files)>0:
#   if totalFileCnt/1000 == int(totalFileCnt/1000):
      print("Counted "+ str(totalFileCnt)+ " files")


print("Copying total of "+ str(totalFileCnt)+ " files")

for src_dir, dirs, files in os.walk(srcDir):
   dst_dir = src_dir.replace(srcDir, tgtDir)
   if not os.path.exists(dst_dir):
      os.mkdir(dst_dir)
   for file_ in files:
      curFileCnt += 1
      src_file = os.path.join(src_dir, file_)
      dst_file = os.path.join(dst_dir, file_)
      if os.path.exists(dst_file):
         os.remove(dst_file)
      fileSize = os.path.getsize(src_file)
      if fileSize>=1000000:
         print("Copying "+str(curFileCnt)+ "/"+str(totalFileCnt)+" ("+str(totalFileCnt-curFileCnt)+" remaining). Current file size: "+ str(fileSize/1000000)+"MB")
      shutil.copy(src_file, dst_dir)
#      print("Coiped "+str(curFileCnt)+ "/"+str(totalFileCnt)+" files. "+str(totalFileCnt-curFileCnt)+" files remaining)")


#generate checksums for the target directory
#walk through the source directory and generate checksums from the target directory for corresponding files
os.chdir(tgtDir)
os.system('cls' if os.name == 'nt' else 'clear')
print('***  Generating checksums for the target directory:  ***\n')

for curdir, subdirs, files in os.walk(srcDir):
   for i in range(0, len(files)):
      curTgtDir = curdir.replace(srcDir, "");
      print (curdir)
      print ('   '+ files[i]+ '/n')
      try:
#         os.chdir(tgtDir)   # probably overkill, but definitely don't want to accidentally checksum source files
#         print (os.getcwd())
         cmd = "tigerdeep -r -l -z -j1 -e '"+ curTgtDir+ '/'+ files[i]+ "' >> 'targetFiles"+ str(curLoop)+ ".tiger'"
         print (cmd)
         os.system(cmd)
      except:
         print ("Failed to checksum:/n")
         print ('   '+ curdir)
         print ('     '+ files[i]+ '/n')
         pass   



#If source and target checksums for each file match then delete source file
print "***  Deleting Verified Source Files:  ***/n"
with open(srcDir+ 'sourceAllFiles.tiger') as f1:
   srcChecksums = f1.read().splitlines()

with open(tgtDir+ "targetFiles"+ str(curLoop)+ ".tiger") as f2:
   tgtChecksums = f2.read().splitlines()

a = set(srcChecksums)
b = set(tgtChecksums)
matchingChecksums = list(set(a).intersection(b))

matchCnt = len(matchingChecksums)
for i in range(0, matchCnt):
   print "Deleting Source File: "+ str(i)+ '/'+ str(matchCnt)+ ': '+ matchingChecksums[i][62:]
   try:
      os.remove(srcDir+ matchingChecksums[i][62:])
   except:
      pass   


#Clear empty directories
#walk through the entire directory structure repeatedly until all blank directories have been deleted
print "***  Deleting Empty Directories  ***/n"
blankCount = 1
while blankCount != 0:
   blankCount = 0
   for curdir, subdirs, files in os.walk(srcDir):
      for i in range(len(files), 0):
         if os.path.islink(files[i]):
                  os.unlink(files[i])
      if os.path.islink(curdir):
            os.unlink(curdir)
      elif len(subdirs) == 0 and len(files) == 0:   #check for empty directories.
         os.rmdir(curdir)         #delete the directory
         blankCount = blankCount + 1
         print ("Deleting Empty Directory: "+ curdir)

#print ('Correctly moved '+ str(matchCnt)+ ' of '+ str(len(tgtChecksums))+ ' attempted files/n')
#Repeat until no files left
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: 100s of Animals and Plants in Zoo Tycoon 2 format

by Nathan.S » Sat Jan 03, 2015 22:27

it sounds like a good idea. I might do some messing around with this and see if I can script anything up.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

dgm5555
Member
 
Posts: 244
Joined: Tue Apr 08, 2014 19:45

Re: 100s of Animals and Plants in Zoo Tycoon 2 format

by dgm5555 » Sun Jan 04, 2015 13:59

QUICK START GUIDE
Public Domain animals are listed under: http://zt2downloadlibrary.wikia.com/wiki/Category:Public_Domain
This list currently contains 170 animals there are also many more plants and physical objects not listed on this page also there are many other non-PD meshes in many locations which are available for download and personal use...
See http://zt2downloadlibrary.wikia.com/wiki/Category:Downloads for a starter

The following is a quickstart guide for doing the mesh conversion manually via Blender
It takes approx 2mins and by the end you will have something like the following for further use:-
(I've done it under Windows XP as Blender 2.49 doesn't 'just work' in Ubuntu 14.4 and I wanted to be quick rather than fiddling around with it)
Image



The following uses a download from the above public domain list for a reindeer as is contains a relatively complex set of meshes. Download from:-
http://www.nexusmods.com/zootycoon2/download/18

European Reindeer
CONVERT FROM .NIF TO .BLEND FILE (approx 2 minutes)
1. Install the list of required programs at the bottom of this post
2. Extract the zt2 file using a zip extraction program
3. Open blender 2.49
4. Delete the cube (del, then click OK)
5. File/import/Netimmerse-gamebro
6. Browse the entities folder to find the .nif file eg ..\ZTABC_ARTIODACTYLA_4\entities\units\animals\ReindeerEuropean
7. Select ReindeerEuropean_Adult_F.nif then Import NIF
8. Click OK at the bottom of the screen showing the blender script
9. The import should proceed
10. You should be able to view your mesh by zooming in with the mouse wheel, rolling with wheel-button, and panning with shift wheel-button
11. Select Edit mode for the window (dropdown lower window which is object mode by default)
12. Split the window vertically (R-click on horizontal split under the window and select split then drag to halve the window.
13. Select the UV Image editor as window type (L bottom corner)
14. Mesh texture should appear as you select the various parts of your mesh.
15. Now switch to each object within the scene to load the UV image, and click the little parcel a the bottom of the window (to 'pack' the image into the .blend).
16. Save the file as a .blend file so you can import to 2.70 and convert it. View the following for a quick-start tutorial on this: http://wiki.minetest.net/Using_Blender


CONVERT VIA BLENDER 2.7 TO IRRLICHT COMPATIBLE MESH (5-10minutes):
This potentially requires merging multiple meshes and UV Maps/Textures (if not you can probably skip straight from step 3 to 13)
1. Open file in Blender 2.7
2. Check all the UV textures and meshes have transferred correctly (same method as above)
3. Decimate = automatically simplify the mesh (or manually do the same) of each object to find the minimum number of vertices to show desired shape (important for fast processing). Decimate is in a properties window/ modifiers (spanner)/ Add Modifer, then apply once you have a satisfactory quality setting (you may have to try a few times to get it right, so save your file after each object is correctly finalised).
4. Save each UV texture image to a format illricht can handle (eg png). UV Menu/image/save image.
5. Switch to GIMP to merge each image into a single file:
a. Open the ‘base’ image (usually the largest) in an image editor (eg GIMP).
b. Resize canvas (image/canvas size) and double the size of the image in X and Y dimensions.
c. Layer/layer to image size (to increase the layer to the new canvas size)
d. File/Open as layers all the other texture files
e. Move the layers around so they don’t overlap
f. File/export as and save as your desired ‘universal’ texture file (.png?)
6. Back to Blender
7. Using any UV texture, load your new texture file over the previous one (UV window/Image/open image)
8. Scale the mesh to match the new image. Keys are easier: ‘a’ = select all, ‘s’=scale, then type desired scale (eg ‘0.5’) then enter. ‘g’ = grab/move and type offset, or drag around with mouse to locate it back where it should be located on the new image.
9. In the 3D window switch to object mode and select the next object, then switch back to edit mode to display the UV mesh.
10. Repeat for all objects/meshes, until all are correctly aligned on your new ‘universal’ texture file
11. Merge all the objects into a single mesh – go to object mode. ‘a’ to select all objects. Ctrl-j to join all meshes into one (or under menu object/join).
12. All previous objects should now be joined as a single mesh and all located correctly on the universal UV texture file.
13. Then export to your favourite mesh type (a B3D plugin which works for 2.72b is: http://www.rtsoft.com/forums/showthread.php?7509-Blender-B3D-2-6x-Export-script%20B3Dexport.py

This is what the simplified mesh looks like (the black lines pointing everywhere are bones/armatures)
Image

SOUND: STILL TO FIGURE OUT
Modified animals often use .wav files from the original game files (so they're not available unless you owned it and would have copyright issues anyway). If you find some useful ones, .xml files link them to the state engine (see below). eg the reindeer above uses the 14 moose sounds from the original game.

ANIMATION: STILL TO FIGURE OUT (BUT PROBABLY EASIER TO DEVELOP YOUR OWN):
In theory it should be possible to import the complex behaviours of zt2 animals into blender then back out to minetest and make use of the animation but this will probably have to wait on someone else to do.
For starters:
In zt2 animations are controlled by a state engine (eg 'Walk'). This is described in an .xml file. These then activate an appropriate animation sequence (Walk_Ahead, Walk_LeftA, etc).
A .bfm file in the relevant animal directory lists all animations available in text format (136 potential animations for the above model).
A .bf file describes the movements of armatures in binary format to achieve the animation.
Unfortunately in many cases modified animals actually use the .xml and or .bf of an animal from the original game files (so it's not available unless you own it and would have copyright issues anyway). If you do find a cc version, the decoding of the binary format is explained http://niftools.sourceforge.net/forum/viewtopic.php?f=10&t=3547&start=15%20in%20this%20post, but considerable work would still be required to develop a script to translate it to a format blender could use to import the animation.

PS If you are good at animation, then the wiki page explanation of this could also be improved: http://wiki.minetest.net/Using_Blender#Animation, or linked to some good tutorials.

REQUIRED PROGRAMS
This is just a quick list of links and files to achieve this project
NIF import/export:
Blender
https://download.blender.org/release/Blender2.49b/
http://www.blender.org/download/ - latest release (suggest using this for editing)

Python 2.6
https://www.python.org/download/releases/2.6.6/
https://www.python.org/download/releases/2.6.9/ (don't use, has no binaries)

PyFFI - Python File Format Interface
http://sourceforge.net/projects/pyffi/files/pyffi/2.1.11/PyFFI-2.1.11.cefd181.win32.exe/download - not sure what this is for, but was a recommended download


NIF blender plugin
http://sourceforge.net/projects/niftools/files/blender_nif_scripts/2.5.x/2.5.09/blender_nif_scripts-2.5.9.77b0815-windows.exe/download
http://sourceforge.net/projects/niftools/files/latest/download?source=files – Installing NIFscope doesn’t install blender plugin

zip extraction program - 7zip
http://downloads.sourceforge.net/sevenzip/7z920.exe
(home page: http://www.7-zip.org/)
Last edited by dgm5555 on Tue Jan 06, 2015 20:30, edited 4 times in total.
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

Re: 100s of Animals and Plants in Zoo Tycoon 2 format

by ExeterDad » Sun Jan 04, 2015 18:12

Sounds pretty cool! But... to achieve nice detail on organic objects require many vertices. I see the example above has tons of them. What affect will a handful of these creatures running around our worlds have? Will they be very laggy?
Typically modelers for gaming strive to achieve low poly models and have strategic texturing to fool the eye to think the model has higher detail.
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

Re: 100s of Animals and Plants in Zoo Tycoon 2 format

by Jordach » Mon Jan 05, 2015 13:45

dgm5555 wrote:as Blender 2.49 doesn't 'just work' in Ubuntu 14.4
You've got bigger problems than that. The latest Blender version is 2.72b. That plugin probably isn't updated anymore. My suggestion would be to search blendall or blendswap for CC0 or CC licensed works.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

dgm5555
Member
 
Posts: 244
Joined: Tue Apr 08, 2014 19:45

Re: 100s of Animals and Plants in Zoo Tycoon 2 format

by dgm5555 » Mon Jan 05, 2015 22:18

So far no one has pointed out that the reindeer is two separate meshes with 2 UV textures, and undoubtedly more complicated animals/objects will have even more. I'm not sure how best to handle this (i've put my method in the above post), so suggestions appreciated.
Also anyone familiar with handling animations how to use this (at this point, I'm not even 100% sure it's preserved in my method and don't know how to check).

@Jordach. The .nif plugin currently hasn't been updated for 2.72, but works fine for 2.49. That's the reason for the above workflow suggesting switching to 2.72 for exporting. I used 2.6 when I was editing meshes and created the core of the Blender page on the wiki, but someone's updated it for 2.70, and there is a working b3d export plugin available at: http://www.rtsoft.com/forums/showthread.php?7509-Blender-B3D-2-6x-Export-script...

@ExeterDad. The decimate tool in Blender is a mesh simplification tool. Works extremely well...
Image
 


Return to Minetest Texture Packs

Who is online

Users browsing this forum: No registered users and 39 guests

cron