forked from jamesra/VikingPlot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddColladaNode.m
70 lines (57 loc) · 2.66 KB
/
AddColladaNode.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [DOM, ParentNode, Node] = AddColladaNode( DOM, ...
ParentNode, ...
StructID, ...
GeometryTarget, ...
MaterialSymbol, ...
MaterialTarget, ...
WorldPosition, ...
Translate, ...
Scale)
%ADDCOLLADANODE Summary of this function goes here
% Detailed explanation goes here
% if(isempty(GeometryURL))
% GeometryURL = ['#' Name '-geometry'];
% end
%
% if(isempty(MaterialURL))
% MaterialURL = ['#' MaterialName];
% end
WorldNode = [];
Node = DOM.createElement('node');
Node.setAttribute('id', ['NodeID-' StructID]);
Node.setAttribute('name',['NodeID-' StructID]);
if(~isempty(Translate))
TranslateNode = DOM.createElement('translate');
TranslateNode.setAttribute('sid', 'translate');
TranslateNode.appendChild(DOM.createTextNode(num2str(Translate, '%g ')));
Node.appendChild(TranslateNode);
end
if(~isempty(Scale))
ScaleNode = DOM.createElement('scale');
ScaleNode.setAttribute('sid', 'scale');
ScaleNode.appendChild(DOM.createTextNode(num2str(Scale, '%g ')));
Node.appendChild(ScaleNode);
end
if(~isempty(WorldPosition))
WorldNode = DOM.createElement('extra');
%WorldNode.setAttribute('id', 'world_position']);
WorldNode.setAttribute('name', 'world_position');
WorldNode.setAttribute('type', 'float3');
WorldNode.appendChild(DOM.createTextNode(num2str(WorldPosition, '%g ')));
end
InstanceGeometryNode = DOM.createElement('instance_geometry');
InstanceGeometryNode.setAttribute('url', GeometryTarget);
BindMaterialNode = DOM.createElement('bind_material');
TechniqueCommonNode = DOM.createElement('technique_common');
InstanceMaterialNode = DOM.createElement('instance_material');
InstanceMaterialNode.setAttribute('symbol', MaterialSymbol);
InstanceMaterialNode.setAttribute('target', MaterialTarget);
TechniqueCommonNode.appendChild(InstanceMaterialNode);
BindMaterialNode.appendChild(TechniqueCommonNode);
InstanceGeometryNode.appendChild(BindMaterialNode);
Node.appendChild(InstanceGeometryNode);
if(~isempty(WorldNode))
% Node.appendChild(WorldNode);
end
ParentNode.appendChild(Node);
end