Class: Assimp::AnimMesh
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Assimp::AnimMesh
show all
- Extended by:
- StructAccessors
- Defined in:
- lib/assimp/mesh.rb
Instance Method Summary
collapse
extended, has_ref?, struct_array_attr_accessor, struct_array_attr_checker, struct_array_attr_reader, struct_array_attr_writer, struct_attr_accessor, struct_attr_reader, struct_attr_writer, struct_ref_array_attr_accessor, struct_ref_array_attr_reader, struct_ref_array_attr_writer
Instance Method Details
#colors ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/assimp/mesh.rb', line 103
def colors
cs = self[:colors].to_a
cs.collect { |c_ptr|
if c_ptr.null?
nil
else
s = Color4D.size
num_vertices.times.collect { |i|
Color4D::new(c_ptr+i*s)
}
end
}
end
|
#set_colors(index, colors) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/assimp/mesh.rb', line 117
def set_colors(index, colors)
@colors = [nil]*MAX_NUMBER_OF_COLOR_SETS unless @colors
raise "Invalid colors index #{index}!" if index < 0 || index >= MAX_NUMBER_OF_COLOR_SETS
unless colors && colors.length > 0
@colors[index] = nil
return self
end
raise "Invalid colors count: #{colors.length}!" if num_vertices != colors.length
ptr = FFI::MemoryPointer::new(Assimp::Color4D, num_vertices)
s = Assimp::Color4D.size
colors.each_with_index { |v, i|
ptr.put_array_of_uint8(i*s, v.pointer.read_array_of_uint8(s))
}
@colors[index] = ptr
self
end
|
#set_texture_coords(index, uvs) ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/assimp/mesh.rb', line 148
def set_texture_coords(index, uvs)
@texture_coords = [nil]*MAX_NUMBER_OF_TEXTURECOORDS unless @texture_coords
raise "Invalid texture_coords index #{index}!" if index < 0 || index >= MAX_NUMBER_OF_TEXTURECOORDS
unless uvs && uvs.length > 0
@texture_coords[index] = nil
return self
end
raise "Invalid texture_coords count: #{uvs.length}!" if num_vertices != uvs.length
ptr = FFI::MemoryPointer::new(Assimp::Vector3D, num_vertices)
s = Assimp::Vector3D.size
uvs.each_with_index { |v, i|
ptr.put_array_of_uint8(i*s, v.pointer.read_array_of_uint8(s))
}
@texture_coords[index] = ptr
self
end
|
#texture_coords ⇒ Object
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/assimp/mesh.rb', line 134
def texture_coords
tcs = self[:texture_coords].to_a
tcs.collect { |tc_ptr|
if tc_ptr.null?
nil
else
s = Vector3D.size
num_vertices.times.collect { |i|
Vector3D::new(tc_ptr+i*s)
}
end
}
end
|