assimp 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2267f3196b45b54118aaf7ed88c26b82b9b4a821
4
- data.tar.gz: 26918deb266399e35e175413a187a1ac9f3060f7
3
+ metadata.gz: eee234d3825f9b4c8af0cc10d6333afd34b19884
4
+ data.tar.gz: c1ace6c4ff29adb75270e2f95bfedacc152c08b9
5
5
  SHA512:
6
- metadata.gz: 489bdc6e880842c0bf8f863f001a01019439f2bd450b454683476f8fee621d3ef3eca702977e1721a480e35823ad1d809bcc2ee7ed2d7d3acd3e99fc5a0f7075
7
- data.tar.gz: b06590faa7886951d9cbd0e5c14d580862155d838eebbab13213b337f4fd9144146495caa1181c39f6a07e8d581dcde58b540a142abf40853390f8b1e2c2e84e
6
+ metadata.gz: aa734b7160f8830b7658c265776696950c4007cbb4803b2b39beae71aa25c07b84d05145fe9bc2aa1d2d3fb594007750019d036337439d807cd59eed8fe7be24
7
+ data.tar.gz: e33d24b11d4884810ce6117680e843855271d27662cffefd019ed5421140908697dd93e2ceb8aae5f5161c0684900b5fd21b9474b01dbc8c3ea45cd0f882c6ea
data/History.rdoc CHANGED
@@ -4,3 +4,9 @@
4
4
 
5
5
  * Birthday!
6
6
  * Importer.read_file reads structure into hash
7
+
8
+
9
+ === 0.0.2 / 2014-01-31
10
+
11
+ * Some minor enhancements
12
+ * Added several new flags to the basic api.
data/README.rdoc CHANGED
@@ -30,7 +30,7 @@ https://github.com/coballast/assimp
30
30
  scene = importer.read_file("example_file.3ds",
31
31
  [:triangulate, :make_left_handed, :calc_tangent_space]);
32
32
 
33
- pp scene.to_hash
33
+ pp scene
34
34
 
35
35
  # out prints nicely formated data like meshes,
36
36
  # animations, and materials for consumption by say, a webgl front end renderer.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'hoe'
3
3
  require 'rake/extensiontask'
4
4
 
5
- assimp_gem_version = '0.0.1'
5
+ assimp_gem_version = '0.0.2'
6
6
 
7
7
  Hoe.spec 'assimp' do
8
8
  developer('Colin Ballast', 'coballast@gmail.com')
@@ -5,7 +5,7 @@ VALUE get_Hash_from_aiBone(struct aiBone * bone)
5
5
  VALUE result, name, offset_matrix, weights;
6
6
  unsigned int i;
7
7
  result = rb_hash_new();
8
- name = rb_str_new2(&bone->mName.data[0]);
8
+ name = get_rb_str_from_aiString(&bone->mName);
9
9
  offset_matrix = get_Array_from_aiMatrix4x4(&bone->mOffsetMatrix);
10
10
  weights = rb_ary_new();
11
11
  for(i = 0; i < bone->mNumWeights; i++){
@@ -5,73 +5,84 @@ static VALUE initialize(VALUE self)
5
5
  return self;
6
6
  }
7
7
 
8
+ unsigned int get_flags(VALUE flags_array)
9
+ {
10
+ unsigned int array_len, i, flags;
11
+
12
+ Check_Type(flags_array, T_ARRAY);
13
+ flags = 0;
14
+ array_len = RARRAY_LEN(flags_array);
15
+ for(i = 0; i < array_len; i++){
16
+ VALUE element;
17
+ element = rb_ary_entry(flags_array, i);
18
+ if(TYPE(element)==T_SYMBOL){
19
+ ID sym_id;
20
+ sym_id = SYM2ID(element);
21
+ if(sym_id==rb_intern("triangulate"))
22
+ flags |= aiProcess_Triangulate;
23
+
24
+ if(sym_id==rb_intern("calc_tangent_space"))
25
+ flags |= aiProcess_CalcTangentSpace;
26
+
27
+ if(sym_id==rb_intern("make_left_handed"))
28
+ flags |= aiProcess_MakeLeftHanded;
29
+
30
+ if(sym_id==rb_intern("gen_normals"))
31
+ flags |= aiProcess_GenNormals;
32
+
33
+ if(sym_id==rb_intern("gen_smooth_normals"))
34
+ flags |= aiProcess_GenSmoothNormals;
35
+
36
+ if(sym_id==rb_intern("gen_uv_coords"))
37
+ flags |= aiProcess_GenUVCoords;
38
+
39
+ if(sym_id==rb_intern("transform_uv_coords"))
40
+ flags |= aiProcess_TransformUVCoords;
41
+
42
+ if(sym_id==rb_intern("join_identical_vertices"))
43
+ flags |= aiProcess_JoinIdenticalVertices;
44
+
45
+ if(sym_id==rb_intern("pretransform_vertices"))
46
+ flags |= aiProcess_PreTransformVertices;
47
+
48
+ if(sym_id==rb_intern("validate_data_structure"))
49
+ flags |= aiProcess_ValidateDataStructure;
50
+
51
+ if(sym_id==rb_intern("improve_cache_locality"))
52
+ flags |= aiProcess_ImproveCacheLocality;
53
+
54
+ if(sym_id==rb_intern("fix_infacing_normals"))
55
+ flags |= aiProcess_FixInfacingNormals;
56
+
57
+ if(sym_id==rb_intern("sort_by_p_type"))
58
+ flags |= aiProcess_SortByPType;
59
+ }
60
+ }
61
+ return flags;
62
+ }
63
+
8
64
  static VALUE read_file(VALUE self, VALUE args)
