File: point_shadowmaps.javascript

package info (click to toggle)
k3d 0.4.3.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 51,716 kB
  • ctags: 81,610
  • sloc: cpp: 283,698; ansic: 64,095; xml: 61,533; sh: 9,026; makefile: 5,282; python: 431; perl: 308; awk: 130
file content (76 lines) | stat: -rw-r--r-- 2,275 bytes parent folder | download
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
70
71
72
73
74
75
76
//javascript

/// Boilerplate to determine which document to modify ...
function FindDocument(ScriptName)
{
	if(Document)
			return Document;
	else
			{
					if(Application.documents.length == 1)
							return Application.documents[0];
					else if(Application.documents.length == 0)
							Application.ui.ErrorMessage("You must have an open document to run this script!", ScriptName + ":");
					else
							Application.ui.ErrorMessage("Not sure which document to use ... try using the desired document's Document Window > Tools > Play Script.", ScriptName + ":");
			}
			
	return null;
}

function CreateShadowMap(Document, Name)
{
	var shadow_map = Document.CreateObject("ShadowMap");
	shadow_map.name = Name;

	return shadow_map;
}

var gtkml =
	'<gtkml>' +
		'<window type="toplevel" title="point_shadowmaps">' +
			'<vbox homogeneous="false">' +
				'<hbox homogeneous="false" expand="true">' +
					'<label labelpadding="4">Enter root name for Shadow Maps:</label>' + 
					'<entry name="name">Shadow Map</entry>' +
				'</hbox>' + 
				'<hbuttonbox layout="end">' +
					'<button>OK' + 
						'<event signal="clicked" name="ok"/>' + 
					'</button>' +
					'<button>Cancel' +
						'<event signal="clicked" name="cancel"/>' +
					'</button>' +
				'</hbuttonbox>' +
			'</vbox>' +
		'</window>' +
	'</gtkml>';

document = FindDocument("point_shadowmaps");
if(document)
	{
		dialog = new GTKMLContainer(gtkml);
		if(dialog.DoModal())
			{
				// Record undo/redo data ...
				document.StartChangeSet();

				var root_name = dialog.Field("name");
				var front = CreateShadowMap(document, root_name + " Front");
				var back = CreateShadowMap(document, root_name + " Back");
				var left = CreateShadowMap(document, root_name + " Left");
				var right = CreateShadowMap(document, root_name + " Right");
				var top = CreateShadowMap(document, root_name + " Top");
				var bottom = CreateShadowMap(document, root_name + " Bottom");

				// Finish recording undo/redo data (no need to record the rest of our changes) ...
				document.FinishChangeSet("Create point shadowmaps");

				back.orientation = [0, 180, 0];
				left.orientation = [0, 90, 0];
				right.orientation = [0, -90, 0];
				top.orientation = [90, 0, 0];
				bottom.orientation = [-90, 0, 0];
			}
	}