20 |
# |
# |
21 |
# |
# |
22 |
|
|
|
|
|
23 |
from __future__ import nested_scopes |
from __future__ import nested_scopes |
24 |
import jarray |
import jarray |
25 |
|
|
32 |
vob.AbstractUpdateManager.defaultAnimationTime = 1500 |
vob.AbstractUpdateManager.defaultAnimationTime = 1500 |
33 |
vob.AbstractUpdateManager.fractCalc = vob.AbstractUpdateManager.LinearCalculator(0) |
vob.AbstractUpdateManager.fractCalc = vob.AbstractUpdateManager.LinearCalculator(0) |
34 |
|
|
|
|
|
|
print "LOADING BUOYMANAGER" |
|
|
|
|
35 |
lineconn = GLRen.createLineConnector(.5, .5, .5, .5) |
lineconn = GLRen.createLineConnector(.5, .5, .5, .5) |
36 |
#lineconn = GLRen.createSqFilletConnection(30, 1, .125, 6) |
#lineconn = GLRen.createSqFilletConnection(30, 1, .125, 6) |
37 |
|
|
38 |
size = jarray.zeros(2, 'f') |
size = jarray.zeros(2, 'f') |
39 |
|
|
40 |
|
dbg = 0 |
41 |
|
def pa(*s): |
42 |
|
print 'vob.buoy.buoymanager::',s |
43 |
|
|
44 |
|
|
45 |
|
pa("LOADING BUOYMANAGER") |
46 |
class RealBuoyManager(BuoyLinkListener): |
class RealBuoyManager(BuoyLinkListener): |
47 |
"""Manage buoys through the new APIs |
"""Manage buoys through the new APIs |
48 |
|
|
110 |
def link(self, *args): |
def link(self, *args): |
111 |
self.links.append(args) |
self.links.append(args) |
112 |
def linkReally(self, direction, anchorCS, otherNode, linkId, otherAnchor): |
def linkReally(self, direction, anchorCS, otherNode, linkId, otherAnchor): |
113 |
|
if dbg: pa('link really') |
114 |
|
|
115 |
anchorUnit = self.vs.unitSqCS(anchorCS, "UN") |
anchorUnit = self.vs.unitSqCS(anchorCS, "UN") |
116 |
anchorCenter = self.vs.translateCS(anchorUnit, "TR55", .5, .5) |
anchorCenter = self.vs.translateCS(anchorUnit, "TR55", .5, .5) |
117 |
x = self.ctrx |
x = self.ctrx |
118 |
r = self.ctry * 1.05 |
r = self.ctry * 1.05 |
119 |
print "Buoy: ",self.ctrx, self.ctry, x, r |
if dbg: pa("Buoy: ",self.ctrx, self.ctry, x, r) |
120 |
if direction > 0: |
if direction > 0: |
121 |
buoy = self.vs.coords.buoyOnCircle1(0, anchorCenter, |
buoy = self.vs.coords.buoyOnCircle1(0, anchorCenter, |
122 |
x, self.ctry, r, |
x, self.ctry, r, |
128 |
x+r, self.ctry, |
x+r, self.ctry, |
129 |
.1) |
.1) |
130 |
self.vs.matcher.add(buoy, linkId) |
self.vs.matcher.add(buoy, linkId) |
131 |
print otherNode |
if dbg: pa(otherNode) |
132 |
obj = otherNode.getSize(linkId, otherAnchor, size) |
obj = otherNode.getSize(linkId, otherAnchor, size) |
133 |
w = size[0] |
w = size[0] |
134 |
h = size[1] |
h = size[1] |
142 |
|
|
143 |
|
|
144 |
sca = 1.5 |
sca = 1.5 |
145 |
print "BuoyScaling: ",w, h, sca |
if dbg: pa("BuoyScaling: ",w, h, sca) |
146 |
into = self.vs.orthoBoxCS(buoy, "V"+str(linkId), -100, -w*sca/2.0, -h*sca/2.0, |
into = self.vs.orthoBoxCS(buoy, "V"+str(linkId), -100, -w*sca/2.0, -h*sca/2.0, |
147 |
1, 1, w*sca, h*sca) |
1, 1, w*sca, h*sca) |
148 |
|
|
154 |
self.vs.activate(into) |
self.vs.activate(into) |
155 |
otherAnchorCS = otherNode.renderBuoy(self.vs, into, linkId, otherAnchor, None) |
otherAnchorCS = otherNode.renderBuoy(self.vs, into, linkId, otherAnchor, None) |
156 |
self.cs[into] = (otherNode, linkId, otherAnchor, into) |
self.cs[into] = (otherNode, linkId, otherAnchor, into) |
157 |
|
|
158 |
self.vs.map.put(GLCache.getCallList(""" |
self.vs.map.put(GLCache.getCallList(""" |
159 |
PushAttrib ENABLE_BIT LINE_BIT |
PushAttrib ENABLE_BIT LINE_BIT |
160 |
Disable TEXTURE_2D |
Disable TEXTURE_2D |
164 |
""")) |
""")) |
165 |
|
|
166 |
self.vs.map.put(lineconn, anchorUnit, |
self.vs.map.put(lineconn, anchorUnit, |
167 |
self.vs.unitSqCS(otherAnchorCS, "UN")) |
self.vs.unitSqCS(otherAnchorCS, "UN")) |
|
|
|
|
# vs.map.put(filletconn, main_whole_cs, link_whole_cs) |
|
168 |
|
|
169 |
self.vs.map.put(GLCache.getCallList(""" |
self.vs.map.put(GLCache.getCallList(""" |
170 |
PopAttrib |
PopAttrib |
176 |
linkId == self.animationCS_main[1][1]: |
linkId == self.animationCS_main[1][1]: |
177 |
self.vs.matcher.keymapSingleCoordsys(into,self.animationCS_main[0]) |
self.vs.matcher.keymapSingleCoordsys(into,self.animationCS_main[0]) |
178 |
self.animationCS_main = None |
self.animationCS_main = None |
179 |
|
if dbg: pa('link really..DONE') |
180 |
|
|
181 |
def key(self, key): |
def key(self, key): |
182 |
if key == "Print": |
if key == "Print": |
212 |
self.animationCS_main = [self.mainCS, link, self.vs] |
self.animationCS_main = [self.mainCS, link, self.vs] |
213 |
|
|
214 |
|
|
215 |
print "Following link", link |
pa( "Following link", link) |
216 |
|
|
217 |
self.mainNode = link[0].createMainNode(link[1], link[2]) |
self.mainNode = link[0].createMainNode(link[1], link[2]) |
218 |
|
|
219 |
def followLinkByAnchor(self, anchor): |
def followLinkByAnchor(self, anchor): |
220 |
print "Searching for anchor", anchor |
pa("Searching for anchor", anchor) |
221 |
for key in self.cs.keys(): |
for key in self.cs.keys(): |
222 |
print "Comparing to", self.cs[key] |
pa("Comparing to", self.cs[key]) |
223 |
if self.cs[key] != None: |
if self.cs[key] != None: |
224 |
a = self.cs[key][2] |
a = self.cs[key][2] |
225 |
if a == anchor: |
if a == anchor: |
226 |
self.followLink(self.cs[key]) |
self.followLink(self.cs[key]) |
227 |
return |
return |
228 |
|
|
229 |
print "Anchor not found!!!" |
pa("Anchor not found!!!") |
230 |
|
|
231 |
def getVs(self): |
def getVs(self): |
232 |
return self.vs; |
return self.vs; |