Skip to content

Commit

Permalink
0.8.8
Browse files Browse the repository at this point in the history
0.8.6: COLLADA writing fix (inputs count)
0.8.7: Writer and Reader interfaces, fields encapsulating
0.8.8: Added "Universal" format instead of python dicts, some fixes, a lot of refactoring
danila-schelkov committed May 3, 2022
1 parent 9706b9b commit d588b18
Showing 45 changed files with 1,884 additions and 1,685 deletions.
2 changes: 1 addition & 1 deletion .idea/3d-converter.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions models_converter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
__all__ = [
'formats',
'chunks',
'utils'
'utilities'
]
4 changes: 2 additions & 2 deletions models_converter/formats/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__all__ = [
'scw',
'dae',
'obj',
'collada',
'wavefront',
'gltf'
]
7 changes: 7 additions & 0 deletions models_converter/formats/collada/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .writer import Writer
from .parser import Parser

__all__ = [
'Writer',
'Parser'
]
51 changes: 51 additions & 0 deletions models_converter/formats/collada/collada.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from xml.etree.ElementTree import *


VERSION = '1.4.1'
NAMESPACE = 'http://www.collada.org/2005/11/COLLADASchema'


class Collada:
def __init__(self):
self.root = Element('COLLADA', version=VERSION, xmlns=NAMESPACE)

@staticmethod
def write_source(parent,
source_id: str,
array_tag: str,
array_data: tuple,
stride: int,
params: list):
source = SubElement(parent, 'source', id=source_id)

array = SubElement(source, array_tag)
array.attrib = {'id': f'{source_id}-array',
'count': f'{len(array_data) * stride}'}

technique_common = SubElement(source, 'technique_common')
accessor = SubElement(technique_common, 'accessor')
accessor.attrib = {'source': f'#{source_id}-array',
'count': f'{len(array_data)}',
'stride': f'{stride}'}

for param_data in params:
param = SubElement(accessor, 'param')
param.attrib = param_data

array.text = ' '.join(array_data)

@staticmethod
def write_input(parent,
semantic: str,
source_id: str,
offset: int = None):
attributes = {
'semantic': semantic,
'source': f'#{source_id}'
}

if offset is not None:
attributes['offset'] = f'{offset}'

_input = SubElement(parent, 'input')
_input.attrib = attributes
Loading

0 comments on commit d588b18

Please sign in to comment.