[Gambas-user] New soft at the farm
Fabien Bodard
gambas.fr at ...626...
Wed Nov 25 09:43:05 CET 2015
This is how to use the Timer.Trigger to reduce the calls to the _Draw event.
Each time mouse seem to move it call the _MouseMove event so it can be
undreds time a second. Then this event call the .refresh method that
raiseth _draw event.
You have many call more in your code for the .refresh method.
So what i've done. I've put two timer one for the mouse event call and
one for the drawing. I think maybe only the one for the mouse event
will be sufficient.
so the mouse event call the timer.trigger thouthen time but the timer
event is raised only once by event loop. and you have not a queue that
appear with the slow down of your program. Because each call to
.refresh will be done event if the content of the _Draw take 0.1 sec
....
so now it is smooth on my machine and you can remove the fast lines.
' Gambas class file
Public $hDrawTimer As New Timer As "DrawTimer"
Public $hMoveTimer As New Timer As "MoveTimer"
Private MouseX As Integer
Private MouseY As Integer
Public cubes As New ClassCube[]
Public Struct Punto3D
x As Float
y As Float
z As Float
End Struct
'globles del mouse
Public paneando As Boolean
Public rotando As Boolean
Public mouDownX As Float
Public mouDownY As Float
Public mouUpX As Float
Public mouUpY As Float
Public mouX As Float
Public mouY As Float
Public cgX As Float 'coordenadas del CG en 2D
Public cgY As Float
Public lastPos As Integer
Public mouOut As Boolean ' fuera del area de graficos
Public mouDown As Boolean ' fuera del area de graficos
Public mouUp As Boolean ' fuera del area de graficos
Public Here As Boolean
Public mouWheel As Boolean
Public mouDelta As Integer
Public debugTime As Boolean = True
Public fps As Integer
Public FaceCubeList[6] As Integer[] 'cubes in face, from 9 to 9
Public FaceRotation[6] As Float[] ' xyz triplets
Public FaceCenter[6] As Float
Public CurrentFace As Integer
Public RotationFilter As Integer[]
Public RotationAcumulator As Float
Public CenterCube As Integer
Public State As Integer
Public Const stMixing As Integer = 1
Public Const stStopping As Integer = 2
Public Const stQuiting As Integer = 3
Public Sub Form_Open()
$hDrawTimer.Delay = 50
rotando = True
Paint3D.Init
modMotor3D.ResetMatrizRotacion
modMotor3D.escala = 0.5
Generate
'GenerateBigOne
End
Public Sub Form_Close()
If State = stStopping Or state = stMixing Then
state = stQuiting
Stop Event
Else
Me.Close
End If
End
Public Sub form_Activate()
'graph_Draw
$hDrawTimer.Trigger
End
Public Sub form_Resize()
'graph_Draw
$hDrawTimer.Trigger
End
Private Sub generate()
Dim cube1 As New ClassCube
Dim colores1 As New Integer[]
Dim p As Punto3D, a As Integer, b As Integer
' size of one cube is 1
'front facing, this is the front/left/low cube
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, Color.Green, 0, 0, &H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, 0, 0, 0, &H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, 0, Color.red, 0, &H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, Color.Green, 0, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, 0, 0, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
FaceCenter[0] = cubes.Max ' this cube is in the center
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, 0, Color.red, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
' High front row
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, Color.Green, 0, Color.blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, 0, 0, Color.Blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [Color.Yellow, 0, 0, Color.red, Color.Blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = 1 * cube1.Scale
cubes.Add(cube1)
' BACK FACE
'front facing, this is the front/left/low cube
cube1 = Null
cube1 = New ClassCube
colores1 = [0, Color.white, Color.Green, 0, 0, &H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [0, Color.white, 0, 0, 0, &H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [0, color.white, 0, Color.red, 0, &H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [0, color.white, Color.Green, 0, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [0, color.white, 0, 0, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
FaceCenter[1] = cubes.Max ' this cube is in the center
cube1 = Null
cube1 = New ClassCube
colores1 = [0, color.white, 0, Color.red, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
' High front row
cube1 = Null
cube1 = New ClassCube
colores1 = [0, Color.white, Color.Green, 0, Color.blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [0, Color.white, 0, 0, Color.Blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [0, Color.white, 0, Color.red, Color.Blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = -1 * cube1.Scale
cubes.Add(cube1)
FaceCubeList[0] = [0, 1, 2, 3, 4, 5, 6, 7, 8] ' front
FaceCubeList[1] = [9, 10, 11, 12, 13, 14, 15, 16, 17] 'back
FaceCubeList[2] = [0, 3, 6, 9, 12, 15, 18, 21, 24] 'left
FaceCubeList[3] = [2, 5, 8, 11, 14, 17, 20, 23, 26] 'rigth
FaceCubeList[4] = [6, 7, 8, 15, 16, 17, 24, 25, 26] 'top
FaceCubeList[5] = [0, 1, 2, 9, 10, 11, 18, 19, 20] 'bottomh
For a = 0 To 5
FaceRotation[a] = [0, 0, 0]
Next
' CENTER
'front facing, this is the mid/left/low cube
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, Color.Green, 0, 0, &H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, 0, 0, 0, &H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
FaceCenter[2] = cubes.Max ' this cube is in the center
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, 0, Color.red, 0, &H00FF00FF] '&H00FF00FF]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = -1 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
' mid, mid, left
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, Color.Green, 0, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
FaceCenter[3] = cubes.Max ' this cube is in the center
' this cube is in the core, not shown
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, 0, 0, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
CenterCube = cubes.Max
' mid, mid, rigth
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, 0, Color.red, 0, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = 0 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
FaceCenter[4] = cubes.Max ' this cube is in the center
' High mid row
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, Color.Green, 0, Color.blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = -1 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, 0, 0, Color.Blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 0 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
FaceCenter[5] = cubes.Max ' this cube is in the center
cube1 = Null
cube1 = New ClassCube
colores1 = [0, 0, 0, Color.red, Color.Blue, 0]
cube1.colores = colores1
cube1.scale = 200
cube1.xcg = 1 * cube1.Scale
cube1.ycg = 1 * cube1.Scale
cube1.zcg = 0 * cube1.Scale
cubes.Add(cube1)
b = cubes.Max
For a = 0 To b
cubes[a].RoundEdge = True
cube1 = New ClassCube
cube1.colores = [Color.HSV(0, 0, 45), Color.HSV(0, 0, 45),
Color.HSV(0, 0, 45), Color.HSV(0, 0, 45), Color.HSV(0, 0, 45),
Color.HSV(0, 0, 45)]
cube1.xCG = cubes[a].xCG
cube1.yCG = cubes[a].yCG
cube1.zCG = cubes[a].zCG
cube1.Scale = cubes[a].Scale * 0.95
cube1.RoundEdge = True
cubes.Add(cube1)
Next
'faces
BuildFaceList
GetFace
End
Public Sub GenerateBigOne()
Dim cube1 As ClassCube
' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' test collapsing
cube1 = Null
cube1 = New ClassCube
' colores1 = [Color.Green, Color.Yellow, Color.Violet, Color.Blue,
Color.white, &H00FF00FF]
cube1.colores = [Color.Green, Color.Yellow, Color.Violet,
Color.Blue, Color.white, &H00FF00FF]
cube1.Scale = 150
cube1.xcg = 0
cube1.ycg = 0 '2 * cube1.Scale
cube1.zcg = 0 '-1 * cube1.Scale
cube1.RoundEdge = True
cube1.FaceAngle = [0, 0, 0]
cubes.Add(cube1)
'
End
Public Sub graph_Drawer()
Dim nCube As Integer, p As New Punto3D
Dim x As Float, y As Float, nn As Integer
Paint3D.Begin(graph)
Paint3D.scale = 1
Paint.AntiAlias = False
'Debug " Drawer"
For nCube = 0 To cubes.Max
cubes[ncube].Draw
Next
Paint3D.End
End
Public Sub graph_MouseWheel()
mouDelta += Mouse.Delta
mouWheel = True
With modMotor3D
.escala += .escala * mouDelta * 0.1
'ademas intento un zoom dinamico, si el mouse esta lejos del
centro, atrae los graficos hacia el
.pan.x -= (graph.w / 2 - Mouse.X) * 0.1
.pan.y += (graph.h / 2 - Mouse.y) * 0.1
'Debug .pan.x, .pan.y, .escala
End With
'graph_Draw
$hDrawTimer.Trigger
mouWheel = False
mouDelta = 0
End
Public Sub graph_MouseDown()
Dim nFace As Integer
If state = stMixing Then Return
mouDownX = Mouse.X
mouDownY = Mouse.y
mouDown = True
RotationAcumulator = 0
If Mouse.Right Then
GetFace
Else
CurrentFace = -1
End If
End
Public Sub graph_MouseMove()
MouseX = Mouse.X
MouseY = Mouse.y
$hMoveTimer.Trigger
End
Public Sub MoveTimer_Timer()
Dim dx As Float, dy As Float, p As New Punto3d, pr As New Punto3d
Dim EjeX As Float, ejeY As Float, ejeZ As Float, nCube As Integer,
nn As Integer, f As Integer
Dim gorgui As Integer
If here Then Debug "Here"
here = True
If mouDown Then
If paneando Then
With modMotor3D
.pan.x -= (mouDownX - MouseX) * 0.25
.pan.y = (mouDownY - MouseY) * 0.25
End With
Else If rotando Then
'veo para donde mueve el mouse con respenco a la posicion 2D del CG
dX = (mouDownX - MouseX) * 0.005 '* mouDownXCG
dY = - (mouDownY - MouseY) * 0.005 '* mouDownYCG
' con esto la rotacion se hace de un eje a la vez
If Abs(dy) > Abs(dx) Then dx = 0 Else dy = 0
' debo interpretar que eje pretende mover
' el eje que mas apunta al user, es el que no rota, si el
mouse se mueve horizontal, rota sobre
' el eje vertica, y si se mueve vertical, rota sobre el
eje mas horizontal
p.x = 1
p.y = 0
p.z = 0
modMotor3D.rotar3d(p, pr)
EjeX = pr.x
p.x = 0
p.y = 1
p.z = 0
modMotor3D.rotar3d(p, pr)
ejey = pr.x
p.x = 0
p.y = 0
p.z = 1
modMotor3D.rotar3d(p, pr)
ejeZ = pr.x
'Debug ejex, ejey, ejez
If Abs(ejex) > Abs(ejey) And Abs(ejex) > Abs(ejez) Then
modMotor3D.vector3d.x = dy * Sgn(ejex)
If Abs(ejey) > Abs(ejez) And Abs(ejey) > Abs(ejex) Then
modMotor3D.vector3d.y = dy * Sgn(ejey)
If Abs(ejez) > Abs(ejey) And Abs(ejez) > Abs(ejex) Then
modMotor3D.vector3d.z = dy * Sgn(ejez)
p.x = 1
p.y = 0
p.z = 0
modMotor3D.rotar3d(p, pr)
EjeX = pr.y
p.x = 0
p.y = 1
p.z = 0
modMotor3D.rotar3d(p, pr)
ejey = pr.y
p.x = 0
p.y = 0
p.z = 1
modMotor3D.rotar3d(p, pr)
ejeZ = pr.y
'Debug ejex, ejey, ejez
If Abs(ejex) > Abs(ejey) And Abs(ejex) > Abs(ejez) Then
modMotor3D.vector3d.x = dx * Sgn(ejex)
If Abs(ejey) > Abs(ejez) And Abs(ejey) > Abs(ejex) Then
modMotor3D.vector3d.y = dx * Sgn(ejey)
If Abs(ejez) > Abs(ejey) And Abs(ejez) > Abs(ejex) Then
modMotor3D.vector3d.z = dx * Sgn(ejez)
If CurrentFace >= 0 Then
modMotor3D.fVector3D[0] += (dx + dy) * RotationFilter[0] * 2
modMotor3D.fVector3D[1] += (dx + dy) * RotationFilter[1] * 2
modMotor3D.fVector3D[2] += (dx + dy) * RotationFilter[2] * 2
' ademas roto los CG
FaceRotation[CurrentFace] = modMotor3D.fVector3D
RotationAcumulator += FaceRotation[CurrentFace][0] +
FaceRotation[CurrentFace][1] + FaceRotation[CurrentFace][2]
modMotor3D.PushMatrix
modMotor3D.LoadIdentuty
'Debug RotationAcumulator, FaceRotation[CurrentFace][0],
FaceRotation[CurrentFace][1], FaceRotation[CurrentFace][2]
modMotor3D.fRotateVector
For ncube = 0 To FaceCubeList[CurrentFace].max
nn = FaceCubeList[CurrentFace][ncube]
modMotor3D.Rotar3Df(cubes[nn].xCG, cubes[nn].yCG,
cubes[nn].zCG, ByRef cubes[nn].xCG, ByRef cubes[nn].yCG, ByRef
cubes[nn].zCG)
modMotor3D.RotacionLocalv(cubes[nn].Points, cubes[nn].Points)
' For f = 0 To cubes[nn].points.Max
' cubes[nn].Points[f] = cubes[nn].RotPoints[f]
' Next
'
modMotor3D.RotacionLocalv(cubes[nn].Normals, cubes[nn].Normals)
Next
modMotor3D.PopMatrix
Else
modMotor3D.setvectorrotacion
End If
End If
$hDrawTimer.Trigger
' graph_Draw
mouDownX = MouseX
mouDownY = MouseY
End If
here = False
End
Public Sub graph_MouseUp()
Dim TotRot As Float, quarters As Integer, rest As Float, dist As
Float, MaxDist As Float
Dim nn As Integer, nCube As Integer, turns As Integer, Turn90 As
Integer, n$ As String, f As Integer
Dim diagonal As Float
Dim Xc As Float, Yc As Float, Zc As Float
If here Then Debug "Here"
mouDown = False
If CurrentFace = -1 Then
' we've been rotating everithinng
Else 'complete the turnn
' in case of many turns we simplify
turns = RotationAcumulator / (2 * Pi)
RotationAcumulator -= turns * 2 * Pi ' we dont need anything over 2 * pi
quarters = Fix(RotationAcumulator / (Pi / 4))
If quarters = 1 Then quarters = 2 '
If quarters = 3 Then quarters = 4
If quarters = 5 Then quarters = 6 '
If quarters = 7 Then quarters = 8
If quarters = -1 Then quarters = -2 '
If quarters = -3 Then quarters = -4
If quarters = -5 Then quarters = -6 '
If quarters = -7 Then quarters = -8
rest = rotationAcumulator - quarters * (Pi / 4)
FaceRotation[CurrentFace][0] = - rest * RotationFilter[0]
FaceRotation[CurrentFace][1] = - rest * RotationFilter[1]
FaceRotation[CurrentFace][2] = - rest * RotationFilter[2]
'
modMotor3D.PushMatrix
modMotor3D.LoadIdentuty
modMotor3D.fVector3D = FaceRotation[CurrentFace]
modMotor3D.fRotateVector
For ncube = 0 To FaceCubeList[CurrentFace].Max
nn = FaceCubeList[CurrentFace][ncube]
modMotor3D.Rotar3Df(cubes[nn].xCG, cubes[nn].yCG,
cubes[nn].zCG, ByRef cubes[nn].xCG, ByRef cubes[nn].yCG, ByRef
cubes[nn].zCG)
modMotor3D.RotacionLocalv(cubes[nn].Points, cubes[nn].Points)
' For f = 0 To cubes[nn].points.Max
' cubes[nn].Points[f] = cubes[nn].RotPoints[f]
' Next
modMotor3D.RotacionLocalv(cubes[nn].Normals, cubes[nn].Normals)
Next
modMotor3D.PopMatrix
RotationAcumulator = 0
BuildFaceList
Endif
' graph_Drawer
$hDrawTimer.Trigger ' does no work this way
End
Public Sub graph_Draw()
graph_Drawer
fps += 1
End
Public Sub GetFace()
Dim p As New Punto3d, pr As New Punto3d
Dim EjeX As Float, ejeY As Float, ejeZ As Float, face As Integer
Dim maxZ As Float
For face = 0 To 5
ejez = modMotor3D.xyzZ3D(cubes[FaceCenter[face]].cg)
If ejez > maxZ Then maxZ = ejez
Next
For face = 0 To 5
ejez = modMotor3D.xyzZ3D(cubes[FaceCenter[face]].cg)
If ejez = maxZ Then Break
Next
CurrentFace = face
RotationFilter = [Abs(Sgn(Int(cubes[FaceCenter[CurrentFace]].xCG))),
Abs(Sgn(Int(cubes[FaceCenter[CurrentFace]].yCG))),
Abs(Sgn(Int(cubes[FaceCenter[CurrentFace]].zCG)))]
End
Private Sub BuildFaceList()
Dim TotRot As Float, quarters As Integer, rest As Float, dist As
Float, MaxDist As Float
Dim nn As Integer, nCube As Integer, turns As Integer, Turn90 As
Integer, n$ As String
For nn = 0 To 5 ' total faces
FaceCubeList[nn].Clear
TotRot = 0
For ncube = 0 To cubes.Max
If Round(cubes[FaceCenter[nn]].xCG) <> 0 Then
If Round(cubes[ncube].xCG) = Round(cubes[FaceCenter[nn]].xCG) Then
FaceCubeList[nn].Add(ncube)
TotRot += 1
Endif
End If
If Round(cubes[FaceCenter[nn]].yCG) <> 0 Then
If Round(cubes[ncube].yCG) = Round(cubes[FaceCenter[nn]].yCG) Then
FaceCubeList[nn].Add(ncube)
TotRot += 1
Endif
End If
If Round(cubes[FaceCenter[nn]].zCG) <> 0 Then
If Round(cubes[ncube].zCG) = Round(cubes[FaceCenter[nn]].zCG) Then
FaceCubeList[nn].Add(ncube)
TotRot += 1
Endif
End If
Next
'Debug TotRot
Next
End
Public Sub mix()
Dim TotRot As Float, quarters As Integer, rest As Float, dist As
Float, MaxDist As Float, f As Integer
Dim nn As Integer, nCube As Integer, turns As Float, Turn90 As
Integer, n$ As String, turns0 As Float
Dim nFace As Integer, t As Float
'nFace = 1
t = Timer
BuildFaceList
btnMix.Text = "Stop"
For turn90 = 1 To 18
nFace = Int(Rnd(0, 5.99))
RotationFilter = [Abs(Sgn(Int(cubes[FaceCenter[nFace]].xCG))),
Abs(Sgn(Int(cubes[FaceCenter[nFace]].yCG))),
Abs(Sgn(Int(cubes[FaceCenter[nFace]].zCG)))]
BuildFaceList
turns0 = 0
For turns = 0 To Pi / 2 Step (Pi / 2 / 9)
modMotor3D.fVector3D = [turns - turns0, turns -
turns0, turns - turns0]
modMotor3D.fVector3D[0] *= RotationFilter[0]
modMotor3D.fVector3D[1] *= RotationFilter[1]
modMotor3D.fVector3D[2] *= RotationFilter[2]
modMotor3D.PushMatrix
modMotor3D.LoadIdentuty
modMotor3D.fRotateVector
For ncube = 0 To FaceCubeList[nFace].max
nn = FaceCubeList[nFace][ncube]
modMotor3D.Rotar3Df(cubes[nn].xCG, cubes[nn].yCG,
cubes[nn].zCG, ByRef cubes[nn].xCG, ByRef cubes[nn].yCG, ByRef
cubes[nn].zCG)
modMotor3D.RotacionLocalv(cubes[nn].Points, cubes[nn].Points)
modMotor3D.RotacionLocalv(cubes[nn].Normals, cubes[nn].Normals)
Next
modMotor3D.PopMatrix
$hDrawTimer.Trigger
'graph_Draw
Wait 0.001
turns0 = turns
If State = stQuiting Then Quit
Next
If State = stStopping Then Break
Next
Me.Title = " Mixing time : " & Format$(Timer - t, "0.00") & "secs"
End
Public Sub btnMix_Click()
If btnMix.text = "Stop" Then
State = stStopping
Else
State = stMixing
mix
'graph_Draw
btnMix.Text = "Mix"
State = 0
BuildFaceList
End If
End
Public Sub Panel1_MouseDown()
End
Public Sub DrawTimer_Timer()
graph.Refresh
End
2015-11-24 21:50 GMT+01:00 Jussi Lahtinen <jussi.lahtinen at ...626...>:
> Seems to be bug in gb.jit. Please report it in:
> http://gambaswiki.org/bugtracker
>
>
> Jussi
>
> On Tue, Nov 24, 2015 at 7:26 PM, martin p cristia <tercoide at ...67...>
> wrote:
>
>> Thanks for all the critics, help improving things.
>>
>> Version 0.1.6 just uploaded to the Farm has the following changes:
>>
>> - .Refresh instead of a cached DrawingArea
>> - prevents click while mixing
>> - From starting position, mixing time (now displayed at the window's
>> title after the mix) takes : 3.95 secs with Antialias = False (@
>> Fmain.graph_drawer) and 8.00 secs when set to True, what's yours? Cube
>> actually fly here.
>>
>>
>> (to Jussi)
>>
>> -> Sub modMotor3D.fRotateVector complains about receiving a Integer[] at
>> this line when declared as Fast:
>>
>> matrizXmatriz(MatrizRVieja, MatrizRNueva, MatrizRotacion, 3)
>>
>> all matrices are declared as Float[], as well as in the multiplication
>> routine
>>
>> -> Sub Paint3D.SortPaths makes Ubuntu pop a Unexpected Error message
>> when Fast -ened, and program stops without making Gambas crash
>>
>>
>>
>>
>>
>> -- Saludos Ing. Martin P Cristia
>>
>>
>> ------------------------------------------------------------------------------
>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>> Give your users amazing mobile app experiences with Intel(R) XDK.
>> Use one codebase in this all-in-one HTML5 development environment.
>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple
>> OSs.
>> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
--
Fabien Bodard
More information about the User
mailing list