Jump to content
Bryan623

BAT for Blender (Looking for help)

11 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

Hey guys,

I've been using Blender for a few years now, and i have some (very) basic python knowledge.  Now that i'm back into SC4, and don't have a copy of 3ds Max 2014, i'd like to help out the community a bit and start a project that would benefit not just me but a lot of people.  My only issue is that my skill set is kind of weak.

I have dug up some useful info, but i suck at math.

http://users.tpg.com.au/rivit/rvt-SimCity-articles2.htm <- some useful stuff here

https://www.sc4devotion.com/forums/index.php?topic=17650.20 <- page 2 has some nifty stuff too

 

If anyone is interested let me know (i'm sure a lot of people are)

 


  Edited by Bryan623  
  • Like 3
  • Yes 1

Hmmm.... what should i put here?  I don't know...

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

Hey @Bryan623 (and @Jasoncw), there's a discussion of this happening at SC4Devotion. Some progress is being made, although the project is still very much in its infancy. I've modelled all my BATs (all three of them, lol) in Blender, bc i find it easier than 3ds Max, but at present i still need to export them to 3ds Max (or Gmax) to render them for SC4. 

  • Like 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

@Bryan623 I started to look into this some time ago but I was thwarted by my complete ignorance of how to use modelling software. I have some experience with Python but I don't know  how the software needs to be manipulated. At the time, I took a long look at the python modules in Blender and was gaining some insight, I even created a couple interface buttons to move an object on an axis. There was a time (20 yrs ago) that I wrote code for cnc machine tools, so I am familiar with x,y,z, and co-ordinates but even with that and a lot of research I still was unable to figure out how to apply it to the software.  

Anyway, if you think I can help in any way, I would be glad to try. Keep in mind that you may have to lead me by the hand.

  • Like 1

Check out my Linux Tutorials - How to use Wine with SC4D, NAM, Modding Tools

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

Well, today in 2024 and having the tools of AI... may we have the possibility of resuming this project. What do you think about it? How AI could help to coding the tools necessary to develop Bat4Blender?

  • Like 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

Well, i have no idea of coding so CHATGPT 3.5 told me this:

"To create a Python export script for Blender that can export models in the .s3d format used by SimCity 4, you will need to use the Blender API. Here I'll provide you with a basic example of how you could get started with a simple script that exports the geometry of a selected object in Blender:

python

 

import bpy

def export_s3d(filepath):
    # Get the selected object in Blender
    obj = bpy.context.active_object
    
    # Check if the object is a mesh object
    if obj.type != 'MESH':
        print("The selected object is not a mesh.")
        return
    
    # Get the mesh data from the object
    mesh = obj.data
    
    # Create an .s3d file and write the mesh data
    with open(filepath, 'w') as f:
        # Write the .s3d file header
        f.write("S3D v1\n")
        
        # Write the object's geometry (vertices, faces, etc.)
        for v in mesh.vertices:
            f.write(f"v {v.co.x} {v.co.y} {v.co.z}\n")
        
        for face in mesh.polygons:
            f.write("f")
            for vi in face.vertices:
                f.write(f" {vi + 1}")  # Blender index starts from 0
            f.write("\n")

# Example usage
export_s3d("/destination/path/model.s3d")

 

This script exports the selected object's geometry to a .s3d file format. However, please note that this is a very basic example and does not include exporting texture information, materials, or other properties of the object. You would need to expand this script to meet your specific requirements, such as exporting texture data, generating .fsh files, etc.

Creating a complete export script for SimCity 4 would require a deeper understanding of the Blender API and the .s3d file format. You may need to further research and consult the documentation for Blender and SimCity 4 for detailed information on manipulating models and files in these programs."

 

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

more:

"let's expand the script to include exporting texture information, materials, and other object properties. Here is an improved version of the script that addresses these aspects:

import bpy

def export_s3d(filepath):
    # Get the selected object in Blender
    obj = bpy.context.active_object
    
    # Check if the object is a mesh object
    if obj.type != 'MESH':
        print("The selected object is not a mesh.")
        return
    
    # Get the mesh data from the object
    mesh = obj.data
    
    # Create an .s3d file and write the model information
    with open(filepath, 'w') as f:
        # Write the .s3d file header
        f.write("S3D v1\n")
        
        # Write the object's geometry (vertices, faces, etc.)
        for v in mesh.vertices:
            f.write(f"v {v.co.x} {v.co.y} {v.co.z}\n")
        
        # Write face information including normals
        for face in mesh.polygons:
            f.write("f")
            for vi in face.vertices:
                f.write(f" {vi + 1}")  # Blender index starts from 0
            f.write("\n")
            f.write(f"n {face.normal.x} {face.normal.y} {face.normal.z}\n")
        
        # Write material and texture information
        for material_slot in obj.material_slots:
            material = material_slot.material
            f.write(f"material {material.name}\n")
            # Write texture information if available
            if material.use_nodes:
                for node in material.node_tree.nodes:
                    if node.type == 'TEX_IMAGE':
                        texture = node.image
                        f.write(f"texture {texture.filepath}\n")
        
        # Write other object properties if necessary
        
# Example usage
export_s3d("/destination/path/model.s3d")

This updated script exports additional information such as face normals, materials, and associated textures. However, please note that this script assumes that materials and textures are set up using Blender's node system.

If your materials and textures are set up differently in Blender, you may need to adjust the script to fit your specific workflow. Additionally, you may need to handle other object properties such as animation or physics data based on your requirements.

If you need further details or assistance with any specific part of the script, feel free to ask. I'm here to help."

 

I wish it could help.

Ohdude

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
Currently: Viewing Topic: Found Custom Contents
 

@ohdude, you can instruct ChatGPT to provide better code. You do it by using GPT-4 and providing a huge amount of data to it. In the context of SC4, we "just" have to collect tons of knowledge from Devotion and Simtropolis and collect it into a collection of PDFs. Here's how:

Hope it'll be useful.

  • No 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

What if such knowledge were not simply collectible? At some point wouldn’t teaching AI to do it take longer than just doing it?

  • Like 1
  • Yes 2

Head over to my Lot and Mod Shack to keep abreast of my latest developments.

Do you like custom textures, but don't like all the work involved creating them?, take a look at the Texture Automation options here. Change the look and feel of your transit networks, with the minimum of effort, for example customised versions of my Sidewalk NAM (SWN) and Terrain Grass NAM (TGN) mods, and much more besides.

New to the NAM? Check out my tutorials on YouTube. Latest upload: How to: RHW - MHO Roundabout Interchanges. (Nov 25).

p.s. - I'm MGB over on SC4D and a member of the NAM team.

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

@memo is making very interesting progress on Bat4blender here:

 

Share this post


Link to post
Share on other sites

Sign In or register to comment...

To comment in reply, you must be a community member

Sign In  

Already have an account? Sign in here.

Sign In Now

Create an Account  

Sign up to join our friendly community. It's easy!  

Register a New Account


×

Thank You for the Continued Support!

Simtropolis depends on donations to fund site maintenance costs.
Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

Make a Donation, Get a Gift!

Expand your city with the best from the Simtropolis Exchange.
Make a Donation and get one or all three discs today!

STEX Collections

By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

Each donation helps keep Simtropolis online, open and free!

Thank you for reading and enjoy the site!

More About STEX Collections