neil@yc.estec.nl (Neil Dixon) (04/10/90)
To any starbase expert out there!
Some time ago I posted a request asking how to use a R.H.S. in Starbase, but got no response. I'm hoping this time I'm a bit luckier.
Looking through the Starbase manuals, it appears that the way to get a R.H.S.
in starbase is:-
define matrix left_to_right, which is identity except Z scale element is -1
set up camera structure and call view_camera
call view_matrix3d with left_to_right matrix and mode PRE_CONCAT_VW
push transformation matrix left_to_right
draw whatever you want
make_picture_current.
This doesn't seem to work, since the net effect is still a left hand system. What
is missing? An example program demonstrating my difficulties follows.
Neil Dixon <neil@yc.estec.nl> UUCP:...!mcvax!esatst!neil, BITNET: NDIXON@ESTEC
Thermal Control & Life Support Division (YC)
European Space Research and Technology Centre (ESTEC),
Noordwijk, The Netherlands.
/* ------------------------- Cut Here ----------------------*/
#include <starbase.c.h>
#include <math.h>
main(argc, argv)
int argc;
char **argv;
{
int fd;
camera_arg camera;
float xval, yval, zval;
float theta;
static float left_to_right[4][4] = { /* use r.h. coord system */
{ 1.0, 0.0, 0.0, 0.0},
{ 0.0, 1.0, 0.0, 0.0},
{ 0.0, 0.0,-1.0, 0.0},
{ 0.0, 0.0, 0.0, 1.0}
};
system("xwcreate -geometry 400x400 rhs");
fd = gopen("/dev/screen/rhs", OUTDEV, "sox11", INIT|THREE_D);
text_alignment(fd, TA_LEFT, TA_TOP, 0.0, 0.0);
xval = 1.0;
yval = 1.0;
zval = 1.0;
vdc_extent(fd, -2.0, -2.0, -2.0, 2.0, 2.0, 2.0);
character_height(fd, 0.2);
line_color(fd, 1.0, 1.0, 1.0);
text_color(fd, 1.0, 1.0, 1.0);
background_color(fd, 0.0, 0.0, 0.0);
camera.refx = camera.refy = camera.refz = 0.0;
camera.upx = camera.upz = 0.0;
camera.upy = 1.0;
camera.field_of_view = 60.0;
camera.front = camera.back = 0.0;
camera.projection = CAM_PERSPECTIVE;
theta = 0.0;
camera.camy = 2.0;
push_matrix3d(fd, left_to_right);
while (1) {
camera.camx = 2.0 * sin(theta);
camera.camz = 2.0 * cos(theta);
theta = fmod(theta + M_PI/180.0, 2 * M_PI);
view_camera(fd, &camera);
view_matrix3d(fd, left_to_right, PRE_CONCAT_VW);
clear_view_surface(fd);
move3d(fd, 0.0, 0.0, 0.0);
draw3d(fd, xval, 0.0, 0.0);
text3d(fd, xval, 0.0, 0.0,"X",WORLD_COORDINATE_TEXT,0);
move3d(fd, 0.0, 0.0, 0.0);
draw3d(fd, 0.0, yval, 0.0);
text3d(fd, 0.0, yval, 0.0,"Y",WORLD_COORDINATE_TEXT,0);
move3d(fd, 0.0, 0.0, 0.0);
draw3d(fd, 0.0, 0.0, zval);
text3d(fd, 0.0, 0.0, zval,"Z",WORLD_COORDINATE_TEXT,0);
make_picture_current(fd);
}
gclose(fd);
}stroyan@hpfcso.HP.COM (Mike Stroyan) (04/11/90)
> Looking through the Starbase manuals, it appears that the way to get a R.H.S. > in starbase is:- ... > This doesn't seem to work, since the net effect is still a left hand system. > What is missing? An example program demonstrating my difficulties follows. > Neil Dixon You can get the result you want by either- 1) using gopen with MODEL_XFORM or 2) repeating "push_matrix3d(fd, left_to_right);" after view_matrix3d If you are not in MODEL_XFORM mode, then view_matrix3d will pop off all of the transforms on the current transform matrix stack, since they all have the old view matrix concatenated into them. In MODEL_XFORM mode the modelling transforms are kept separate and do not need to be flushed. Mike Stroyan, stroyan@hpfcla.hp.com