RUIC 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +3 -3
- data/HISTORY +110 -86
- data/README.md +220 -220
- data/bin/ruic +61 -61
- data/gui/TODO +2 -2
- data/gui/appattributesmodel.rb +51 -51
- data/gui/appelementsmodel.rb +126 -126
- data/gui/launch.rb +19 -19
- data/gui/makefile +14 -14
- data/gui/resources/style/dark.qss +459 -459
- data/gui/window.rb +90 -90
- data/gui/window.ui +753 -753
- data/lib/ruic.rb +191 -190
- data/lib/ruic/application.rb +25 -3
- data/lib/ruic/assets.rb +441 -436
- data/lib/ruic/attributes.rb +179 -178
- data/lib/ruic/behaviors.rb +0 -0
- data/lib/ruic/effect.rb +31 -31
- data/lib/ruic/interfaces.rb +0 -0
- data/lib/ruic/nicebytes.rb +29 -0
- data/lib/ruic/presentation.rb +6 -3
- data/lib/ruic/renderplugin.rb +17 -17
- data/lib/ruic/ripl.rb +45 -45
- data/lib/ruic/statemachine.rb +6 -0
- data/lib/ruic/version.rb +3 -3
- data/ruic.gemspec +25 -25
- data/test/MetaData-simple.xml +28 -28
- data/test/MetaData.xml +435 -435
- data/test/customclasses.ruic +29 -29
- data/test/filtering.ruic +42 -42
- data/test/futureassets.ruic +7 -7
- data/test/nonmaster.ruic +20 -20
- data/test/paths.ruic +16 -16
- data/test/projects/CustomClasses/CustomClasses.uia +7 -7
- data/test/projects/CustomClasses/CustomClasses.uip +40 -40
- data/test/projects/CustomClasses/FutureAsset.uip +17 -17
- data/test/projects/MissingAssets/Existing.uip +87 -87
- data/test/projects/MissingAssets/MissingAssets.uia +0 -0
- data/test/projects/MissingAssets/MissingAssets.uia-user +14 -14
- data/test/projects/MissingAssets/RoundedPlane-1/RoundedPlane-1.import +18 -18
- data/test/projects/MissingAssets/RoundedPlane-1/meshes/RoundedPlane.mesh +0 -0
- data/test/projects/MissingAssets/effects/effects.txt +0 -0
- data/test/projects/MissingAssets/effects/existing.effect +0 -0
- data/test/projects/MissingAssets/fonts/Arimo-Regular.ttf +0 -0
- data/test/projects/MissingAssets/fonts/Chivo-Black.ttf +0 -0
- data/test/projects/MissingAssets/fonts/OFL.txt +0 -0
- data/test/projects/MissingAssets/maps/effects/brushnoise.dds +0 -0
- data/test/projects/MissingAssets/maps/existing.png +0 -0
- data/test/projects/MissingAssets/maps/maps.txt +0 -0
- data/test/projects/MissingAssets/maps/materials/concrete_plain.png +0 -0
- data/test/projects/MissingAssets/maps/materials/concrete_plain_bump.png +0 -0
- data/test/projects/MissingAssets/maps/materials/spherical_checker.png +0 -0
- data/test/projects/MissingAssets/materials/concrete.material +0 -0
- data/test/projects/MissingAssets/materials/materials.txt +0 -0
- data/test/projects/MissingAssets/scripts/existing1.lua +0 -0
- data/test/projects/MissingAssets/scripts/existing2.lua +0 -0
- data/test/projects/MissingAssets/states/existing.scxml +0 -0
- data/test/projects/MissingAssets/tests/interface-navigation.scxml-test +0 -0
- data/test/projects/Paths/Paths.uia +4 -4
- data/test/projects/Paths/Paths.uip +98 -98
- data/test/projects/SimpleScene/SimpleScene.uia +4 -4
- data/test/projects/SimpleScene/SimpleScene.uip +35 -35
- data/test/properties.ruic +80 -80
- data/test/referencematerials.ruic +50 -50
- data/test/usage.ruic +54 -54
- metadata +5 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c4a0b020e018104674acc04364e26190043161b
|
4
|
+
data.tar.gz: dfea032213116f92cd14c5eccb35286213b28a96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2314350ab17e64a43e6afdf95537287e4ce781f023172634a02e7b285c38c88e1e344df87bbe1bb2feee655a17d1f5b4f0f8fcce0b7caf5e23dbe85b11d2728d
|
7
|
+
data.tar.gz: 1f2e65d2327897075f4c91917aa21d504a3919790d12cdd94a41392584291b1f5d1bd0600ebdf797be4e94afed51d7cbec9890dc74d8a63ad71cdda6240bf94c
|
data/.yardopts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
--no-private
|
2
|
-
--markup markdown
|
3
|
-
lib/**/*.rb -
|
1
|
+
--no-private
|
2
|
+
--markup markdown
|
3
|
+
lib/**/*.rb -
|
4
4
|
README.md LICENSE HISTORY
|
data/HISTORY
CHANGED
@@ -1,86 +1,110 @@
|
|
1
|
-
## v0.6.
|
2
|
-
|
3
|
-
###
|
4
|
-
|
5
|
-
*
|
6
|
-
*
|
7
|
-
|
8
|
-
###
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
*
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
*
|
22
|
-
*
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
*
|
30
|
-
|
31
|
-
|
32
|
-
* Fix bug that
|
33
|
-
*
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
*
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
*
|
45
|
-
*
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
*
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
*
|
60
|
-
|
61
|
-
|
62
|
-
*
|
63
|
-
|
64
|
-
|
65
|
-
## v0.
|
66
|
-
*
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
*
|
73
|
-
|
74
|
-
|
75
|
-
## v0.2.
|
76
|
-
*
|
77
|
-
|
78
|
-
|
79
|
-
## v0.
|
80
|
-
*
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
*
|
86
|
-
|
1
|
+
## v0.6.1
|
2
|
+
|
3
|
+
### New/Changed Features
|
4
|
+
|
5
|
+
* Support for the new `PathBuffer` property types (for paths that reference a `.path` on disk).
|
6
|
+
* Unsupported/invalid custom property types fall back to String (with a warning).
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
* Render plugins are now lightly tested and supported.
|
10
|
+
|
11
|
+
|
12
|
+
## v0.6.0
|
13
|
+
|
14
|
+
### Backwards Incompatible Changes
|
15
|
+
|
16
|
+
* Changed `FileBacked#resolve_file_path` to `FileBacked#absolute_path`, and added `FileBacked#relative_path`.
|
17
|
+
* Removed `.errors?` and `.errors` for application and assets.
|
18
|
+
|
19
|
+
### New/Changed Features
|
20
|
+
|
21
|
+
* State machines properly report on visual actions.
|
22
|
+
* _Only `<set-attribute>` properly implemented so far._
|
23
|
+
* Added much improved `Presentation#referenced_files`, `Application#missing_files`, `Application#unused_files`.
|
24
|
+
* Tweaked REPL output.
|
25
|
+
* `nil` results no longer print `#=> nil` in the REPL.
|
26
|
+
* `show` prefixes the result with `#=>`.
|
27
|
+
* Multi-line results are now wrapped, with each line prefixed with `#=>`.
|
28
|
+
* Added beginnings of support for effects and renderplugins.
|
29
|
+
* Presentations do not cause a runtime error if a custom class (e.g. behavior, effect, custom material) cannot be found.
|
30
|
+
|
31
|
+
### Bug Fixes
|
32
|
+
* Fix bug that caused some properties to report their type as `nil` or `float` instead of `Float`.
|
33
|
+
* Presentations are slightly more capable if they are created without an existing file.
|
34
|
+
|
35
|
+
|
36
|
+
## v0.5.0 - 2014-Nov-26
|
37
|
+
|
38
|
+
* Fix bug that prevented loading an application from the command line in another directory.
|
39
|
+
* Compatibility: `FileBacked#path_to` is now `FileBacked#resolve_file_path` to prevent conflict with `Presentation#path_to`.
|
40
|
+
* Make `inspect` representation of assets more useful.
|
41
|
+
* Add convenience methods for collections of assets by type on presentations:
|
42
|
+
`.layers`, `.groups`, `.cameras`, `.lights`, `.components`, `.models`, `.materials`,
|
43
|
+
`.images`, `.behaviors`, `.aliases`, `.paths`, `.anchor_points`, `.texts`
|
44
|
+
* Fix bug that prevented behavior instances from having proper `name` or `sourcepath` attribute values.
|
45
|
+
* Added `.hierarchy` to presentations and assets for printing the scene graph.
|
46
|
+
|
47
|
+
|
48
|
+
## v0.4.5 - 2014-Nov-19
|
49
|
+
|
50
|
+
* Added a large amount of documentation.
|
51
|
+
* Minor code refactoring:
|
52
|
+
* Most (internal) Presentation methods that took a scene graph element as the argument now take an asset.
|
53
|
+
* All `FileBacked` assets now have `save!` and `save_as`.
|
54
|
+
|
55
|
+
|
56
|
+
## v0.4.1 - 2014-Nov-16
|
57
|
+
|
58
|
+
* Update `MetaData.xml` for tests to newest version.
|
59
|
+
* Source paths for images/textures normalize the path (forward slashes and no leading `./`).
|
60
|
+
* Added `app.main` as a simpler alias for `app.main_presentation`.
|
61
|
+
* Add support for paths and anchor points, including `mypath.anchors` as an array of anchor points.
|
62
|
+
* Assets present in MetaData and presentation, but not yet hand-entered into the hierarchy, now work and default to inherit from `Asset`.
|
63
|
+
|
64
|
+
|
65
|
+
## v0.4.0 - 2014-Nov-11
|
66
|
+
* Switch attribute filtering again; now all attributes are inline in the `find()` hash, and the four special keys are prefixed with an underscore: `_type`, `_slide`, `_master`, and `_under`.
|
67
|
+
|
68
|
+
|
69
|
+
## v0.3.0 - 2014-Nov-10
|
70
|
+
* Switch attribute filtering to use `attr:{ … }` instead of `attributes:{ … }`
|
71
|
+
* Attribute matching now requires that a requested attribute be present, or else the asset matching fails.
|
72
|
+
* _For example, `main.find attr:{ diffusecolor:[nil,nil,nil] }` will now only find assets with a `diffusecolor` attribute._
|
73
|
+
|
74
|
+
|
75
|
+
## v0.2.5 - 2014-Nov-10
|
76
|
+
* Re-adds blank line after REPL result.
|
77
|
+
|
78
|
+
|
79
|
+
## v0.2.4 - 2014-Nov-10
|
80
|
+
* Fix bug with history editing in REPL (prompts no longer have a blank line before)
|
81
|
+
* Add temporary hack to make projects using Float2 load correctly
|
82
|
+
|
83
|
+
|
84
|
+
## v0.2.3 - 2014-Nov-7
|
85
|
+
* Cleaner mechanism for creating a truly blank binding
|
86
|
+
|
87
|
+
|
88
|
+
## v0.2.2 - 2014-Nov-7
|
89
|
+
* REPL shows version number when it starts
|
90
|
+
|
91
|
+
|
92
|
+
## v0.2.1 - 2014-Nov-7
|
93
|
+
* REPL mode after script maintains binding of script (all local variables remain available)
|
94
|
+
* Customized `.irbrc` files will not cause warnings
|
95
|
+
|
96
|
+
|
97
|
+
## v0.2.0 - 2014-Nov-7
|
98
|
+
* Add Presentation#save_as
|
99
|
+
* REPL working directory is same as .uia
|
100
|
+
|
101
|
+
|
102
|
+
## v0.1.0 - 2014-Nov-7
|
103
|
+
* Add REPL mode for ruic binary
|
104
|
+
|
105
|
+
|
106
|
+
## v0.0.1 - 2014-Nov-7
|
107
|
+
* Initial gem release
|
108
|
+
* Crawl presentations and modify attributes
|
109
|
+
* Batch find assets
|
110
|
+
* Save presentation changes back to disk
|
data/README.md
CHANGED
@@ -1,220 +1,220 @@
|
|
1
|
-
# What is RUIC?
|
2
|
-
RUIC is a Ruby API for reading, analyzing, and manipulating application assets created by NVIDIA's [UI Composer][1]. Among other things, it allows you to:
|
3
|
-
|
4
|
-
* See if an application is missing any assets (e.g. images or meshes) and what parts of the application are looking for those.
|
5
|
-
* See if there are any files in the application folder that you can delete (e.g. images or materials that are no longer being used).
|
6
|
-
* Read and modify the attributes of elements on different slides.
|
7
|
-
* Batch change attributes (e.g. change all usage of one font or color to another).
|
8
|
-
* Procedurally generate many models with automated placement in your scene.
|
9
|
-
|
10
|
-
_Some of the features above are planned, but not yet implemented; see Known Limitations below._
|
11
|
-
|
12
|
-
|
13
|
-
# Documentation
|
14
|
-
|
15
|
-
In addition to the examples in this file full API documentation is available at:
|
16
|
-
http://www.rubydoc.info/gems/RUIC/
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# Installing RUIC
|
21
|
-
RUIC can be installed via RubyGems (part of Ruby) via the command:
|
22
|
-
|
23
|
-
gem install ruic # May need `sudo gem install ruic` depending on your setup
|
24
|
-
|
25
|
-
Although RUIC is a pure-Ruby library, it relies on [Nokogiri][2] for all the XML processing and manipulation. Installing RUIC will also automatically install Nokogiri, which may require some compilation.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
# Using the RUIC DSL
|
30
|
-
|
31
|
-
RUIC scripts are pure Ruby with a few convenience methods added. You run them via the `ruic` command-line script, e.g.
|
32
|
-
|
33
|
-
ruic myscript.ruic # or .rb extension, for syntax highlighting while editing
|
34
|
-
|
35
|
-
|
36
|
-
## Creating and Accessing Applications
|
37
|
-
RUIC scripts must start with `uia` commands to load an application and all its assets.
|
38
|
-
After this you can access the application as `app`:
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
uia '../MyApp.uia' # Relative to the ruic script file, or absolute
|
42
|
-
|
43
|
-
show app.file #=> /var/projects/UIC/MyApp/main/MyApp.uia
|
44
|
-
show app.filename #=> MyApp.uia
|
45
|
-
|
46
|
-
show app.assets.count #=> 7
|
47
|
-
# You can ask for app.behaviors, app.presentations, app.statemachines, and app.renderplugins
|
48
|
-
# for arrays of specific asset types
|
49
|
-
```
|
50
|
-
|
51
|
-
_The `show` command prints the result; it is simply a nicer alias for `puts`._
|
52
|
-
|
53
|
-
If you need to load multiple applications in the same script, subsequent `uia` commands will create
|
54
|
-
`app2`, `app3`, etc. for you to use.
|
55
|
-
|
56
|
-
```ruby
|
57
|
-
uia '../MyApp.uia' # Available as 'app'
|
58
|
-
uia '../../v1/MyApp.uia' # Available as 'app2'
|
59
|
-
```
|
60
|
-
|
61
|
-
|
62
|
-
## Working with Presentations
|
63
|
-
|
64
|
-
```ruby
|
65
|
-
uia '../MyApp.uia'
|
66
|
-
|
67
|
-
main = app.main_presentation # The presentation displayed as the main presentation (regardless of id)
|
68
|
-
sub = app['#nav'] # You can ask for an asset based on the id in the .uia...
|
69
|
-
sub = app['Navigation.uip'] # or based on the path to the file (relative to the .uia)
|
70
|
-
|
71
|
-
|
72
|
-
car = sub/"Scene.Vehicle.Group.Car" # Find elements in a presentation by presentation path…
|
73
|
-
car = app/"nav:Scene.Vehicle.Group.Car" # …or absolute application path
|
74
|
-
|
75
|
-
show car.name #=> Car
|
76
|
-
show car.type #=> Model # Scene, Layer, Camera, Light, Group, Model, Material,
|
77
|
-
# Image, Behavior, Effect, ReferencedMaterial, Text,
|
78
|
-
# RenderPlugin, Component, (custom materials)
|
79
|
-
|
80
|
-
show car.component? #=> false # Ask if an element is a component
|
81
|
-
assert car.component==sub.scene # Ask for the owning component; may be the scene
|
82
|
-
```
|
83
|
-
|
84
|
-
## Finding Many Assets
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
uia 'MyApp.uia'
|
88
|
-
main = app.main_presentation
|
89
|
-
|
90
|
-
every_asset = main.find # Array of matching assets
|
91
|
-
master_assets = main.find _master:true # Test for master/nonmaster
|
92
|
-
models = main.find _type:'Model' # …or based on type
|
93
|
-
slide2_assets = main.find _slide:2 # …or presence on slide
|
94
|
-
rectangles = main.find sourcepath:'#Rectangle' # …or attribute values
|
95
|
-
gamecovers = main.find name:'Game Cover' # …including the name
|
96
|
-
|
97
|
-
# Combine tests to get more specific
|
98
|
-
master_models = main.find _type:'Model', _master:true
|
99
|
-
slide2_rects = main.find _type:'Model', _slide:2, sourcepath:'#Rectangle'
|
100
|
-
nonmaster_s2 = main.find _slide:2, _master:false
|
101
|
-
red_materials = main.find _type:'Material', diffuse:[1,0,0]
|
102
|
-
|
103
|
-
# You can match values more loosely
|
104
|
-
pistons = main.find name:/^Piston/ # Regex for batch finding
|
105
|
-
bottom_row = main.find position:[nil,-200,nil] # nil for wildcards in vectors
|
106
|
-
|
107
|
-
# Restrict the search to a sub-tree
|
108
|
-
group = main/"Scene.Layer.Group"
|
109
|
-
group_models = group.find _type:'Model' # Orig asset is never included
|
110
|
-
group_models = main.find _under:group, _type:'Model' # Or, use `_under` to limit
|
111
|
-
|
112
|
-
# Iterate the results as they are found
|
113
|
-
main.find _type:'Model', name:/^Piston/ do |model, index| # Using the index is optional
|
114
|
-
show "Model #{index} is named #{model.name}"
|
115
|
-
end
|
116
|
-
```
|
117
|
-
|
118
|
-
Notes:
|
119
|
-
|
120
|
-
* `nil` inside an array is a "wildcard" value, allowing you to test only specific values
|
121
|
-
* Numbers (both in vectors/colors/rotations and float/long values) must only be within `0.001` to match.
|
122
|
-
* _For example, `attr:{diffuse:[1,0,0]}` will match a color with `diffuse=".9997 0.0003 0"`_
|
123
|
-
* Results of `find` are always in scene-graph order.
|
124
|
-
|
125
|
-
|
126
|
-
## Working with References
|
127
|
-
|
128
|
-
```ruby
|
129
|
-
uia 'MyApp.uia'
|
130
|
-
mat1 = app/"main:Scene.Layer.Sphere.Material" # A normal UIC Material
|
131
|
-
mat2 = app/"main:Scene.Layer.Cube.Material" # A normal UIC Material
|
132
|
-
p mat2.type #=> "Material"
|
133
|
-
ref = mat2.replace_with_referenced_material # A very specific method :)
|
134
|
-
p ref.properties['referencedmaterial'].type #=> "ObjectRef"
|
135
|
-
p ref['referencedmaterial',0].object #=> nil
|
136
|
-
p ref['referencedmaterial',0].type #=> :absolute
|
137
|
-
ref['referencedmaterial',0].object = mat1 #=> Sets an absolute reference
|
138
|
-
ref['referencedmaterial',0].type = :path #=> Use a relative path instead
|
139
|
-
|
140
|
-
# Alternatively, you can omit the .object when setting the reference:
|
141
|
-
# ref['referencedmaterial',0] = mat1
|
142
|
-
|
143
|
-
mat3 = ref['referencedmaterial',1].object #=> Get the asset pointed to
|
144
|
-
assert mat1 == mat3 #=> They are the same! It worked!
|
145
|
-
|
146
|
-
app.save_all! #=> Write presentations in place
|
147
|
-
```
|
148
|
-
|
149
|
-
|
150
|
-
## Locating MetaData.xml
|
151
|
-
RUIC needs access to a UIC `MetaData.xml` file to understand the properties in the various XML files.
|
152
|
-
By default RUIC will look in the location specified by `RUIC::DEFAULTMETADATA`, e.g.
|
153
|
-
`C:/Program Files (x86)/NVIDIA Corporation/UI Composer 8.0/res/DataModelMetadata/en-us/MetaData.xml`
|
154
|
-
|
155
|
-
If this file is in another location, you can tell the script where to find it either:
|
156
|
-
|
157
|
-
* on the command line: `ruic -m path/to/MetaData.xml myscript.ruic`
|
158
|
-
* in your ruic script: `metadata 'path/to/MetaData.xml' # before any 'app' commands`
|
159
|
-
|
160
|
-
|
161
|
-
# Interactive RUIC
|
162
|
-
In addition to executing a standalone script, RUIC also has a REPL (like IRB) that allows you to
|
163
|
-
interactively execute and test changes to your application/presentations before saving.
|
164
|
-
There are two ways to enter interactive mode:
|
165
|
-
|
166
|
-
* If you invoke the `ruic` binary with a `.uia` file as the argument the interpreter will load
|
167
|
-
the application and enter the REPL:
|
168
|
-
|
169
|
-
$ ruic myapp.uia
|
170
|
-
(RUIC v0.6.0 interactive session; 'quit' or ctrl-d to end)
|
171
|
-
|
172
|
-
uia "test/projects/SimpleScene/SimpleScene.uia"
|
173
|
-
#=> <UIC::Application 'SimpleScene.uia'>
|
174
|
-
|
175
|
-
* Alternatively, you can have RUIC execute a script and then enter the interactive REPL
|
176
|
-
by supplying the `-i` command-line switch:
|
177
|
-
|
178
|
-
$ ruic -i test/referencematerials.ruic
|
179
|
-
(RUIC v0.6.0 interactive session; 'quit' or ctrl-d to end)
|
180
|
-
|
181
|
-
app
|
182
|
-
#=> <UIC::Application 'ReferencedMaterials.uia'>
|
183
|
-
|
184
|
-
cubemat
|
185
|
-
#=> <asset Material#Material_002>
|
186
|
-
|
187
|
-
As shown above, all local variables created by the script continue to be available
|
188
|
-
in the interactive session.
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
# Known Limitations (aka TODO)
|
193
|
-
_In decreasing priority…_
|
194
|
-
|
195
|
-
- Report on image assets, their sizes
|
196
|
-
- Report used assets (and where they are used)
|
197
|
-
- Report unused assets (in a format suitable for automated destruction)
|
198
|
-
- Report missing assets (and who was looking for them)
|
199
|
-
- Gobs more unit tests
|
200
|
-
- Parse .lua headers (in case one references an image)
|
201
|
-
- Parse render plugins
|
202
|
-
- Read/edit animation tracks
|
203
|
-
- Find all colors, and where they are used
|
204
|
-
- Visual actions for State Machines
|
205
|
-
- Create new presentation assets (e.g. add a new sphere)
|
206
|
-
- Modify the scene graph of presentations
|
207
|
-
- Create new presentations/applications from code
|
208
|
-
- Report on image asset file formats (e.g. find PNGs, find DXT1 vs DXT3 vs DXT Luminance…)
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
# License & Contact
|
213
|
-
RUIC is copyright ©2014 by Gavin Kistner and is licensed under the [MIT License][3]. See the `LICENSE` file for more details.
|
214
|
-
|
215
|
-
For bugs or feature requests please open [issues on GitHub][4]. For other communication you can [email the author directly](mailto:!@phrogz.net?subject=RUIC).
|
216
|
-
|
217
|
-
[1]: http://uicomposer.nvidia.com
|
218
|
-
[2]: http://nokogiri.org
|
219
|
-
[3]: http://opensource.org/licenses/MIT
|
220
|
-
[4]: https://github.com/Phrogz/RUIC/issues
|
1
|
+
# What is RUIC?
|
2
|
+
RUIC is a Ruby API for reading, analyzing, and manipulating application assets created by NVIDIA's [UI Composer][1]. Among other things, it allows you to:
|
3
|
+
|
4
|
+
* See if an application is missing any assets (e.g. images or meshes) and what parts of the application are looking for those.
|
5
|
+
* See if there are any files in the application folder that you can delete (e.g. images or materials that are no longer being used).
|
6
|
+
* Read and modify the attributes of elements on different slides.
|
7
|
+
* Batch change attributes (e.g. change all usage of one font or color to another).
|
8
|
+
* Procedurally generate many models with automated placement in your scene.
|
9
|
+
|
10
|
+
_Some of the features above are planned, but not yet implemented; see Known Limitations below._
|
11
|
+
|
12
|
+
|
13
|
+
# Documentation
|
14
|
+
|
15
|
+
In addition to the examples in this file full API documentation is available at:
|
16
|
+
http://www.rubydoc.info/gems/RUIC/
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
# Installing RUIC
|
21
|
+
RUIC can be installed via RubyGems (part of Ruby) via the command:
|
22
|
+
|
23
|
+
gem install ruic # May need `sudo gem install ruic` depending on your setup
|
24
|
+
|
25
|
+
Although RUIC is a pure-Ruby library, it relies on [Nokogiri][2] for all the XML processing and manipulation. Installing RUIC will also automatically install Nokogiri, which may require some compilation.
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# Using the RUIC DSL
|
30
|
+
|
31
|
+
RUIC scripts are pure Ruby with a few convenience methods added. You run them via the `ruic` command-line script, e.g.
|
32
|
+
|
33
|
+
ruic myscript.ruic # or .rb extension, for syntax highlighting while editing
|
34
|
+
|
35
|
+
|
36
|
+
## Creating and Accessing Applications
|
37
|
+
RUIC scripts must start with `uia` commands to load an application and all its assets.
|
38
|
+
After this you can access the application as `app`:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
uia '../MyApp.uia' # Relative to the ruic script file, or absolute
|
42
|
+
|
43
|
+
show app.file #=> /var/projects/UIC/MyApp/main/MyApp.uia
|
44
|
+
show app.filename #=> MyApp.uia
|
45
|
+
|
46
|
+
show app.assets.count #=> 7
|
47
|
+
# You can ask for app.behaviors, app.presentations, app.statemachines, and app.renderplugins
|
48
|
+
# for arrays of specific asset types
|
49
|
+
```
|
50
|
+
|
51
|
+
_The `show` command prints the result; it is simply a nicer alias for `puts`._
|
52
|
+
|
53
|
+
If you need to load multiple applications in the same script, subsequent `uia` commands will create
|
54
|
+
`app2`, `app3`, etc. for you to use.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
uia '../MyApp.uia' # Available as 'app'
|
58
|
+
uia '../../v1/MyApp.uia' # Available as 'app2'
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
## Working with Presentations
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
uia '../MyApp.uia'
|
66
|
+
|
67
|
+
main = app.main_presentation # The presentation displayed as the main presentation (regardless of id)
|
68
|
+
sub = app['#nav'] # You can ask for an asset based on the id in the .uia...
|
69
|
+
sub = app['Navigation.uip'] # or based on the path to the file (relative to the .uia)
|
70
|
+
|
71
|
+
|
72
|
+
car = sub/"Scene.Vehicle.Group.Car" # Find elements in a presentation by presentation path…
|
73
|
+
car = app/"nav:Scene.Vehicle.Group.Car" # …or absolute application path
|
74
|
+
|
75
|
+
show car.name #=> Car
|
76
|
+
show car.type #=> Model # Scene, Layer, Camera, Light, Group, Model, Material,
|
77
|
+
# Image, Behavior, Effect, ReferencedMaterial, Text,
|
78
|
+
# RenderPlugin, Component, (custom materials)
|
79
|
+
|
80
|
+
show car.component? #=> false # Ask if an element is a component
|
81
|
+
assert car.component==sub.scene # Ask for the owning component; may be the scene
|
82
|
+
```
|
83
|
+
|
84
|
+
## Finding Many Assets
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
uia 'MyApp.uia'
|
88
|
+
main = app.main_presentation
|
89
|
+
|
90
|
+
every_asset = main.find # Array of matching assets
|
91
|
+
master_assets = main.find _master:true # Test for master/nonmaster
|
92
|
+
models = main.find _type:'Model' # …or based on type
|
93
|
+
slide2_assets = main.find _slide:2 # …or presence on slide
|
94
|
+
rectangles = main.find sourcepath:'#Rectangle' # …or attribute values
|
95
|
+
gamecovers = main.find name:'Game Cover' # …including the name
|
96
|
+
|
97
|
+
# Combine tests to get more specific
|
98
|
+
master_models = main.find _type:'Model', _master:true
|
99
|
+
slide2_rects = main.find _type:'Model', _slide:2, sourcepath:'#Rectangle'
|
100
|
+
nonmaster_s2 = main.find _slide:2, _master:false
|
101
|
+
red_materials = main.find _type:'Material', diffuse:[1,0,0]
|
102
|
+
|
103
|
+
# You can match values more loosely
|
104
|
+
pistons = main.find name:/^Piston/ # Regex for batch finding
|
105
|
+
bottom_row = main.find position:[nil,-200,nil] # nil for wildcards in vectors
|
106
|
+
|
107
|
+
# Restrict the search to a sub-tree
|
108
|
+
group = main/"Scene.Layer.Group"
|
109
|
+
group_models = group.find _type:'Model' # Orig asset is never included
|
110
|
+
group_models = main.find _under:group, _type:'Model' # Or, use `_under` to limit
|
111
|
+
|
112
|
+
# Iterate the results as they are found
|
113
|
+
main.find _type:'Model', name:/^Piston/ do |model, index| # Using the index is optional
|
114
|
+
show "Model #{index} is named #{model.name}"
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
118
|
+
Notes:
|
119
|
+
|
120
|
+
* `nil` inside an array is a "wildcard" value, allowing you to test only specific values
|
121
|
+
* Numbers (both in vectors/colors/rotations and float/long values) must only be within `0.001` to match.
|
122
|
+
* _For example, `attr:{diffuse:[1,0,0]}` will match a color with `diffuse=".9997 0.0003 0"`_
|
123
|
+
* Results of `find` are always in scene-graph order.
|
124
|
+
|
125
|
+
|
126
|
+
## Working with References
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
uia 'MyApp.uia'
|
130
|
+
mat1 = app/"main:Scene.Layer.Sphere.Material" # A normal UIC Material
|
131
|
+
mat2 = app/"main:Scene.Layer.Cube.Material" # A normal UIC Material
|
132
|
+
p mat2.type #=> "Material"
|
133
|
+
ref = mat2.replace_with_referenced_material # A very specific method :)
|
134
|
+
p ref.properties['referencedmaterial'].type #=> "ObjectRef"
|
135
|
+
p ref['referencedmaterial',0].object #=> nil
|
136
|
+
p ref['referencedmaterial',0].type #=> :absolute
|
137
|
+
ref['referencedmaterial',0].object = mat1 #=> Sets an absolute reference
|
138
|
+
ref['referencedmaterial',0].type = :path #=> Use a relative path instead
|
139
|
+
|
140
|
+
# Alternatively, you can omit the .object when setting the reference:
|
141
|
+
# ref['referencedmaterial',0] = mat1
|
142
|
+
|
143
|
+
mat3 = ref['referencedmaterial',1].object #=> Get the asset pointed to
|
144
|
+
assert mat1 == mat3 #=> They are the same! It worked!
|
145
|
+
|
146
|
+
app.save_all! #=> Write presentations in place
|
147
|
+
```
|
148
|
+
|
149
|
+
|
150
|
+
## Locating MetaData.xml
|
151
|
+
RUIC needs access to a UIC `MetaData.xml` file to understand the properties in the various XML files.
|
152
|
+
By default RUIC will look in the location specified by `RUIC::DEFAULTMETADATA`, e.g.
|
153
|
+
`C:/Program Files (x86)/NVIDIA Corporation/UI Composer 8.0/res/DataModelMetadata/en-us/MetaData.xml`
|
154
|
+
|
155
|
+
If this file is in another location, you can tell the script where to find it either:
|
156
|
+
|
157
|
+
* on the command line: `ruic -m path/to/MetaData.xml myscript.ruic`
|
158
|
+
* in your ruic script: `metadata 'path/to/MetaData.xml' # before any 'app' commands`
|
159
|
+
|
160
|
+
|
161
|
+
# Interactive RUIC
|
162
|
+
In addition to executing a standalone script, RUIC also has a REPL (like IRB) that allows you to
|
163
|
+
interactively execute and test changes to your application/presentations before saving.
|
164
|
+
There are two ways to enter interactive mode:
|
165
|
+
|
166
|
+
* If you invoke the `ruic` binary with a `.uia` file as the argument the interpreter will load
|
167
|
+
the application and enter the REPL:
|
168
|
+
|
169
|
+
$ ruic myapp.uia
|
170
|
+
(RUIC v0.6.0 interactive session; 'quit' or ctrl-d to end)
|
171
|
+
|
172
|
+
uia "test/projects/SimpleScene/SimpleScene.uia"
|
173
|
+
#=> <UIC::Application 'SimpleScene.uia'>
|
174
|
+
|
175
|
+
* Alternatively, you can have RUIC execute a script and then enter the interactive REPL
|
176
|
+
by supplying the `-i` command-line switch:
|
177
|
+
|
178
|
+
$ ruic -i test/referencematerials.ruic
|
179
|
+
(RUIC v0.6.0 interactive session; 'quit' or ctrl-d to end)
|
180
|
+
|
181
|
+
app
|
182
|
+
#=> <UIC::Application 'ReferencedMaterials.uia'>
|
183
|
+
|
184
|
+
cubemat
|
185
|
+
#=> <asset Material#Material_002>
|
186
|
+
|
187
|
+
As shown above, all local variables created by the script continue to be available
|
188
|
+
in the interactive session.
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
# Known Limitations (aka TODO)
|
193
|
+
_In decreasing priority…_
|
194
|
+
|
195
|
+
- Report on image assets, their sizes
|
196
|
+
- Report used assets (and where they are used)
|
197
|
+
- Report unused assets (in a format suitable for automated destruction)
|
198
|
+
- Report missing assets (and who was looking for them)
|
199
|
+
- Gobs more unit tests
|
200
|
+
- Parse .lua headers (in case one references an image)
|
201
|
+
- Parse render plugins
|
202
|
+
- Read/edit animation tracks
|
203
|
+
- Find all colors, and where they are used
|
204
|
+
- Visual actions for State Machines
|
205
|
+
- Create new presentation assets (e.g. add a new sphere)
|
206
|
+
- Modify the scene graph of presentations
|
207
|
+
- Create new presentations/applications from code
|
208
|
+
- Report on image asset file formats (e.g. find PNGs, find DXT1 vs DXT3 vs DXT Luminance…)
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
# License & Contact
|
213
|
+
RUIC is copyright ©2014 by Gavin Kistner and is licensed under the [MIT License][3]. See the `LICENSE` file for more details.
|
214
|
+
|
215
|
+
For bugs or feature requests please open [issues on GitHub][4]. For other communication you can [email the author directly](mailto:!@phrogz.net?subject=RUIC).
|
216
|
+
|
217
|
+
[1]: http://uicomposer.nvidia.com
|
218
|
+
[2]: http://nokogiri.org
|
219
|
+
[3]: http://opensource.org/licenses/MIT
|
220
|
+
[4]: https://github.com/Phrogz/RUIC/issues
|