Git Product home page Git Product logo

second-life-model-patcher's Introduction

Collada Model Patcher for Second Life

What does it do?

This tool takes two input Collada files, determines the bounding boxes of both files, and (given that the secondary meshes bounding box is smaller than the first) artificially 'inflates' the bounding box of the secondary mesh by adding small, invisible "one-vertex triangles" to match the bounding box of the primary mesh.

Why is it useful?

Second Life has the rather interesting quirk of always scaling secondary meshes to the same dimensions as the primary mesh when uploading a 3D object. This affects mesh collision boxes and custom LODs and ends in stretched results if the bounding boxes didn't line up perfectly before uploading. I suspect that this has been implemented to prevent objects from being used abusively (be it intentionally or by accident) by for example having the collision box of an object surpass the actual bounds of the object, leading to "invisible walls". This does - in a way - make a lot of sense, since it would negatively impact the player if they would constantly run into invisible walls / have the camera clip on them, however, it also penalizes creators like myself that try to create high quality and performant models. Spending hours of coming up with a nice asset creation workflow, just to realized everything looking rather ugly in-game after Second Life finished its adjustments.

Usage

Once you start the tool, you will be able to enter two file paths (or use the handy file chooser by pressing the '...' buttons). These file paths should lead to your primary ('target bounding box size') and secondary ('geometry you want to have') Collada (.dae) files. Once you select them, you should see their bounding boxes being displayed in the frame below. Click the button to start the merging, and the tool will create and save a new file to the same folder of your secondary mesh (with the _patched postfix). You're done! Congratulations

How it works

The bounding box of an object can be described as 6 values, the largest and smallest occurrence of each axis (XYZ) in the positions of all vertices. This tool simply injects either one or two additional vertices at the positions of the corner of the target bounding box to make the secondary mesh have the exact same bounds. It then defines a 'triangle' for each added vertex (each 'corner' of the triangle is the same vertex) which effectively has a surface area of 0, making it invisible.

Limitations

  • No axis of the secondary object's bounding box may surpass the primary object's bounding box (secondary has to be smaller)
  • Currently only Collada files that contain exactly one geometry are supported
  • Second Life won't accept the result as a collision mesh because of the small triangle, however, the uploader can convert it to a hull, which validates it again and still maintains the scaling

Installation

You will require two additional dependencies:

  • PyQt5, responsible for the beautiful UI (pip install PyQt5)
  • pycollada, responsible for reading, modifying and writing the Collada data (pip install pycollada)

Future

As it stands right now, this tool is a stand-alone solution. I am thinking of potentially embedding this functionality into a blender add-on, however, I am not sure if or when I'm going to tackle that.

second-life-model-patcher's People

Contributors

jackthefoxotter avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.