当前位置: 首页>>代码示例>>C++>>正文


C++ MeshModel::drawModelEdges方法代码示例

本文整理汇总了C++中MeshModel::drawModelEdges方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshModel::drawModelEdges方法的具体用法?C++ MeshModel::drawModelEdges怎么用?C++ MeshModel::drawModelEdges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MeshModel的用法示例。


在下文中一共展示了MeshModel::drawModelEdges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawScene

void drawScene() {
	if (g_reset) {
		sceneObject.getMtrx().setAllValues(1, 0, 0, 0,
			0, 1, 0, 0,
			0, 0, 1, 0,
			0, 0, 0, 1);
		axisTransform = sceneObject.getMtrx();

		g_ambientLight = 0xffffff;
		g_light1.setDefaults();
		g_light2.setDefaults();

		g_reset = !g_reset;
	}
	//initial position of object
	Matrix4x4 modelMtrx(1, 0, 0, 0,
						0, 1, 0, 0,
						0, 0, 1, 0,
						0, 0, -5, 1);

	//transforming object with all required transformations
	modelMtrx = sceneObject.getMtrx()*modelMtrx;

	//creating a camera object
	Camera cam({ 0, 0, 0, 1 }, (sceneObject.getMshMdl().getCentroid())*modelMtrx, { 0,1,0,1 });
	
	//pointing camera at object
	if (g_centerCam) {
		saveCamera.setAllValues(1, 0, 0, 0,
								0, 1, 0, 0,
								0, 0, 1, 0,
								0, 0, 0, 1);
		saveCamera*=cam.getViewMtrx();
		g_centerCam = false;
	}
	modelMtrx *= saveCamera;

	//creating projection matrix and aplying it
	cam.setProjectionMatrix(g_fovy, g_near, g_far, (eProjectionType)g_projectionType, 1);

	//view to screen matrix
	Matrix4x4 v2sMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, g_Swidth / 2, g_Sheight / 2, 0, 1);

	Matrix4x4 projectionMtrx(cam.getProjectionMtrx()* v2sMatrix);

	//creating a mesh model and apllying all the transformations
	MeshModel model = sceneObject.getMshMdl();
	model.transformMshMdl(modelMtrx);

	if (g_mesh) {
		model.transformMshMdl(projectionMtrx);
		model.drawModelEdges();
	}
	else {
		Vector4 eyePosition(g_Swidth / 2, g_Sheight / 2, 0, 1);
		g_zBuffer.emptyBuffer();
		Shader shader(g_shadingType);
		model.material.setAll(g_ambient, g_diffuse, g_specular, g_specularExp);
		shader.draw(model, g_ambientLight, g_light1, g_light2, g_zBuffer, eyePosition, projectionMtrx);
		g_zBuffer.drawBuffer();
	}

	modelMtrx *= projectionMtrx;

	//show bounding box
	if (g_bbox) {
		BBox box2 = box;
		box2.transformBox(modelMtrx);
		box2.drawBox();
	}
	//show normals
	if (g_normals) {
		model.drawNormals(g_normals_size);
	}
	//show coordinate systems
	if (g_showCrdSystem) {
		model.calcCentroid();
		sceneObject.drawObjectCrdSystem(axisTransform, model.getCentroid(), g_Swidth / 2, g_Sheight / 2);
	}
}
开发者ID:eden-fed,项目名称:HW_computer_graphics,代码行数:80,代码来源:Main.cpp


注:本文中的MeshModel::drawModelEdges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。