Popular Post LarsJ Posted January 8, 2013 Popular Post Share Posted January 8, 2013 (edited) The picture shows Rubik's Cube in the middle of a rotation, wherein the layer is rotated 90 degrees.New version for AutoIt 3.3.10The scripts were flawed. Fixed in this update.08-01-2013: First postIn the Cubes menu there are six cubes from 2*2*2 to 7*7*7: Pocket Cube, Rubik's Cube, Rubik's Revenge, Professor's Cube, V-Cube 6 and V-Cube 7. See http://en.wikipedia.org/wiki/Rubik's_Cube.The Scramble menu scrambles the cube. In the input field in the statusbar you can set the number of scramble steps.The Solve menu automatically solves the cube. In this version it just plays back the undo log.The Build menu shows how the cubes are created. It also shows how the rotation of a layer is simulated.The Scramble, Solve and Build menus puts the program into a Scramble, Solve and Build mode. To leave the Scramble and Solve modes click the menu once more. To leave the Build mode uncheck the menu.The program mode or state appears in the statusbar.See the Help menu for more information about the menus.Rotating a layer in the cubeClick an edge of the layer with the left mouse button and hold the button downMove the mouse in the direction you want to rotate the layerRelease the left mouse buttonThe rotating layer in the picture has probably been clicked somewhere on the blue edge.You can't rotate a layer in Scramble, Solve and Build modes.The mouse buttons can be switched in the Options.Rotating the entire cubeClick in the window with the right mouse button and hold the button downMove the mouse in the direction you want the cube to rotateRelease the right mouse buttonThe description of the mouse rotations can be found in the Help menu.Using the keyboardUse the arrow keys or <A,a>, <W,w>, <S,s>, <Z,z> to rotate the cube.Use <Home> or <H,h> to place the cube in the start position.Use <Page Up> or <I,i> and <Page Down> or <O,o> to zoom in and out.Use Num 1-6 or 1-6 to show the 6 sides of the cube.The programInspiration for the program is from this site: http://rubiksim.sourceforge.net/.The graphics is generated with old style OpenGL 1.1. Some OpenGL globals and functions are copied from this thread http://www.autoitscript.com/forum/index.php?showtopic=83581 by trancexx. Especially globals and functions for creating an OpenGL window and a rendering context.ZipfileThe zipfile contains a number of files:RubiksCube.au3 - GUI and main loop, run this fileMenuFncs.au3 - implements the menu systemMenuWins.au3 - creates menu system windowsKeyboard.au3 - code for shortcut keysOGLconsts.au3 - OpenGL constantsOGLfuncs.au3 - OpenGL functionsCubes.au3 - creates the cubesTurnLayer.au3 - rotate a layerRotateCube.au3 - rotate the cubeScramble.au3 - scramble functionSolveCube.au3 - solve functionsBuild.au3 - build functionsUtilities.au3 - calculations(The files are edited with Notepad++ with a tabwidth of 2. This doesn't match the default settings in Scite.)21-01-2013: Update #1Fixed some errors in the Build menu.Added a log to see the colors of all sides at one time. See picture in post #5.RubiksCube3.3.10.7zTestet on XP 32 bit and Win 7 32/64 bit.Previous versions for AutoIt 3.3.8You need APIConstants.au3 v3.8 by Yashied. http://www.autoitscript.com/forum/index.php?showtopic=98712.To run this script as a 64 bit program you must use AutoIt beta 3.3.9.0 or higher. See http://www.autoitscript.com/forum/index.php?showtopic=147280. Testet with 3.3.9.4 and it works flawlessly.As a 32 bit program it runs under version 3.3.8.1.RubiksCube.7zRubiksCube2.7z25-08-2013: Update #2Added some workarounds to make the script run as a 64 bit program under version 3.3.8.1. See post #6.The scripts in this zip runs as 32 and 64 bit programs under version 3.3.8.1. All UDFs are included in the zip.RubiksCube3.7z Edited May 4, 2014 by LarsJ trancexx, argumentum, James and 10 others 12 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Myicq Posted January 8, 2013 Share Posted January 8, 2013 ..just as I thought I had a fair grip on AutoIT.. what an impressive job ! (er du tilfældigvis dansker ?) I am just a hobby programmer, and nothing great to publish right now. Link to comment Share on other sites More sharing options...
UEZ Posted January 8, 2013 Share Posted January 8, 2013 I don't like Rubik's Cube because I'm too silly for it but nice work. If you correct the perspective of the cube then it would look even better by dividing the x/y coordinates by a constants. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
LarsJ Posted January 9, 2013 Author Share Posted January 9, 2013 Myicq, Yes, I'm Danish. UEZ, It would look better, but I also think it would complicate the calculations primary in TurnLayer.au3. To keep calculations simple there is used an orthographic projection (glOrtho()). The lines between the layers in the cube are parallel. In a proper perspective these lines would not be parallel. That would complicate the calculations. Lars. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted January 21, 2013 Author Share Posted January 21, 2013 Fixed some errors in the Build menu.Added a log to see the colors of all sides at one time: Added updated zipfile in first post. trancexx 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted August 26, 2013 Author Share Posted August 26, 2013 Because of an issue with double parameters in DllCall's in AutoIt 3.3.8.1 when scripts are run as 64 bit programs some OpenGL functions are not working. In this example only a few functions uses double parameters: glOrtho, gluLookAt and gluProject. It's possible to make workarounds.A solution is to use The Embedded Flat Assembler (FASM) UDF by Ward to create assembler code to call the functions. For details see first post section 1.7 in this example.After the 64-bit workarounds were implemented there seemed to be a problem with glOrtho and gluLookAt. They work individually, but they do not work when both commands are used in the same script. This problem is solved by coding glOrtho in this way: Func glOrtho( $left, $right, $bottom, $top, $zNear, $zFar ) Local $m = $IDENTITY_MATRIX $m[0] = 2 / ( $right - $left ) $m[5] = 2 / ( $top - $bottom ) $m[10] = -2 / ( $zFar - $zNear ) $m[12] = - ( $right + $left ) / ( $right - $left ) $m[13] = - ( $top + $bottom ) / ( $top - $bottom ) $m[14] = - ( $zFar + $zNear ) / ( $zFar - $zNear ) glMultMatrixf( $m ) EndFuncIn the documentation of glOrtho it appears that the function can be implemented in this way.New zip added in the bottom of first post. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted May 4, 2014 Author Share Posted May 4, 2014 The scripts were flawed. Fixed in this update for 3.3.10. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now