tiny_obj 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +37 -1
- data/lib/tiny_obj/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cb16c82d54588fd6f63383314bd351e4f908d093f0330f72d81f6aa76e826cb
|
4
|
+
data.tar.gz: baed73918e0f7f90fb05192940a28457d4e14e282f5616eaecf28f37f8b7b2d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b3548ab188a5ecec6b902cd14c5a59c6fd19a17ae35e17050e09fcf378a321e8b7721912f666418b224666251297ff890ccd09b869d29973079931668f98af4
|
7
|
+
data.tar.gz: 132f5624215350be97b4f4b13e87f7f7577820fce2198b26541a1e1d5e91aca0557ecf574f10b4f979506c71aa9b998ed9d5148ca47cc75d43cc3abc62318f37
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,10 +24,46 @@ Or install it yourself as:
|
|
24
24
|
require 'tiny_obj'
|
25
25
|
obj = TinyOBJ.load("path/to/file.obj") # finds materials in /path/to
|
26
26
|
obj = TinyOBJ.load("path/to/file.obj", "path/to/materials/dir")
|
27
|
-
|
27
|
+
|
28
|
+
hash = obj.to_hash
|
29
|
+
#=> hash is a hash containing :materials, :vertices, :shapes, and other
|
28
30
|
# goodness.
|
29
31
|
```
|
30
32
|
|
33
|
+
Converting the OBJ into a hash is convenient but not performant. If you are
|
34
|
+
dealing with a large object, you may wish to fill a buffer with data without
|
35
|
+
having to convert it into Ruby hashes, arrays and numbers. You can do that
|
36
|
+
with TinyOBJ#fill_buffers. Below is a complete example, which uses Fiddle to
|
37
|
+
allocate the buffer.
|
38
|
+
|
39
|
+
**Note** that using Fiddle is not required (but is convenient since it ships
|
40
|
+
with Ruby). Only knowing the memory address of the buffer is necessary. Be
|
41
|
+
aware that using the wrong address or not a real (or adequately-sized) buffer
|
42
|
+
can lead to undefined behavior and program crashes.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
vertex_stride = Fiddle::SIZEOF_FLOAT * (
|
46
|
+
3 + # 3 floats for each position (x, y, z)
|
47
|
+
3 + # 3 floats for each normal (x, y, z)
|
48
|
+
2 # 2 floats for each texture coord (u, v)
|
49
|
+
)
|
50
|
+
|
51
|
+
index_stride = 2 # each index will be one uint16, or two 8-bit bytes
|
52
|
+
vertex_buffer = Fiddle::Pointer.malloc(@obj.num_distinct_vertices * vertex_stride)
|
53
|
+
index_buffer = Fiddle::Pointer.malloc(@obj.num_indices * index_stride)
|
54
|
+
|
55
|
+
@obj.fill_buffers(positions: vertex_buffer,
|
56
|
+
normals: vertex_buffer + Fiddle::SIZEOF_FLOAT * 3,
|
57
|
+
texcoords: vertex_buffer + Fiddle::SIZEOF_FLOAT * 6,
|
58
|
+
indices: index_buffer,
|
59
|
+
vertex_stride: vertex_stride,
|
60
|
+
index_stride: index_stride,
|
61
|
+
index_type: :uint16)
|
62
|
+
|
63
|
+
# vertex_buffer now contains interleaved vertex data, and
|
64
|
+
# index_buffer now contains index data.
|
65
|
+
```
|
66
|
+
|
31
67
|
## Development
|
32
68
|
|
33
69
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/tiny_obj/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_obj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin MacKenzie IV
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|