Changeset 728 for trunk/RBRapier/RBRapier/Tools/Animation
- Timestamp:
- 10/23/03 11:46:44 (5 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBRapier/RBRapier/Tools/Animation/Navigation.py
r703 r728 44 44 projection = None 45 45 animate = False 46 drawAnimation = False 46 47 47 bgcolor = (1., .7,.7)48 fgcolor = (1., .7,.7)48 bgcolor = (1.,1.,1.,.2) 49 fgcolor = (1.,1.,1.,.8) 49 50 50 51 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 69 70 self.modelview.GLSelect(context) 70 71 72 def GLDeselect(self, context): 73 self.modelview.GLDeselect(context) 74 self.projection.GLDeselect(context) 75 71 76 def GLExecute(self, context): 72 vb = self.viewboxes.get('animate') 73 if vb is not None: 74 vb, alpha = vb.viewbox1, .2*(1.-vb.GetBlend()) 75 else: 76 vb, alpha = self.viewboxes.get('draw'), 0.2 77 vb = None 78 if not vb and self.drawAnimation: 79 vbAnimation = self.viewboxes.get('animate') 80 if vbAnimation: 81 vb = vbAnimation.viewbox1 82 alpha = (1.-vbAnimation.GetBlend()) 83 if not vb: 84 vb = self.GetViewBox('draw') 85 alpha = 1. 77 86 78 87 if vb is not None: … … 84 93 self._DrawViewBox(vb) 85 94 86 def GLDeselect(self, context): 87 self.modelview.GLDeselect(context) 88 self.projection.GLDeselect(context) 89 90 def _DrawViewBox(self, drawVB, bgalpha=0.2): 95 def _DrawViewBox(self, drawVB, bgAlpha=1., fgAlpha=1.): 91 96 if self.useblending: 92 GL.glColor4fv(self.bgcolor+(bgalpha,)) 97 r,g,b,a = self.bgcolor 98 GL.glColor4f(r,g,b,a*bgAlpha) 93 99 drawVB.Draw(GL.GL_TRIANGLE_FAN) 94 100 95 GL.glColor4fv(self.fgcolor+(0.8,)) 101 r,g,b,a = self.fgcolor 102 GL.glColor4f(r,g,b,a*fgAlpha) 96 103 drawVB.Draw() 97 104 … … 116 123 self.viewboxes['displayed'] = viewbox 117 124 125 def AnimateToViewBox(self, viewbox, animationspan=0.5, key=None, drawAnimation=True): 126 viewbox0 = self.GetViewBox().copy() 127 self.viewboxes['animate'] = ViewBox.BlendedViewBox(viewbox0, viewbox) 128 self.SetViewBox(self.viewboxes['animate'], key) 129 self.animation = Animation.TimeBlend.fromSpan(animationspan) 130 self.drawAnimation = drawAnimation 131 118 132 def GetViewBox(self, which=None): 119 133 return self.viewboxes.get(which) … … 123 137 except KeyError: 124 138 return self.viewboxes[None] 125 126 def AnimateToViewBox(self, viewbox, animationspan=0.5, key=None):127 viewbox0 = self.GetViewBox().copy()128 self.viewboxes['animate'] = ViewBox.BlendedViewBox(viewbox0, viewbox)129 self.SetViewBox(self.viewboxes['animate'], key)130 self.animation = Animation.TimeBlend.fromSpan(animationspan)131 132 139 def SetViewBox(self, viewbox, key=None): 133 140 if 'draw' in self.viewboxes: 134 141 del self.viewboxes['draw'] 135 self.viewboxes[key] = viewbox 142 if viewbox is None: 143 try: del self.viewboxes[key] 144 except KeyError: pass 145 else: 146 self.viewboxes[key] = viewbox 136 147 137 148
