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

📄 vertexcolour.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 SetGColr(Vl,Rd,Gr,Bl)	Vl.colr_type = PCOLR_RGB;		\				Vl.colr_value.colr_rep.rgb.red   = Rd;	\				Vl.colr_value.colr_rep.rgb.green = Gr;	\				Vl.colr_value.colr_rep.rgb.blue  = Bl#define deg 			*3.1415926535897932384/180main()					/* file "VertexColour.c" */{    Pint	WorkstnID = 1;			/* workstation identifier */    Pint	ConnID;				/* connection identifier */    Pint	WorkstnType = POIDDX;		/* out/in, dir, dbl bfr, X */    Pint	Cube = 1, Scene = 2;		/* structure IDs */    static Prgb	Gray = {0.5, 0.5, 0.5};		/* for setting colours */    Pgcolr	Black;				/* edge colour */    Pmatrix3	Matrix;				/* transformation matrix */    static Pvec3   Translate = {0.5, 0.5, 0.5};	/* for modelling transforms */    static Pvec3   Scale     = {0.3, 0.3, 0.3};	/* for modelling transforms */    static Ppoint3 Loc       = {0.0, 0.0, 0.0};	/* local origin for xforms */    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, 0, (Pcolr_rep *) &Gray);    BuildCube(Cube);				/* define geometry/colour */    popen_struct(Scene);    pset_int_shad_method(PINT_SHAD_METHOD_COLR);    pset_edge_flag(PEDGE_ON);    SetGColr(Black, 0.0, 0.0, 0.0);    pset_edge_colr(&Black);    pset_int_style(PSTYLE_SOLID);    pbuild_tran_matrix3(&Loc, &Translate, 20 deg, 20 deg, 7.1 deg, &Scale,      &Error, Matrix);    pset_local_tran3(Matrix, PTYPE_REPLACE);    pexec_struct(Cube);    pclose_struct();    ppost_struct(WorkstnID, Scene, 1.0);    pclose_ws(WorkstnID);    pclose_phigs();}/****************************************************************************/BuildCube(Cube)Pint	Cube;					/* structure ID */{    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 Prgb	TopColours[5]	= {{0.0, 1.0, 0.0},	/* green */				   {1.0, 1.0, 0.0},	/* yellow */				   {1.0, 1.0, 0.5},	/* light yellow */				   {0.5, 1.0, 1.0},	/* light cyan */				   {0.0, 1.0, 1.0}};	/* cyan */    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 Prgb	BottomColours[4]= {{1.0, 0.0, 0.0},	/* red */				   {0.0, 0.0, 0.0},	/* black */				   {0.0, 0.0, 1.0},	/* blue */				   {1.0, 0.0, 1.0}};	/* magenta */    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 Prgb	RightColours[5]	= {{0.0, 0.0, 1.0},	/* blue */				   {0.0, 1.0, 1.0},	/* cyan */				   {0.5, 1.0, 1.0},	/* light cyan */				   {1.0, 0.5, 1.0},	/* light magenta */				   {1.0, 0.0, 1.0}}; 	/* magenta */    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 Prgb	LeftColours[4]	= {{1.0, 0.0, 0.0},	/* red */				   {1.0, 1.0, 0.0},	/* yellow */				   {0.0, 1.0, 0.0},	/* green */				   {0.0, 0.0, 0.0}};	/* black */    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 Prgb	FrontColours[5]	= {{1.0, 0.0, 1.0},	/* magenta */				   {1.0, 0.5, 1.0},	/* light magenta */				   {1.0, 1.0, 0.5},	/* light yellow */				   {1.0, 1.0, 0.0},	/* yellow */				   {1.0, 0.0, 0.0}}; 	/* red */    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 Prgb	BackColours[4]	= {{0.0, 0.0, 0.0},	/* black */				   {0.0, 1.0, 0.0},	/* green */				   {0.0, 1.0, 1.0},	/* cyan */				   {0.0, 0.0, 1.0}}; 	/* blue */    static Ppoint3 CornerPts[3] = {	{ 1.0,  0.0,  1.0}, { 1.0,  1.0,  0.0}, { 0.0,  1.0,  1.0}};    static Prgb	CornerColours[3]= {{1.0, 0.5, 1.0},	/* light magenta */				   {0.5, 1.0, 1.0},	/* light cyan */				   {1.0, 1.0, 0.5}}; 	/* light yellow */    popen_struct(Cube);    FillAreaSet(4, BackPts, BackColours);    FillAreaSet(4, BottomPts, BottomColours);    FillAreaSet(4, LeftPts, LeftColours);    FillAreaSet(5, RightPts, RightColours);    FillAreaSet(5, TopPts, TopColours);    FillAreaSet(5, FrontPts, FrontColours);    FillAreaSet(3, CornerPts, CornerColours);    pclose_struct();}/****************************************************************************/FillAreaSet(Vertices, VertPts, VertRGB)Pint	Vertices;			/* number of vertices in polygon */Ppoint3	VertPts[];			/* vertex geometry */Prgb	VertRGB[];			/* vertex colours */{    Pvertex3_set	VertexSet;    Pvertex3_list	VertexList;        VertexSet.num_lists = 1;    VertexSet.vertices = &VertexList;    VertexList.num_vertices = Vertices;    VertexList.num_data_per_vertex = 0;    VertexList.vertex_points = VertPts;    VertexList.vertex_colrvs.colr_reps.rgb = VertRGB;    VertexList.vertex_norms = NULL;    VertexList.vertex_data = NULL;    pfill_area_set3_data(PCOLR_RGB, NULL, NULL, &VertexSet);}

⌨️ 快捷键说明

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