kaotkbliss Posted December 23, 2009 Share Posted December 23, 2009 I am trying to create a slider control that will resize a 3d model (using IrrLicht) I understand how a slider works and how it's created and have done that. I understand how resizing the 3d model works and have done that. I can't seem to figure out how to combine the two to work together the way I want. this is the resize syntax ScaleMesh( node/3d model, x height, y height, z height ) $heightS=GUICtrlCreateSlider ( 0.15*@desktopwidth, 0.84*@desktopheight ,150,20) GUICtrlSetLimit($heightS,130/100,70/100) $height2=GUICtrlRead($heightS) While 1 $msg = GUIGetMsg() If $msg = $heightS Then $height2=GUICtrlRead($heightS) ScaleMesh( $toon, $height2, $height2, $height2 ) EndIf Wend obviously there is more code between. I've tried giving the guictrlsetlimit a set number but that doesn't work either. Basically what is happening with the code above is the slider starts all the way to the left and only has an option to move all the way to the right (no in between) and (could be my math) but the image resizes way too big. I would like the slider to start in the center and moving to the left makes the image smaller by 10% up to a -30% total, right makes it bigger at 10% inciments for a total of +30% total. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 23, 2009 Moderators Share Posted December 23, 2009 kaotkbliss, Sliders cannot go above 100, so you have to play with the limits to get the return values you want. In this script I have set the limits to 40 and 100, so all you have to do to get the % change you want is to add 30 to the result: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $heightS = GUICtrlCreateSlider(10, 10, 150, 20) GUICtrlSetLimit($heightS, 100, 40) GUISetState() $height2 = 70 GUICtrlSetData($heightS, $height2) While 1 Switch GUIGetMsg() Case $heightS $height2 = GUICtrlRead($heightS) ConsoleWrite($height2 + 30 & @CRLF) ; Just to show what you get <<<<<<<<<<<<<< ;ScaleMesh($toon, $height2, $height2, $height2) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I hope this helps. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
kaotkbliss Posted December 23, 2009 Author Share Posted December 23, 2009 I'm at work right now and have been pretty scatterbrained the past few days being busy and everyone is on Holiday... I thought I mentioned (but looks like I didn't) the ScaleMesh works on percents so a whole number makes the image bigger, a decimal makes it smaller. to decrease the size by 10% the value would be .90 (new size= 90% of current size) so even if you use min value on the slider as .70 and max as 30, if you decrease 2x you are now at -30% of original size then increase 10% then you are now at -40% (-30%)---(-20%)---(-10%)---( 0 )---(+10%)---(+20%)---(+30%) even if you set it all at -10% and +10% the same moves above still put you at -30% I hope you understand what I am trying to say 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 23, 2009 Moderators Share Posted December 23, 2009 kaotkbliss, That was as clear as mud! Do I understand that you need to apply the percentage change betwen the current value and the new one? If so then this should work: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $heightS = GUICtrlCreateSlider(10, 10, 150, 20) GUICtrlSetLimit($heightS, 100, 40) GUISetState() $height2 = 70 GUICtrlSetData($heightS, $height2) $Currheight2 = 70 $AbsoluteSize = 100 While 1 Switch GUIGetMsg() Case $heightS $height2 = GUICtrlRead($heightS) $ChangeFactor = ($height2 + 30) / ($Currheight2 + 30) ConsoleWrite("Old Size: " & $AbsoluteSize & @CRLF & "Change Factor: " & $ChangeFactor & @CRLF & _ "Calc Size: " & $AbsoluteSize * $ChangeFactor & @CRLF & "Req Size: " & $height2 + 30 & @CRLF) $Currheight2 = $height2 $AbsoluteSize = $height2 + 30 ;ScaleMesh($toon, $height2, $height2, $height2) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd So if you change the current image by $ChangeFactor, you shoudl get the required 70-130% range. Enjoy the holidays - when you get round to them. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
kaotkbliss Posted December 23, 2009 Author Share Posted December 23, 2009 GREAT! thank you so much, while the sizes are a little off, I did get the slider to do what I wanted, now it is just a matter of tweeking the values. The $changefactor variable is what I placed into the ScaleMesh x,y,z values 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 23, 2009 Moderators Share Posted December 23, 2009 kaotkbliss, There are probably small rounding errors at work in the maths - I did not take any great care over that. Glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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