mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
Added scale1D
This commit is contained in:
parent
7f34552d93
commit
c79a08611f
@ -256,7 +256,12 @@ class DirectManipulationControl(DirectObject):
|
|||||||
if self.constraint:
|
if self.constraint:
|
||||||
type = self.constraint[2:]
|
type = self.constraint[2:]
|
||||||
if type == 'post' and not self.currEditTypes & EDIT_TYPE_UNMOVABLE:
|
if type == 'post' and not self.currEditTypes & EDIT_TYPE_UNMOVABLE:
|
||||||
self.xlate1D(state)
|
# [gjeon] to enable non-uniform scaling
|
||||||
|
if base.direct.fControl and not self.currEditTypes & EDIT_TYPE_UNSCALABLE:
|
||||||
|
self.fScaling = 1
|
||||||
|
self.scale1D(state)
|
||||||
|
else:
|
||||||
|
self.xlate1D(state)
|
||||||
elif type == 'disc' and not self.currEditTypes & EDIT_TYPE_UNMOVABLE:
|
elif type == 'disc' and not self.currEditTypes & EDIT_TYPE_UNMOVABLE:
|
||||||
self.xlate2D(state)
|
self.xlate2D(state)
|
||||||
elif type == 'ring' and not self.currEditTypes & EDIT_TYPE_UNROTATABLE:
|
elif type == 'ring' and not self.currEditTypes & EDIT_TYPE_UNROTATABLE:
|
||||||
@ -491,6 +496,31 @@ class DirectManipulationControl(DirectObject):
|
|||||||
# Mouse motion edge to edge of display region results in one full turn
|
# Mouse motion edge to edge of display region results in one full turn
|
||||||
relHpr(base.direct.widget, base.direct.camera, 0, 0, -deltaAngle)
|
relHpr(base.direct.widget, base.direct.camera, 0, 0, -deltaAngle)
|
||||||
|
|
||||||
|
def scale1D(self, state):
|
||||||
|
# [gjeon] Constrained 1D scale of the selected node based upon up down mouse motion
|
||||||
|
if self.fScaleInit:
|
||||||
|
self.fScaleInit = 0
|
||||||
|
self.initScaleMag = Vec3(self.objectHandles.getAxisIntersectPt(self.constraint[:1])).length()
|
||||||
|
# record initial scale
|
||||||
|
self.initScale = base.direct.widget.getScale()
|
||||||
|
# Reset fHitInitFlag
|
||||||
|
self.fHitInit = 1
|
||||||
|
|
||||||
|
# Scale factor is ratio current mag with init mag
|
||||||
|
if self.constraint[:1] == 'x':
|
||||||
|
currScale = Vec3(self.initScale.getX() *
|
||||||
|
self.objectHandles.getAxisIntersectPt('x').length() / self.initScaleMag,
|
||||||
|
self.initScale.getY(), self.initScale.getZ())
|
||||||
|
elif self.constraint[:1] == 'y':
|
||||||
|
currScale = Vec3(self.initScale.getX(),
|
||||||
|
self.initScale.getY() * self.objectHandles.getAxisIntersectPt('y').length() / self.initScaleMag,
|
||||||
|
self.initScale.getZ())
|
||||||
|
elif self.constraint[:1] == 'z':
|
||||||
|
currScale = Vec3(self.initScale.getX(), self.initScale.getY(),
|
||||||
|
self.initScale.getZ() * self.objectHandles.getAxisIntersectPt('z').length() / self.initScaleMag)
|
||||||
|
|
||||||
|
base.direct.widget.setScale(currScale)
|
||||||
|
|
||||||
def scale3D(self, state):
|
def scale3D(self, state):
|
||||||
# Scale the selected node based upon up down mouse motion
|
# Scale the selected node based upon up down mouse motion
|
||||||
# Mouse motion from edge to edge results in a factor of 4 scaling
|
# Mouse motion from edge to edge results in a factor of 4 scaling
|
||||||
|
Loading…
x
Reference in New Issue
Block a user