9
65
  {
10
66
  char * file_str;
11
67
  struct aiScene * scene;
12
- unsigned int flags, array_len, i;
68
+ unsigned int flags;
13
69
  long num_args;
14
- VALUE file_name, read_flags;
70
+ VALUE file_name, result;
15
71
  flags = 0;
16
72
  num_args = RARRAY_LEN(args);
73
+ result = Qnil;
74
+
17
75
  if(num_args > 2 || num_args < 1)
18
76
  rb_raise(rb_eArgError, "wrong number of arguments");
19
77
 
20
78
  file_name = rb_ary_entry(args, 0);
21
- Check_Type(file_name, T_STRING);
22
- if(num_args > 1){
23
- read_flags = rb_ary_entry(args, 1);
24
- Check_Type(read_flags, T_ARRAY);
25
- array_len = RARRAY_LEN(read_flags);
26
- }
27
-
79
+ Check_Type(file_name, T_STRING);
28
80
  file_str = StringValueCStr(file_name);
29
81
 
30
- if(num_args > 1){
31
- for(i = 0; i < array_len; i++){
32
- VALUE element = rb_ary_entry(read_flags, i);
33
- if(TYPE(element)==T_SYMBOL){
34
- ID sym_id = SYM2ID(element);
35
- if(sym_id==rb_intern("triangulate")){
36
- flags |= aiProcess_Triangulate;
37
- }
38
- if(sym_id==rb_intern("calc_tangent_space")){
39
- flags |= aiProcess_CalcTangentSpace;
40
- }
41
- if(sym_id==rb_intern("make_left_handed")){
42
- flags |= aiProcess_MakeLeftHanded;
43
- }
44
- if(sym_id==rb_intern("gen_normals")){
45
- flags |= aiProcess_GenNormals;
46
- }
47
- if(sym_id==rb_intern("gen_smooth_normals")){
48
- flags |= aiProcess_GenSmoothNormals;
49
- }
50
- if(sym_id==rb_intern("join_identical_vertices")){
51
- flags |= aiProcess_JoinIdenticalVertices;
52
- }
53
- if(sym_id==rb_intern("pretransform_vertices")){
54
- flags |= aiProcess_PreTransformVertices;
55
- }
56
- if(sym_id==rb_intern("validate_data_structure")){
57
- flags |= aiProcess_ValidateDataStructure;
58
- }
59
- if(sym_id==rb_intern("improve_cache_locality")){
60
- flags |= aiProcess_ImproveCacheLocality;
61
- }
62
- if(sym_id==rb_intern("fix_infacing_normals")){
63
- flags |= aiProcess_FixInfacingNormals;
64
- }
65
- if(sym_id==rb_intern("sort_by_p_type")){
66
- flags |= aiProcess_SortByPType;
67
- }
68
- }
69
- }
70
- }
82
+ if(num_args > 1)
83
+ flags = get_flags(rb_ary_entry(args, 1));
71
84
 
72
85
  scene = aiImportFile(file_str, flags);
73
- VALUE result;
74
- result = Qnil;
75
86
 
76
87
  if(!scene)
77
88
  rb_raise(rb_eIOError, aiGetErrorString());
data/lib/assimp.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'assimp/assimp'
2
2
 
3
3
  module ASSIMP
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Ballast
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-25 00:00:00.000000000 Z
11
+ date: 2014-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc