Viewing Environment and Definition   

<<< KID Graphics: Overview Chapters KID Rendering >>>

Contents

[back to top]


12.1 Introduction

The viewing environment is held in properties which are either inherited from the graphics class or are defined locally. Defaults are provided for all graphics classes.

view_to, view_from view_direction view_vertical, perspective functions

These properties allow the user to define how the model is viewed. Examples of the use of these properties, and their default values, are given below:

 

> (graphics view_to ´( 0 0 0 ) )    -- look at origin
> (graphics view_from ´(3000 1732 1999))
         -- view from specified point
> (graphics view_direction ´(-0.3 -0.1732 -0.2))
         -- define specific view direction
> (graphics view_direction)         
         -- returns current view direction ´-3.0 -0.1732 -0.2´
> (graphics view_vertical ´(0 0 1)) 
         -- make Z axis vertical in view
> (graphics perspective nil)        -- switch off perspective

If graphics perspective is nil (the default), then,

If graphics perspective is t , then'

view function

The following pre-defined view directions can be set using their associated commands:

 

> (graphics view ´top)
> (graphics view ´bottom)
> (graphics view ´left)
> (graphics view ´right)
> (graphics view ´front)
> (graphics view ´back)
> (graphics view ´trimetric)
> (graphics view ´isometric)

[back to top]


12.2 Windowing

view_window_xmin/xmax/ymin/ymax

Windowing defines that area of the model image which is in view. The "view_window_" functions are the most basic ones. There default settings are:

 

> (graphics view_window_xmin -100)
> (graphics view_window_xmax 100)
> (graphics view_window_ymin -100)
> (graphics view_window_ymax 100)

[back to top]

12.2.1 Using the cursor for redefining the window

The following functions provide an easier way to redefine the window by using the cursor.

pick_window

When a picture has been drawn, "pick_window" enables the cursor for two picks, to define a window diagonal.

 

> (graphics sketch ´b0)
> (graphics pick_window )    -- cursor enabled for two picks
> (graphics redraw )

pick_centre

pick_centre enables the cursor for a pick which defines the centre of the new window. If more detail of the new window centre is required this operation can be followed by a "zoom". Be careful not to use "autowindow" immediately after these commands, unless the new window is to be purposely overwritten.

 

> (graphics sketch ´b0)
> (graphics pick_centre)
> (graphics zoom 2)
> (graphics redraw)

autowindow

It is possible to "autowindow" the view so that the window is set to the smallest size possible for the objects which are currently drawn.

redraw

"redraw" clears the screen and draws the current GRA graphics data structure. This means that if the graphics drawing list is altered, followed by a "redraw", the GRA graphics data is output, not reflecting the change in the drawing list.

ar

"ar" is the combination of an "autowindow" and a "redraw".

 

> (graphics sketch ´b0)    -- b0 sketched with current view
> (graphics autowindow)    -- no visible change
> (graphics redraw) 
                    -- sketch of b0 with smallest possible window

or

 

> (graphics ar)            -- autowindow and redraw
> (graphics drawing_list ´( b0 b1)) -- drawing list changed
> (graphics redraw)        -- but only b0 will be drawn
Note: Using "autowindow" on its own does not have any visible effect, although it does altered the GRA viewing environment. Its effect is only visible after a "redraw".

centre

The "centre" function uses a model space pointer to specify the centre of the current view window. To refresh the view, and therefore see the view in relation to the specified "centre", it is necessary to do a "redraw".

 

> ( graphics ske ´b0 )
> ( graphics centre ´( 0 0 10 ); redraw )

zoom

The "zoom" function takes a real number as its argument. It changes the current window sizes so that the image is magnified or reduced about the "centre" of the current view window.

A factor greater than 1.0 magnifies the image on the screen.

To see the zoomed image it is necessary to refresh the screen using "redraw".

 

> ( graphics zoom <factor> )
> ( graphics redraw )

[back to top]


12.3 View manipulation

pan_left/right/up/down

It is possible to change the view definition by altering the properties previously described. However, a number of functions are provided to allow easy manipulation of the view. The pan functions take a real number as their argument. The effect is to move the edges of the window by the given distance in the given direction.

 

> (graphics pan_left <distance>)
> (graphics pan_right <distance>)
> (graphics pan_up <distance>)
> (graphics pan_down <distance>)

rotate_left/right/up/down

The rotate functions also take a real number as their argument. They rotate the viewing direction and the 'from point' about the image by the given amount. The angle is specified in degrees.

 

> (graphics rotate_left <angle>)
> (graphics rotate_right <angle>)
> (graphics rotate_up <angle>)
> (graphics rotate_down <angle>)

[back to top]


12.4 Selecting a view

Only one view or graphics subclass can be active at a time, and all graphics output are sent to that view until another one is selected. The view must first be defined, then this view can be selected:

 

Object

Function

graphics

select

 

> (define view_x graphics)
> (view_x select)
Note: Selecting a view does not clear the screen, or draw the frame and axes.

[back to top]


12.5 Clearing the screen and drawing the current view

 

Object

Function

graphics

clear, axes, frame

clear

The function clear clears the graphics screen of the terminal, and empty the GRA stream(s) used by the current view:

 

> (graphics clear)

In addition to the clear function, use of the abbreviated forms of sketch and hidden clear the screen before drawing the entity.

 

> (graphics ske ´b0)
> (graphics hid ´b0)

frame and axes functions

To display the limits of the current view on the screen, the "frame" function is provided, "axes" draws axes in the current view.

 

> (graphics frame [<t or nil>])
> (graphics axes [<t or nil>])

Using these functions without any arguments draws a frame or axes in the view. If an argument is given, this is interpreted as a logical value (t or nil). If the value given is t (i.e. anything but nil) a frame or axes are automatically drawn when ever the view is redrawn.

[back to top]


12.6 Use of the drawing list

drawing_list

Each view has a drawing list property, e.g. view_1 drawing_list . This is used to contain a list of the objects which have been drawn in this particular view. Initially, the drawing list is empty, but when objects are rendered their names are added to this list.

Some functions redraw all the items in the drawing list. If the view has no drawing list itself, they look up the class tree until a non empty drawing list is found. Therefore, one class may be used to hold the drawing list and its subclasses may be views which are used to render the objects.

It is possible to add items to the drawing list without rendering them. This could be used to create a sketch of a number of objects.

 

> (define my_view graphics)
> (my_view select)
> (my_view drawing_list ´(b0 e1 f2))
> (my_view sketch)   -- objects b0, e1 and f2 will now be drawn
Note: 1) The object which is the argument should be a list of KID objects, which represent kernel items with tags, and it must be quoted (') to avoid it being evaluated.

2) graphics clear does not clear the drawing_list which is used for "Picking". Therefore, it is possible to pick objects from what appears to be a clear display. The drawing_list must be reset independently.

> (graphics drawing_list ´(b0))-- drawing_list only contains b0
> (graphics drawing_list nil)    -- empty the drawing_list

[back to top]


12.7 Enquiry

It is possible to enquire about a view:

 

Object

Function

graphics

enquiries

 

> (view_x enquire)   -- prints information about the view

[back to top]

<<< KID Graphics: Overview Chapters KID Rendering >>>