-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging all the changes and fixes into the master branch (#2)
2.0.0 Added support for the camera export Changed the mesh accumulation, export and relevant buffer view generation mechanism to be performed on a per mesh per material basis. This cuts down the export times by a factor of 2x and drastically improves the speed and memory consumption when exported files are imported via Assimp. Added optional support for multiple buffer generation in exported files (if needed) Currently mesh vertices are exported without welding for performance reasons (additional ~30% speed improvement) at the expense of bigger exported file sizes (this could be changed to hash based welding; see the code in MeshData class) Overall re-factoring to clean up and remove redundant code Various small performance optimizations and hardening Added some missing internationalization resource strings 2.1.0 Added ImageMagick app to convert images to .png Passed FOV to gltf from SU 2.2.0 Fixed RGBA blending not being supported when a texture was specified for a material A fix to suppress duplicate geometry in CET exported scenes
- Loading branch information
1 parent
707d720
commit bc120a5
Showing
40 changed files
with
2,298 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#----------------------------------------------------------------------------------- | ||
# MIT License | ||
# | ||
# Copyright (c) 2019 Yulio Technologies Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
#----------------------------------------------------------------------------------- | ||
|
||
require 'base64' | ||
module Yulio | ||
module GltfExporter | ||
class GltfBuffers | ||
def initialize() | ||
#@buffers = {} # Can use hash indexed buffers in you want to initialize & use them out of order, but no real need for that | ||
@buffers = [] | ||
end | ||
|
||
def add_or_append_buffer(index, bytes, alignment) | ||
|
||
# if (@buffers[index] == nil) | ||
# puts 'Creating a new buffer with index ' + index.to_s | ||
# buffer = '' | ||
# @buffers[index] = buffer | ||
# else | ||
# puts 'Using the existing buffer with index ' + index.to_s | ||
# buffer = @buffers[index] | ||
# end | ||
|
||
if (index < @buffers.length) | ||
#puts 'Using the existing buffer with index ' + index.to_s | ||
buffer = @buffers[index] | ||
else | ||
#puts 'Creating a new buffer with index ' + @buffers.length.to_s | ||
buffer = '' | ||
@buffers.push(buffer) | ||
end | ||
|
||
while buffer.length % alignment != 0 | ||
#puts 'Padding the buffer' | ||
buffer = buffer << 0 | ||
end | ||
|
||
offset = buffer.length | ||
|
||
#puts 'Adding ' + bytes.length.to_s + ' bytes to buffer at offset ' + offset.to_s + ' with alignment of ' + alignment.to_s | ||
|
||
buffer << bytes | ||
return offset | ||
end | ||
|
||
def get_buffers | ||
buffers = [] | ||
@buffers.each do |item| | ||
buf = | ||
{ | ||
"byteLength" => item.length | ||
} | ||
buffers.push(buf) | ||
end | ||
return buffers, @buffers | ||
end | ||
|
||
def encode_buffers() | ||
buffers = [] | ||
@buffers.each do |item| | ||
buf = | ||
{ | ||
"uri" => "data:application/octet-stream;base64," + Base64.strict_encode64(item), | ||
"byteLength" => item.length | ||
} | ||
buffers.push(buf) | ||
end | ||
return buffers | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#----------------------------------------------------------------------------------- | ||
# MIT License | ||
# | ||
# Copyright (c) 2019 Yulio Technologies Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
#----------------------------------------------------------------------------------- | ||
Sketchup.require "yulio_gltf_export/gltf_id" | ||
|
||
module Yulio | ||
module GltfExporter | ||
class GltfCameras | ||
def initialize(nodes) | ||
@nodes = nodes | ||
@cameras = [] | ||
@id_gen = GltfId.new | ||
end | ||
|
||
attr_reader :cameras | ||
|
||
def add_camera_type(name,fov) | ||
camera={ | ||
"perspective"=> | ||
{ | ||
"yfov"=>fov, | ||
"zfar"=>25.399999618530278, | ||
"znear"=>0.02539999969303608, | ||
"aspectRatio"=>1.5 | ||
}, | ||
"type"=>"perspective", | ||
"name"=>name | ||
} | ||
index=@cameras.length | ||
@cameras.push(camera) | ||
return index | ||
|
||
end | ||
|
||
def create_camera_matrix(camera) | ||
originM=Geom::Point3d.new(camera.eye.x.to_m,camera.eye.y.to_m,camera.eye.z.to_m) | ||
matrix=Geom::Transformation.axes(originM,camera.xaxis,camera.yaxis,camera.zaxis.reverse) | ||
#temp=[1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0] | ||
#tran=Geom::Transformation.new(temp) | ||
#matrix=tran*matrix | ||
return matrix.to_a | ||
end | ||
|
||
def add_camera_nodes | ||
pages = Sketchup.active_model.pages | ||
if (pages.length == 0) | ||
return | ||
end | ||
|
||
group_node_id = create_camera_group | ||
|
||
pages.each do |page| | ||
name = page.label | ||
camera = page.camera | ||
matrix = create_camera_matrix(camera) | ||
camera_id = add_camera_type(name + "_camera",camera.fov.degrees) | ||
node_id = @nodes.add_node(name, matrix, true) | ||
@nodes.add_camera(node_id, camera_id) | ||
@nodes.add_child(group_node_id, node_id) | ||
end | ||
end | ||
|
||
def create_camera_group | ||
matrix = [ | ||
1.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
-1.0, | ||
0.0, | ||
0.0, | ||
1.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
1.0 | ||
] | ||
|
||
node_id = @nodes.add_node("Camera Group", matrix, true) | ||
@nodes.add_child(0, node_id) | ||
|
||
return node_id | ||
end | ||
|
||
end | ||
end | ||
|
||
end |
Oops, something went wrong.