⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 depthcue.c

📁 Intro/: Directory containing introductory examples. HelloWorld.c A simple program that draws a bo
💻 C
字号:
#include <phigs.h>			/* get HP-PHIGS definitions for C */#include <stdio.h>			/* get standard I/O definitions */#include <math.h>			/* link with library "-lm" */#define deg 				*3.1415926535897932384/180main()					/* file "DepthCue.c" */{    Pint	WorkstnID = 1;		/* workstation identifier */    Pint	ConnID;			/* connection identifier */    Pint	WorkstnType = POIDDX;	/* out/in, direct, dbl bfr, Xwindow */    Pint	Cube = 1, Scene = 2;	/* structure IDs */    static Ppoint3	TopPts[5] =       {{-1.0,  1.0, -1.0}, {-1.0,  1.0,  1.0}, { 0.0,  1.0,  1.0},	{ 1.0,  1.0,  0.0}, { 1.0,  1.0, -1.0}};    static Ppoint_list3	Top = {5, TopPts};    static Ppoint3	BottomPts[4] =       {{-1.0, -1.0,  1.0}, {-1.0, -1.0, -1.0}, { 1.0, -1.0, -1.0},	{ 1.0, -1.0,  1.0}};    static Ppoint_list3	Bottom = {4, BottomPts};    static Ppoint3	RightPts[5] =       {{ 1.0, -1.0, -1.0}, { 1.0,  1.0, -1.0}, { 1.0,  1.0,  0.0},	{ 1.0,  0.0,  1.0}, { 1.0, -1.0,  1.0}};    static Ppoint_list3	Right = {5, RightPts};    static Ppoint3	LeftPts[4] =       {{-1.0, -1.0,  1.0}, {-1.0,  1.0,  1.0}, {-1.0,  1.0, -1.0},	{-1.0, -1.0, -1.0}};    static Ppoint_list3	Left = {4, LeftPts};    static Ppoint3	FrontPts[5] =       {{ 1.0, -1.0,  1.0}, { 1.0,  0.0,  1.0}, { 0.0,  1.0,  1.0},	{-1.0,  1.0,  1.0}, {-1.0, -1.0,  1.0}};    static Ppoint_list3	Front = {5, FrontPts};    static Ppoint3	BackPts[4] =       {{-1.0, -1.0, -1.0}, {-1.0,  1.0, -1.0}, { 1.0,  1.0, -1.0},	{ 1.0, -1.0, -1.0}};    static Ppoint_list3	Back = {4, BackPts};    static Ppoint3	CornerPts[3] =       {{ 1.0,  0.0,  1.0}, { 1.0,  1.0,  0.0}, { 0.0,  1.0,  1.0}};    static Ppoint_list3	Corner = {3, CornerPts};    Pdepth_cue_rep	DepthCueRep;		/* depth-cueing info holder */    Pmatrix3		xform;			/* transformation matrix */    static Pcolr_rep	White =	{1.0, 1.0, 1.0};/* RGB for white; for lines */    Pvec3		Vector;			/* for scaling/translation */    Pint		Error;			/* error-return variable */    popen_phigs((char *) stderr, 0);		/* errors go to "stderr" */    pescape_u4("/dev/screen/phigs_window", &ConnID);    popen_ws(WorkstnID, (void *) ConnID, WorkstnType);    pescape_u250(WorkstnID, 0);			/* set colour env: direct */    pset_colr_rep(WorkstnID, 1, &White);    /*--- set depth cue representation for entry 1 -------------------------*/    DepthCueRep.mode = PDEPTH_CUE_ALLOWED;    DepthCueRep.ref_planes[0] = 0.25;    DepthCueRep.ref_planes[1] = 0.75;    DepthCueRep.scale[0] = 0.0;    DepthCueRep.scale[1] = 1.0;    DepthCueRep.gcolr.colr_type = PCOLR_RGB;    DepthCueRep.gcolr.colr_value.colr_rep.rgb.red   = 0.3;    DepthCueRep.gcolr.colr_value.colr_rep.rgb.green = 0.3;    DepthCueRep.gcolr.colr_value.colr_rep.rgb.blue  = 0.3;    pset_depth_cue_rep(WorkstnID, 1, &DepthCueRep);    /*--- define the Cube structure ----------------------------------------*/    popen_struct(Cube);    Vector.delta_x = 0.25, Vector.delta_y = 0.5, Vector.delta_z = 0.5;    pscale3(&Vector, &Error, xform);    if (Error) printf("Error %d in first pscale3.\n", Error), exit(1);    pset_local_tran3(xform, PTYPE_REPLACE);    Vector.delta_x = 0.7, Vector.delta_y = 0.7, Vector.delta_z = 0.7;    pscale3(&Vector, &Error, xform);    if (Error) printf("Error %d in second pscale3.\n", Error), exit(1);    pset_local_tran3(xform, PTYPE_POSTCONCAT);    protate_y(10 deg, &Error, xform);    if (Error) printf("Error %d in protate_y.\n", Error), exit(1);    pset_local_tran3(xform, PTYPE_POSTCONCAT);    protate_x(10 deg, &Error, xform);    if (Error) printf("Error %d in protate_x.\n", Error), exit(1);    pset_local_tran3(xform, PTYPE_POSTCONCAT);    Vector.delta_x = 0.5, Vector.delta_y = 0.5, Vector.delta_z = 0.5;    ptranslate3(&Vector, &Error, xform);    if (Error) printf("Error %d in ptranslate3.\n", Error), exit(1);    pset_local_tran3(xform, PTYPE_POSTCONCAT);    pfill_area3(&Top);    pfill_area3(&Bottom);    pfill_area3(&Back);    pfill_area3(&Right);    pfill_area3(&Left);    pfill_area3(&Front);    pfill_area3(&Corner);    pclose_struct();    /*--- open the Scene structure -----------------------------------------*/    popen_struct(Scene);    pset_depth_cue_ind(1);    pset_edge_flag(PEDGE_ON);    pset_int_style(PSTYLE_HOLLOW);    pexec_struct(Cube);    pclose_struct();    ppost_struct(WorkstnID, Scene, 1.0);    pclose_ws(WorkstnID);    pclose_phigs();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -