SilverScreen Solid Modeler

SS_COMMAND

SS_COMMAND

Previous topic Next topic  

SS_COMMAND

Previous topic Next topic JavaScript is required for the print function  

SilverScreenAPI

 

SS_COMMAND: A Member of Printf-Family

 

 
ss_command is a member of the printf family of functions.  It uses formatting descriptors such as %d and %s in the same manner as printf.  In additon to the descriptors supported by printf, ss_command also supports one additional descriptor, %z.  This descriptor allows for easy formatting of variables of the type SS_XYZ.

The SS_XYZ structure is used to store three-dimensional coordinates.  The structure has three components:

 

C / C++ Code

 

 struct SS_XYZ

    {

    double x;

    double y;

    double z;

    };

 

 

The %z descriptor requires a pointer to a variable of type SS_XYZ.  Let us assume that p1, p2, and p3 contain the coordinates of three points.  Then ss_command can be used to draw a triangle as follows:

 

C / C++ Code

 

 SS_XYZ p1,p2,p3;

 . . .

 ss_command (“begin polygon”);

 ss_command (“point %z”,&p1);

 ss_command (“point %z”,&p2);

 ss_command (“point %z”,&p3);

 ss_command (“end polygon”);

 

 

The use of the %z descriptor is equivalent to the use of three comma-separated %.15g descriptors.  Without using %z, the above statements can be rewritten as

 

C / C++ Code

 

 ss_command (“point %.15g,%.15g,%.15g”,p1.x,p1.y,p1.z);

 ss_command (“point %.15g,%.15g,%.15g”,p2.x,p2.y,p2.z);

 ss_command (“point %.15g,%.15g,%.15g”,p3.x,p3.y,p3.z);

 

:

 

A Short Example

 
The following program begins by opening a drawing with the name machine.  The viewing mode is set to perspective, and the drawing is zoomed so that it appears at the center of the screen.  The horizonal angle of view is then altered 12 times, each time by 30 degrees.  With each change in view, the drawing is rendered and a BMP image is exported.

 

After unloading the drawing, the 12 BMP images are successively displayed on the screen.
 

C / C++ Code

 

 int i;

 

 // Load the drawing

 ss_command (“load drawing machine”);

 

 // Set up window view

 ss_command (“cursor disable”);

 ss_command (“view project perspective”);

 ss_command (“zoom drawing”);

 

 // Loop 12 times: hide, save an image, then move view

 for ( i = 1 ; i <= 12 ; ++i )

    {

    ss_command (“hide drawing fill edged gray”);

    ss_command (“export picture file vw%d.bmp format bmp24 screen”, i);

    ss_command (“view modify h-angle absolute %d”,i*30);

    }

 ss_command (“unload”);

 

 for ( i = 1 ; i <= 12 ; ++i )

    ss_command (“import picture file vw%d.bmp screen best-fit”,i);

 

 ss_command (“cursor enable”);