blob: 54561ffc1a62cacdc9e00eb2167989e102a105cd (
plain) (
blame)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
//-----------------------------------------------------------------------------
// Copyright (C) 2001 Radical Entertainment Ltd. All rights reserved.
//
// te_IntersectionContext.mel
//
// Description: Defines all the scripts required by the IntersectionContext tool
// As a convention all Terrain Editor global procedures
// and global variables are prefixed with "te_". All commands
// exposed through TE plugins are prefixed with "TE_".
//
// MCB = Menu Call Back
// BCB = Button Call Back
//
// Modification History:
// + Created -- CBrisebois
//-----------------------------------------------------------------------------
//This is the global instance of the bv context tool.
global proc te_MCB_StartIntersection()
{
//Start the Intersection context...
if ( ! `contextInfo -exists IntersectionCtx` )
{
IntersectionContext IntersectionCtx;
}
setToolTo IntersectionCtx;
}
global string $gSelectedIntersection = "";
global int $gIntersectionSelectionCallbackID = 0;
global string $gSelectedName;
global string $gTypeField;
global string $gIntersectionTypes[] = { "NoStop", "NWay", "FourWay", "NoStopN", "NWayN" };
global proc te_MCB_EditIntersection()
{
global string $gSelectedName;
global int $gIntersectionSelectionCallbackID;
global string $gIntersectionTypes[];
global string $gTypeField;
if ( `window -exists TE_InteresctionEditor` )
{
deleteUI -window TE_IntersectionEditor;
}
window -rtf true -title "TE Road / Intersection Editor" TE_IntersectionEditor;
columnLayout -adjustableColumn true;
$gSelectedName = `textField -editable false -text "" -width 170`;
$gTypeField = `optionMenu -label "Type" -width 170 -changeCommand ("te_MCB_IntersectionTypeChange( \"#1\" )")`;
int $index;
int $size = size($gIntersectionTypes);
for ( $index = 0; $index < $size; $index++ )
{
menuItem -label $gIntersectionTypes[ $index ];
}
setParent ..;
button -label "Create Road" -command ( "te_MCB_CreateRoadFromSelected()" );
button -label "Show Whole Road" -command ( "te_MCB_ShowRoadFromSelected()" );
button -label "Destroy Road" -command ( "te_MCB_DestroyRoadFromSelected()" );
button -label "Set Intersection Start" -command ( "te_MCB_AddSelectedIntersectionToRoad( 0 )" );
button -label "Set Intersection End" -command ( "te_MCB_AddSelectedIntersectionToRoad( 1 )" );
separator;
button -label "Create Intersections" -command "te_MCB_StartIntersection()";
setParent ..;
showWindow;
//Create the selection change callback.
$gIntersectionSelectionCallbackID = `scriptJob -parent "TE_IntersectionEditor" -event "SelectionChanged" "te_UpdateIntersectionEditor()"`;
}
global proc te_MCB_IntersectionTypeChange( string $value )
{
global string $gSelectedIntersection;
if ( $gSelectedIntersection != "" )
{
setAttr ( $gSelectedIntersection + ".IntersectionType" ) -type "string" $value;
}
}
global proc te_CloseIntersectionEditorWindow()
{
global int $gIntersectionSelectionCallbackID;
if ( `window -exists TE_InteresctionEditor` )
{
deleteUI -window TE_IntersectionEditor;
}
$gIntersectionSelectionCallbackID = 0;
}
global proc te_UpdateIntersectionEditor()
{
global string $gSelectedIntersection;
global string $gSelectedName;
global string $gTypeField;
global string $gIntersectionTypes[];
string $selectedObjects[] = `ls -sl -dag`;
string $selectedObjectName = $selectedObjects[0];
string $selectedNodeType;
if ( $selectedObjectName != "" )
{
//There is something selected
$selectedNodeType = `nodeType $selectedObjectName `;
if ( $selectedNodeType == "transform" )
{
//We don't want the transform, we want the child node.
string $children[] = `listRelatives -c $selectedObjectName`;
$selectedObjectName = $children[0];
}
if ( $selectedObjectName != "" )
{
$selectedNodeType = `nodeType $selectedObjectName `;
if ( $selectedNodeType == "IntersectionLocatorNode" )
{
//We're in business
textField -edit -text $selectedObjectName $gSelectedName;
string $value = `getAttr ( $selectedObjectName + ".IntersectionType" )`;
//Which index is this string?
int $size = size( $gIntersectionTypes );
int $index;
for ( $index = 0; $index < $size; $index++ )
{
if ( $gIntersectionTypes[ $index ] == $value )
{
optionMenu -edit -sl ($index + 1) $gTypeField;
break;
}
}
if ( $index == $size )
{
//This node had no proper setting. Resetting it.
warning "Node had invalid type setting. Correcting to default type";
optionMenu -edit -sl 1 $gTypeField;
setAttr ( $selectedObjectName + ".IntersectionType" ) -type "string" $gIntersectionTypes[ 0 ];
}
$gSelectedIntersection = $selectedObjectName;
return;
}
else if ( $selectedNodeType == "mesh" )
{
//This is for adding road to the selected intersection. Do not unselect the intersection.
string $whichRoad[] = `listAttr -st teWhichRoad $selectedObjectName`;
if ( size( $whichRoad ) )
{
return;
}
}
}
}
textField -edit -text "" $gSelectedName;
$gSelectedIntersection = "";
}
global proc te_MCB_CreateRoadFromSelected()
{
TE_CreateRoad();
}
global proc te_MCB_ShowRoadFromSelected()
{
TE_ShowRoad();
}
global proc te_MCB_DestroyRoadFromSelected()
{
TE_DestroyRoad();
}
global proc te_MCB_AddSelectedIntersectionToRoad( int $isEnd )
{
global string $gSelectedIntersection;
TE_AddIntersectionToRoad( $gSelectedIntersection, $isEnd );
}
global proc te_Delete_IntersectionContext()
{
if ( `contextInfo -exists IntersectionCtx` )
{
deleteUI -toolContext IntersectionCtx;
}
}
|