コード例 #1
0
ファイル: Scenes3D.py プロジェクト: kleopatra999/Orbitit
    def OnPaint(this, event):
        if this.dbgTrace:
            print 'Interactive3DCanvas.OnPaint(this,..):'

        def xy2SphereV(x, y, w, h, R2):
            x, y = x - width / 2, height / 2 - y
            l2 = x * x + y * y
            if l2 < R2:
                spherePos = GeomTypes.Vec3([x, y, math.sqrt(R2 - l2)])
            elif l2 > R2:
                scale = math.sqrt(R2 / l2)
                spherePos = GeomTypes.Vec3([scale * x, scale * y, 0])
            else:  # probably never happens (floats)
                spherePos = GeomTypes.Vec3([x, y, 0])
            return spherePos

        dc = wx.PaintDC(this)
        this.SetCurrent(this.context)
        if not this.init:
            this.initGl()
            this.init = True
            this.Moriginal = glGetDoublev(GL_MODELVIEW_MATRIX)
        glPushMatrix()
        this.onPaint()
        glPopMatrix()

        if this.xOrg != 0 or this.yOrg != 0:
            viewPort = glGetIntegerv(GL_VIEWPORT)
            height = viewPort[3] - viewPort[1]
            width = viewPort[2] - viewPort[0]
            D = min(width, height)
            R2 = float(D * D) / 4
            R2 = this.rScale * this.rScale * R2
            newSpherePos = xy2SphereV(this.x, this.y, width, height, R2)
            orgSphere = xy2SphereV(this.xOrg, this.yOrg, width, height, R2)
            ax, an = getAxis2AxisRotation(orgSphere, newSpherePos)
            this.movingRepos = GeomTypes.Rot3(axis=ax,
                                              angle=an) * this.modelRepos
            glLoadMatrixd(this.Moriginal)
            glScalef(this.currentScale, this.currentScale, this.currentScale)
            save, GeomTypes.eqFloatMargin = GeomTypes.eqFloatMargin, 1.0e-14
            angle = Geom3D.Rad2Deg * this.movingRepos.angle()
            axis = this.movingRepos.axis()
            GeomTypes.eqFloatMargin = save
            #print 'rotate', angle, axis
            glRotatef(angle, axis[0], axis[1], axis[2])

        if this.z != this.zBac:
            dZ = this.z - this.zBac
            # map [min, max] onto [0, 2]
            # dZ' = (2/(max-min)) dZ + 1
            #pStr = '%f ->' % dZ
            dZ = dZ * this.zScaleFactor + 1.0
            this.currentScale = dZ * this.currentScale
            #print '%s %f' % (pStr, dZ)
            glScalef(dZ, dZ, dZ)

        glFlush()
        this.SwapBuffers()
コード例 #2
0
 def updateOrientation(this):
     v = this.showGui[this.__AxisGuiIndex].GetVertex()
     if v == GeomTypes.Vec3([0, 0, 0]):
         rot = GeomTypes.E
         this.statusText(
             'Rotation axis is the null-vector: applying identity',
             LOG_INFO)
     else:
         rot = GeomTypes.Rot3(axis=v,
                              angle=Geom3D.Deg2Rad * this.currentAngle)
     try:
         this.shape.setBaseOrientation(rot)
     except AttributeError:
         this.statusText(
             'Apply symmetry first, before pulling the slide-bar', LOG_WARN)
コード例 #3
0
     ([[0.99609400000000003, 0.83984400000000003, 0.0]], []),
     ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []),
     ([[0.54296900000000003, 0.0, 0.0]], []),
     ([[0.0, 0.74609400000000003, 0.99609400000000003]], []),
     ([[0.54296900000000003, 0.0, 0.0]], []),
     ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []),
     ([[0.0, 0.74609400000000003, 0.99609400000000003]], []),
     ([[0.0, 0.74609400000000003, 0.99609400000000003]], []),
     ([[0.99609400000000003, 0.83984400000000003, 0.0]], []),
     ([[0.54296900000000003, 0.0, 0.0]], []),
     ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []),
     ([[0.99609400000000003, 0.83984400000000003, 0.0]], [])
 ],
 directIsometries = [
     GeomTypes.Rot3((
         GeomTypes.Quat([-0.5, 0.5, -0.5, -0.5]),
         GeomTypes.Quat([-0.5, -0.5, 0.5, 0.5]),
     )),
     GeomTypes.Rot3((
         GeomTypes.Quat([-0.707106781187, 1.04526690545e-16, -0.707106781187, 4.32963728536e-17]),
         GeomTypes.Quat([-0.707106781187, -1.04526690545e-16, 0.707106781187, -4.32963728536e-17]),
     )),
     GeomTypes.Rot3((
         GeomTypes.Quat([-1.22460635382e-16, 6.12303176911e-17, -0.707106781187, -0.707106781187]),
         GeomTypes.Quat([-1.22460635382e-16, -6.12303176911e-17, 0.707106781187, 0.707106781187]),
     )),
     GeomTypes.Rot3((
         GeomTypes.Quat([0.707106781187, -0.707106781187, -6.12303176911e-17, -6.12303176911e-17]),
         GeomTypes.Quat([0.707106781187, 0.707106781187, 6.12303176911e-17, 6.12303176911e-17]),
     )),
     GeomTypes.Rot3((
         GeomTypes.Quat([-3.33066907388e-16, -0.707106781187, 0.707106781187, 3.08170915002e-16]),
コード例 #4
0
 Es=[
     0, 1, 1, 2, 2, 3, 0, 3, 3, 7, 4, 7, 0, 4, 4, 5, 1, 5, 5, 6, 2, 6, 6, 7
 ],
 colors=[
     ([[0.99609400000000003, 0.83984400000000003, 0.0]], []),
     ([[0.13281200000000001, 0.54296900000000003,
        0.13281200000000001]], []),
     ([[0.54296900000000003, 0.0, 0.0]], []),
     ([[0.0, 0.74609400000000003, 0.99609400000000003]], []),
     ([[0.54296900000000003, 0.52343799999999996,
        0.30468800000000001]], []),
 ],
 directIsometries=[
     GeomTypes.Rot3(
         (GeomTypes.Quat(
             [-0.809016994375, -0.5, 0.309016994375, -3.08426926158e-14]),
          GeomTypes.Quat(
              [-0.809016994375, 0.5, -0.309016994375, 3.08426926158e-14]))),
     GeomTypes.Rot3(
         (GeomTypes.Quat(
             [0.809016994375, -0.309016994375, -4.98739097981e-14, -0.5]),
          GeomTypes.Quat(
              [0.809016994375, 0.309016994375, 4.98739097981e-14, 0.5]))),
     GeomTypes.Rot3(
         (GeomTypes.Quat([0.5, 0.5, -0.5,
                          -0.5]), GeomTypes.Quat([0.5, -0.5, 0.5, 0.5]))),
     GeomTypes.Rot3(
         (GeomTypes.Quat(
             [0.5, -4.53526105559e-14, -0.309016994375, 0.809016994375]),
          GeomTypes.Quat(
              [0.5, 4.53526105559e-14, 0.309016994375, -0.809016994375]))),