Week - 5 - Checking and correcting the Normals
Aim-
- Write a code to display normal as explained in class.
- Create a widget containing two buttons for “reverse normals” and “normal off”.
- Also assign these procedures to keyboard buttons of your choice.
- check the null case also.
Code and Explanation-
| Codes | Explanation |
| *clearmarkall 1 | #It will clear all the previously selected elements |
| *setnormalsdisyplaytype 1 | # It will display the normals in colour. |
| *createmark elements 1 "displayed" | # It will display the all the displayed element. |
| *normalsdisplay elements 1 | #It will turns on the display of element normal. |
| *clearmarkall 1 | |
| *createmarkpanel elements 1 " Select elements to reverse" | #It will create a panel to select the element and stored it. |
| *normalreverse elements 1 | #This will reverse the normal of elements which you have selected |
| *createmark elements 1 "displayed" | |
| *normalsdisplay elements 1 |
CREATING Widget
#setting a window
set a .window
catch {destroy $a}
toplevel $a -class TopLevel
#managing window size and name
wm title $a "Normals"
wm geometry $a 250x70+100+500
wm resizable $a 0 0
wm deiconify $a
#assigning buttons
button $a.01 -text " Reverse Normals" -command {*createmark elements 1 "displayed" ; *normalsreverse elements 1} ;
place $a.01 -x 20 -y 20 -width 100 -height 30
button $a.02 -text " Normals Off" -command {*createmark elements 1 "displayed" ; *normalsoff} ;
place $a.02 -x 130 -y 20 -width 100 -height 30.
Procedure-
- *setnormalsdisplaytpeis used to display the type of visualization whether with direction of normal (0) or color(1)
- Then the elements displayed in were selected using *createmarkcommand.
- Normals were displayed for the selected element with color representation using*normalsdisplay elems.
- Functions were created for the reversing the normals and select the elements using proc and these functions are called by assigning the respective buttons.
- To reverse the normals of the selected elements *normalsreverse command is used.
- hm_framework is used to create a separate tab.
Output-
1. Shortcut key select shift + ~.

2. Now after running widget code.
