Code Monkey home page Code Monkey logo

cem-tool's People

Contributors

zocker-160 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cem-tool's Issues

Blender Object number sequence error message

The error message when the object numbers are not sequential / otherwise incorrect is not very descriptive. If possible, please add a line to the error message that helps the user to make the necessary changes.

for example, ‘Object numbers must be sequential, starting with 1 and with no gaps’

Blender Transformations Error Message

Is it possible to add an error message when ‘accept all transformations’ has not been applied to all of the objects?

One way to implement it would be to look at the origin position and scale of each object and make sure they all say 0.

If not possible, never mind.

Bug with UV maps and possible fix for the Blender plugin

Hi! :)
I think I spotted a bug in the CEM-tool plugin for Blender in version 0.25 regarding UV maps and can even provide a fix for it:
If you import Empire Earth cem-files into Blender using the CEM-tool plugin in version 0.25 you get mostly good results in regards to the UV maps, but not every time. Mostly cavalry units are prone to having messed up UVs after importing. I think I was able to track down the bug:

Somewhere after line 460 of the CEMimporter.py you have the following section:

### add UV coords
for p, polygon in enumerate(main_mesh.polygons):
    for i, index in enumerate(polygon.loop_indices):

        #print("FACE:", faces[p][i])
        #print("TEXTURE UV:", texture_uvs[faces[p][i]] )
        #print("INDEX:", index)

        main_mesh.uv_layers[0].data[index].uv = texture_uvs[mat_vertex_offset : mat_vertex_offset + mat_vertex_count][faces[p][i]]

I don't fully understand what the plugin does, but I will do my best to explain the bug. The bug seems to be in the last line when we access "faces[p][i]". I think the current code assumes that the content of "faces" (a list of coordinates basically) is equal to the list of vertices of the polygons in main_mesh. Which is mostly the case, but not quite in case of some units like cavalry! I tested it with the Sargon of Akkad hero unit and there are two entries missing in the "faces" list. This throws off the script as soon as it reaches the point when the lists diverge. Again, without understanding what the script actually does, my fix was to not use the "faces" list at all and simply access the vertices directly by saving them into their own list and accessing that list in the loop instead of "faces":

### add UV coords
vertex_list = [polygon.vertices for polygon in main_mesh.polygons]
for p, polygon in enumerate(main_mesh.polygons):
    for i, index in enumerate(polygon.loop_indices):    
                        
        #print("FACE:", faces[p][i])
        #print("TEXTURE UV:", texture_uvs[faces[p][i]] )
        #print("INDEX:", index)
                            
        main_mesh.uv_layers[0].data[index].uv = texture_uvs[mat_vertex_offset : mat_vertex_offset + mat_vertex_count][vertex_list[p][i]]

After implementing this little trick the UVs of Sargon of Akkad are no longer messed up and from what I've seen it should have fixed the issues for the other units as well. I know it's been like three years since the last commit to this, but still, I wanted to make you aware of the bug and provide a possible solution. Thanks for this tool, it has been really helpful!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.