-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAddToColladaVisualScene.m
57 lines (44 loc) · 2.23 KB
/
AddToColladaVisualScene.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
function [ DOM ] = AddToColladaVisualScene( DOM, Name, MaterialName, Translation )
%ADDTOCOLLADAVISUALSCENE Summary of this function goes here
% Detailed explanation goes here
DOMNode = DOM.getDocumentElement;
VisLibList = DOMNode.getElementsByTagName('library_visual_scenes');
if(isempty(VisLibList.item(0)))
VisSceneLibNode = DOM.createElement('library_visual_scenes');
VisSceneNode = DOM.createElement('visual_scene');
VisSceneNode.setAttribute('id','VisualSceneNode');
VisSceneNode.setAttribute('name','untitled');
VisSceneLibNode.appendChild( VisSceneNode);
DOMNode.appendChild( VisSceneLibNode);
% xmlwrite('debugcreate.xml', DOM);
else
% xmlwrite('debug.xml', DOM);
VisSceneLibNode = VisLibList.item(0);
if(isempty(VisLibList.item(0).getFirstChild))
VisSceneNode = DOM.createElement('visual_scene');
VisSceneNode.setAttribute('id','VisualSceneNode');
VisSceneNode.setAttribute('name','untitled');
VisSceneLibNode.appendChild( VisSceneNode);
else
VisSceneNode = VisLibList.item(0).getFirstChild;
end
end
Node = DOM.createElement('node');
Node.setAttribute('id',Name);
Node.setAttribute('name',Name);
TranslateNode = DOM.createElement('translate');
TranslateNode.setAttribute('sid', 'translate');
TranslateNode.appendChild(DOM.createTextElement(num2str(Translation, '%g ')));
InstanceGeometryNode = DOM.createElement('instance_geometry');
InstanceGeometryNode.setAttribute('url', ['#' Name '-geometry']);
BindMaterialNode = DOM.createElement('bind_material');
TechniqueCommonNode = DOM.createElement('technique_common');
InstanceMaterialNode = DOM.createElement('instance_material');
InstanceMaterialNode.setAttribute('symbol', [MaterialName 'SG']);
InstanceMaterialNode.setAttribute('target', ['#' MaterialName]);
TechniqueCommonNode.appendChild(InstanceMaterialNode);
BindMaterialNode.appendChild(TechniqueCommonNode);
InstanceGeometryNode.appendChild(BindMaterialNode);
Node.appendChild(InstanceGeometryNode);
VisSceneNode.appendChild(Node);
end