assimp-ffi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,93 @@
1
+ module Assimp
2
+
3
+ class Plane < FFI::Struct
4
+ extend StructAccessors
5
+ layout :a, :ai_real,
6
+ :b, :ai_real,
7
+ :c, :ai_real,
8
+ :d, :ai_real
9
+ struct_attr_accessor :a, :b, :c, :d
10
+ def to_s
11
+ "(#{a}, #{b}, #{c}, #{d})"
12
+ end
13
+ end
14
+
15
+ class Ray < FFI::Struct
16
+ extend StructAccessors
17
+ layout :pos, Vector3D,
18
+ :dir, Vector3D
19
+ struct_attr_accessor :pos, :dir
20
+
21
+ def to_s
22
+ "|#{pos}, #{dir}|"
23
+ end
24
+ end
25
+
26
+ class Color3D < FFI::Struct
27
+ extend StructAccessors
28
+ layout :r, :ai_real,
29
+ :g, :ai_real,
30
+ :b, :ai_real
31
+ struct_attr_accessor :r, :g, :b
32
+
33
+ def to_s
34
+ "[#{r}, #{g}, #{b}]"
35
+ end
36
+ end
37
+
38
+ class String #< FFI::Struct
39
+ extend StructAccessors
40
+ MAXLEN = 1024
41
+ layout :length, :size_t,
42
+ :data, [:char, MAXLEN]
43
+ struct_attr_reader :length
44
+
45
+ def data
46
+ (pointer + Assimp.find_type(:size_t).size).read_string(length)
47
+ end
48
+
49
+ def data=(str)
50
+ sz = str.bytesize
51
+ raise "String too long #{sz} > #{MAXLEN-1}!" if sz > MAXLEN-1
52
+ self[:length] = sz
53
+ (pointer + Assimp.find_type(:size_t).size).write_string(str+"\x00")
54
+ end
55
+
56
+ def to_s
57
+ data
58
+ end
59
+
60
+ end
61
+
62
+ Return = enum( :return, [ :SUCCESS, :FAILURE, -1, :OUTOFMEMORY, -3 ] )
63
+
64
+ Origin = enum( :origin, [ :SET, :CUR, :END ] )
65
+
66
+ DefaultLogStream = bitmask( :default_log_stream, [
67
+ :FILE,
68
+ :STDOUT,
69
+ :STDERR,
70
+ :DEBUGGER
71
+ ])
72
+
73
+ class MemoryInfo < FFI::Struct
74
+ extend StructAccessors
75
+ layout :textures, :uint,
76
+ :materials, :uint,
77
+ :meshes, :uint,
78
+ :nodes, :uint,
79
+ :animations, :uint,
80
+ :cameras, :uint,
81
+ :lights, :uint,
82
+ :total, :uint
83
+ struct_attr_reader :textures,
84
+ :materials,
85
+ :meshes,
86
+ :nodes,
87
+ :animations,
88
+ :cameras,
89
+ :lights,
90
+ :total
91
+ end
92
+
93
+ end
@@ -0,0 +1,14 @@
1
+ module Assimp
2
+
3
+ class Vector2D < FFI::Struct
4
+ extend StructAccessors
5
+ layout :x, :ai_real,
6
+ :y, :ai_real
7
+ struct_attr_accessor :x, :y
8
+
9
+ def to_s
10
+ "<#{x}, #{y}>"
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,99 @@
1
+ module Assimp
2
+
3
+ class Vector3D < FFI::Struct
4
+ extend StructAccessors
5
+ layout :x, :ai_real,
6
+ :y, :ai_real,
7
+ :z, :ai_real
8
+
9
+ struct_attr_accessor :x, :y, :z
10
+
11
+ def to_s
12
+ "<#{x}, #{y}, #{z}>"
13
+ end
14
+
15
+ def square_length
16
+ x*x + y*y + z*z
17
+ end
18
+
19
+ def length
20
+ Math::sqrt(square_length)
21
+ end
22
+
23
+ def set( x, y, z )
24
+ self[:x] = x
25
+ self[:y] = y
26
+ self[:z] = z
27
+ self
28
+ end
29
+
30
+ def -@
31
+ v = Vector3D::new
32
+ v.set(-x, -y, -z)
33
+ end
34
+
35
+ def +(other)
36
+ v = Vector3D::new
37
+ v.set(x + other.x,
38
+ y + other.y,
39
+ z + other.z)
40
+ end
41
+
42
+ def -(other)
43
+ v = Vector3D::new
44
+ v.set(x - other.x,
45
+ y - other.y,
46
+ z - other.z)
47
+ end
48
+
49
+ def *(other)
50
+ v = Vector3D::new
51
+ if other.kind_of? Vector3D
52
+ v.set(x * other.x,
53
+ y * other.y,
54
+ z * other.z)
55
+ else
56
+ v.set(x * other,
57
+ y * other,
58
+ z * other)
59
+ end
60
+ end
61
+
62
+ def ^(other)
63
+ v = Vector3D::new
64
+ v.set(y*other.z - z*other.y,
65
+ z*other.x - x*other.z,
66
+ x*other.y - y*other.x)
67
+ end
68
+
69
+ def /(other)
70
+ v = Vector3D::new
71
+ if other.kind_of? Vector3D
72
+ v.set(x / other.x,
73
+ y / other.y,
74
+ z / other.z)
75
+ else
76
+ v.set(x / other,
77
+ y / other,
78
+ z / other)
79
+ end
80
+ end
81
+
82
+ def normalize!
83
+ l = length
84
+ if l > 0.0
85
+ self.x /= l
86
+ self.y /= l
87
+ self.z /= l
88
+ end
89
+ self
90
+ end
91
+
92
+ def normalize
93
+ v = self.dup
94
+ v.normalize!
95
+ end
96
+
97
+ end
98
+
99
+ end
@@ -0,0 +1,52 @@
1
+ module Assimp
2
+ attach_function :aiGetLegalString, [], :string
3
+ attach_function :aiGetVersionMinor, [], :uint
4
+ attach_function :aiGetVersionMajor, [], :uint
5
+ attach_function :aiGetVersionRevision, [], :uint
6
+
7
+ class Version
8
+ include Comparable
9
+ attr_reader :major, :minor, :revision
10
+
11
+ def initialize(major, minor, revision)
12
+ @major = major
13
+ @minor = minor
14
+ @revision = revision
15
+ end
16
+
17
+ def <=>(other)
18
+ res = (major <=> other.major)
19
+ res = (minor <=> other.minor) if res == 0
20
+ res = (revision <=> other.revision) if res == 0
21
+ res
22
+ end
23
+
24
+ def to_s
25
+ "#{major}.#{minor}.#{revision}"
26
+ end
27
+
28
+ end
29
+
30
+ def self.version
31
+ Version::new Assimp::aiGetVersionMajor, Assimp::aiGetVersionMinor, Assimp::aiGetVersionRevision
32
+ end
33
+
34
+ def self.legal_string
35
+ Assimp::aiGetLegalString
36
+ end
37
+
38
+ CFlags = bitmask(:cflags, [
39
+ :SHARED,
40
+ :STLPORT,
41
+ :DEBUG,
42
+ :NOBOOST,
43
+ :SINGLETHREADED
44
+ ])
45
+
46
+ attach_function :aiGetCompileFlags, [], :cflags
47
+
48
+ def self.compile_flags
49
+ Assimp::aiGetCompileFlags
50
+ end
51
+
52
+ end
data/lib/assimp-ffi.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'ffi'
2
+ require_relative 'assimp/base.rb'
3
+ require_relative 'assimp/config.rb'
4
+ require_relative 'assimp/defs.rb'
5
+ require_relative 'assimp/version.rb'
6
+ require_relative 'assimp/vector2.rb'
7
+ require_relative 'assimp/vector3.rb'
8
+ require_relative 'assimp/color4.rb'
9
+ require_relative 'assimp/matrix3x3.rb'
10
+ require_relative 'assimp/matrix4x4.rb'
11
+ require_relative 'assimp/quaternion.rb'
12
+ require_relative 'assimp/types.rb'
13
+ require_relative 'assimp/camera.rb'
14
+ require_relative 'assimp/anim.rb'
15
+ require_relative 'assimp/fileio.rb'
16
+ require_relative 'assimp/light.rb'
17
+ require_relative 'assimp/texture.rb'
18
+ require_relative 'assimp/material.rb'
19
+ require_relative 'assimp/mesh.rb'
20
+ require_relative 'assimp/metadata.rb'
21
+ require_relative 'assimp/scene.rb'
22
+ require_relative 'assimp/importerdesc.rb'
23
+ require_relative 'assimp/postprocess.rb'
24
+ require_relative 'assimp/import.rb'
25
+ require_relative 'assimp/export.rb'
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: assimp-ffi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brice Videau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.9.19
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.9'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.9.19
33
+ description: FFI bindings of Assimp (Open Asset Import Library bindings) for version
34
+ 4.1.0 onward
35
+ email: brice.videau@imag.fr
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - LICENSE
41
+ - README.md
42
+ - assimp.gemspec
43
+ - lib/assimp-ffi.rb
44
+ - lib/assimp/anim.rb
45
+ - lib/assimp/base.rb
46
+ - lib/assimp/camera.rb
47
+ - lib/assimp/color4.rb
48
+ - lib/assimp/config.rb
49
+ - lib/assimp/defs.rb
50
+ - lib/assimp/export.rb
51
+ - lib/assimp/fileio.rb
52
+ - lib/assimp/import.rb
53
+ - lib/assimp/importerdesc.rb
54
+ - lib/assimp/light.rb
55
+ - lib/assimp/material.rb
56
+ - lib/assimp/matrix3x3.rb
57
+ - lib/assimp/matrix4x4.rb
58
+ - lib/assimp/mesh.rb
59
+ - lib/assimp/metadata.rb
60
+ - lib/assimp/postprocess.rb
61
+ - lib/assimp/quaternion.rb
62
+ - lib/assimp/scene.rb
63
+ - lib/assimp/texture.rb
64
+ - lib/assimp/types.rb
65
+ - lib/assimp/vector2.rb
66
+ - lib/assimp/vector3.rb
67
+ - lib/assimp/version.rb
68
+ homepage: https://github.com/Kerilk/assimp-ruby
69
+ licenses:
70
+ - BSD-2-Clause
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.1.0
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.7.6
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Open Asset Import Library bindings
92
+ test_files: []