【计算机图形学】实验报告7绘制空间物体3D线框图

在这里插入图片描述

#include <GL/glut.h>

GLint winWidth = 1600, winHeight = 1280;
GLfloat x0 = 0.0, y0 = 300.0, z0 = 150;
GLfloat xref = 0.0, yref = 0.0, zref = 50.0;
GLfloat Vx = 0.0, Vy = 0.0, Vz = 1.0;
GLfloat xwMin = -50.0, ywMin = -40.0, xwMax = 50.0, ywMax = 40.0;
GLfloat dnear = 50.0, dfar = 600.0;

void init(void)
{
   
	glClearColor(1.0, 1.0, 1.0, 0.0);
	glMatrixMode(GL_MODELVIEW);
	//gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); 
	gluLookAt(x0, y0, z0, xref, yref, zref, Vx, Vy, Vz);//第一组eyex, eyey,eyez 相机在世界坐标的位置
														//第二组centerx, centery, centerz 相机镜头对准的物体在世界坐标的位置
														//第三组upx, upy, upz 相机向上的方向在世界坐标中的方向
	glMatrixMode(GL_PROJECTION);
	glFrustum(xwMin, xwMax, ywMin, ywMax, dnear, dfar);
}

void displayFcn(void)
{
   
	int i, j;

	float point[138][3] =
	{
    {
   150,25,0},{
   95,25,0},{
   95,-25,0},{
   150,-25,0},{
   125,14,140},{
   102,14,140},{
   102,-14,140},{
   125,-14,140}
	,{
   126,17,145},{
   100,17,145},{
   100,-17,145},{
   126,-17,145},{
   126,17,150},{
   100,17,150},{
   100,-17,150},{
   126,-17,150}
	,{
   135,30,160},{
   80,30,160},{
   80,-30,160},{
   135,-30,160},{
   135,30,165},{
   80,30,165},{
   80,-30,165},{
   135,-30,165}

	,{
   -95,25,0},{
   -150,25,0},{
   -150,-25,0},{
   -95,-25,0},{
   -102,14,140},{
   -125,14,140},{
   -125,-14,140},{
   -102,-14,140}
	,{
   -100,17,145},{
   -126,17,145},{
   -126,-17,145},{
   -100,-17,145},{
   -100,17,150},{
   -126,17,150},{
   -126,-17,150},{
   -100,-17,150}
	,{
   -80,30,160},{
   -135,30,160},{
   -135,-30,160},{
   -80,-30,160},{
   -80,30,165},{
   -135,30,165},{
   -135,-30,165},{
   -80,-30,165}

	,{
   110,30,165},{
   -110,30,165},{
   -110,-30,165},{
   110,-30,165},{
   110,30,185},{
   -110,30,185},{
   -110,-30,185},{
   110,-30,185}
	,{
   115,20,170},{
   -115,20,170},{
   -115,-20,170},{
   115,-20,170},{
   125,20,180},{
   125,-20,180},{
   -125,20,180},{
   -125,-20,180}
	,{
   125,20,190},{
   -125,20,190},{
   -125,-20,190
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在WPF中绘制深度不同颜色的3D模型填充线框,可以使用Viewport3D控件和MeshGeometry3D类。 首先,创建一个Viewport3D控件,设置其大小和位置。然后,创建一个GeometryModel3D对象,设置其Geometry属性为一个MeshGeometry3D对象,设置其Material属性为一个DiffuseMaterial对象,设置其Brush属性为一个线性渐变画刷。线性渐变画刷可以设置多个颜色和位置,在不同位置上产生不同的颜色过渡效果。设置DiffuseMaterial的AmbientColor属性和EmissiveColor属性可以产生一定的阴影效果。 接下来,创建一个ModelVisual3D对象,设置其Content属性为GeometryModel3D对象。最后,将ModelVisual3D对象添加到Viewport3D控件的Children集合中即可。 要实现线框效果,可以创建一个GeometryModel3D对象,设置其Geometry属性为原始MeshGeometry3D对象,设置其Material属性为一个DiffuseMaterial对象,设置其Brush属性为透明画刷。然后,创建一个ModelVisual3D对象,设置其Content属性为GeometryModel3D对象,设置其Visual3DMode属性为Wireframe。最后,将ModelVisual3D对象添加到Viewport3D控件的Children集合中即可。 下面是一个示例代码: ```xml <Viewport3D Width="500" Height="500"> <Viewport3D.Resources> <MeshGeometry3D x:Key="Geometry"> <!--定义一个3D模型--> </MeshGeometry3D> <LinearGradientBrush x:Key="GradientBrush" StartPoint="0,0" EndPoint="1,1"> <GradientStop Offset="0" Color="Red"/> <GradientStop Offset="0.5" Color="Yellow"/> <GradientStop Offset="1" Color="Green"/> </LinearGradientBrush> </Viewport3D.Resources> <Viewport3D.Camera> <!--设置相机位置--> </Viewport3D.Camera> <ModelVisual3D> <ModelVisual3D.Content> <GeometryModel3D Geometry="{StaticResource Geometry}"> <GeometryModel3D.Material> <DiffuseMaterial Brush="{StaticResource GradientBrush}" AmbientColor="Gray" EmissiveColor="Black"/> </GeometryModel3D.Material> </GeometryModel3D> </ModelVisual3D.Content> </ModelVisual3D> <ModelVisual3D> <ModelVisual3D.Content> <GeometryModel3D Geometry="{StaticResource Geometry}"> <GeometryModel3D.Material> <DiffuseMaterial Brush="Transparent"/> </GeometryModel3D.Material> </GeometryModel3D> </ModelVisual3D.Content> <ModelVisual3D.Visual3DMode> <Visual3DMode>Wireframe</Visual3DMode> </ModelVisual3D.Visual3DMode> </ModelVisual3D> </Viewport3D> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值