Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
timmeleshko committed Nov 27, 2023
2 parents 82c9eb0 + dd7ecc5 commit 9961ba4
Showing 1 changed file with 91 additions and 3 deletions.
94 changes: 91 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# rwparser
**rwparser** is an android library for parsing RenderWare dff and txd models of Grand Theft Auto.
**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:

Expand All @@ -23,18 +23,106 @@ dependencyResolutionManagement {
```

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

```kotlin
val modelParser = ModelParser()
modelParser.putDffDumpIntoFile(inFilePath, outFilePath, true)
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:

```kotlin
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:

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

For asynchronous `.txd`'s parsing:

```kotlin
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:


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

For asynchronous `.dff`'s converting:

```kotlin
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) { 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
Expand Down

0 comments on commit 9961ba4

Please sign in to comment.