Code Monkey home page Code Monkey logo

rwparser's Introduction

rwparser

rwparser is an android library for parsing and converting RenderWare dff and txd models of Grand Theft Auto.

Gradle Dependency

Add this dependency to your module's build.gradle file:

dependencies {
  ..
  implementation 'com.github.Lime-blur:rwparser:latest_version'
}

Add it in your root build.gradle at the end of repositories (or in settings.gradle):

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
  }
}

Usage

Parsing

In order to parse a .dff file, you simply need to create a ModelParser() object and call the appropriate method:

val modelParser = ModelParser()
val parseResult = modelParser.putDffDumpIntoFile(inFilePath, outFilePath, /* optional */ true)

For asynchronous parsing, you need to call the appropriate function and bind ModelParser to the component's lifecycle:

class MainActivity : AppCompatActivity() {

    private var modelParser: ModelParser? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ..
        modelParser = ModelParser()
    }

    override fun onDestroy() {
        modelParser?.destroy()
        super.onDestroy()
    }

    private fun parse() {
        modelParser?.putDffDumpIntoFileAsync(inFilePath, outFilePath, /* optional */ true) { parseResult ->
            // Handling the callback
        }
    }
}

Same for .txd file:

val modelParser = ModelParser()
val parseResult = modelParser.putTxdDumpIntoFile(inFilePath, outFilePath)

For asynchronous .txd's parsing:

class MainActivity : AppCompatActivity() {

    private var modelParser: ModelParser? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ..
        modelParser = ModelParser()
    }

    override fun onDestroy() {
        modelParser?.destroy()
        super.onDestroy()
    }

    private fun parse() {
        modelParser?.putTxdDumpIntoFileAsync(inFilePath, outFilePath) { parseResult ->
            // Handling the callback
        }
    }
}

Converting

The library can also convert .dff to .gltf format. To convert you need:

val modelParser = ModelParser()
val parseResult = modelParser.convertDffToGltf(inDffFilePath, outFilePath, /* optional */ inTxdFilePath, /* optional */ viewType)

For asynchronous .dff's converting:

class MainActivity : AppCompatActivity() {

    private var modelParser: ModelParser? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ..
        modelParser = ModelParser()
    }

    override fun onDestroy() {
        modelParser?.destroy()
        super.onDestroy()
    }

    private fun convert() {
        modelParser?.convertDffToGltfAsync(dffFilePath, gltfFilePath, /* optional */ txdFilePath, /* optional */ viewType) { parseResult ->
            // Handling the callback
        }
    }
}

See the sample application, where an example of using the library is implemented: https://github.com/Lime-blur/rwparser/tree/main/sample

Rights

rwparser's People

Contributors

lime-blur avatar timmeleshko avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

rwparser's Issues

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.