




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Hierarchical Modeling II1Angel: Interactive Computer Graphics 5E Addison-Wesley 2009原著Ed AngelProfessor of Computer Science, Electrical and Computer Engineering, and Media ArtsUniversity of New Mexico编辑 武汉大学计算机学院图形学课程组2Angel: Interactive Computer Graphics 5E Addison-Wesley 2009ObjectivesBuild a tree
2、-structured model of a humanoid figureExamine various traversal strategiesBuild a generalized tree-model structure that is independent of the particular model3Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Humanoid Figure4Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Buildin
3、g the ModelCan build a simple implementation using quadrics: ellipsoids and cylindersAccess parts through functionstorso()left_upper_arm()Matrices describe position of node with respect to its parentMlla positions left lower leg with respect to left upper arm5Angel: Interactive Computer Graphics 5E
4、Addison-Wesley 2009Tree with Matrices6Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Display and TraversalThe position of the figure is determined by 11 joint angles (two for the head and one for each other part)Display of the tree requires a graph traversalVisit each node onceDisplay fu
5、nction at each node that describes the part associated with the node, applying the correct transformation matrix for position and orientation7Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Transformation MatricesThere are 10 relevant matricesM positions and orients entire figure through
6、the torso which is the root nodeMh positions head with respect to torsoMlua, Mrua, Mlul, Mrul position arms and legs with respect to torsoMlla, Mrla, Mlll, Mrll position lower parts of limbs with respect to corresponding upper limbs8Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Stack-ba
7、sed TraversalSet model-view matrix to M and draw torsoSet model-view matrix to MMh and draw headFor left-upper arm need MMlua and so onRather than puting MMlua from scratch or using an inverse matrix, we can use the matrix stack to store M and other matrices as we traverse the tree9Angel: Interactiv
8、e Computer Graphics 5E Addison-Wesley 2009Traversal Codefigure() glPushMatrix() torso(); glRotate3f(); head(); glPopMatrix(); glPushMatrix(); glTranslate3f(); glRotate3f(); left_upper_arm(); glPopMatrix(); glPushMatrix();save present model-view matrixupdate model-view matrix for headrecover original
9、 model-view matrixsave it againupdate model-view matrix for left upper armrecover and save original model-view matrix againrest of code10Angel: Interactive Computer Graphics 5E Addison-Wesley 2009AnalysisThe code describes a particular tree and a particular traversal strategyCan we develop a more ge
10、neral approach?Note that the sample code does not include state changes, such as changes to colorsMay also want to use glPushAttrib and glPopAttrib to protect against unexpected state changes affecting later parts of the code11Angel: Interactive Computer Graphics 5E Addison-Wesley 2009General Tree D
11、ata StructureNeed a data structure to represent tree and an algorithm to traverse the treeWe will use a left-child right sibling structureUses linked listsEach node in data structure is two pointersLeft: next nodeRight: linked list of children12Angel: Interactive Computer Graphics 5E Addison-Wesley
12、2009Left-Child Right-Sibling Tree13Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Tree node StructureAt each node we need to store Pointer to siblingPointer to childPointer to a function that draws the object represented by the nodeHomogeneous coordinate matrix to multiply on the right o
13、f the current model-view matrixRepresents changes going from parent to nodeIn OpenGL this matrix is a 1D array storing matrix by columns 14Angel: Interactive Computer Graphics 5E Addison-Wesley 2009C Definition of treenodetypedef struct treenode GLfloat m16; void (*f)(); struct treenode *sibling; st
14、ruct treenode *child; treenode;15Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Defining the torso nodetreenode torso_node, head_node, lua_node, ; /* use OpenGL functions to form matrix */glLoadIdentity();glRotatef(theta0, 0.0, 1.0, 0.0); /* move model-view matrix to m */glGetFloatv(GL_M
15、ODELVIEW_MATRIX, torso_node.m)torso_node.f = torso; /* torso() draws torso */Torso_node.sibling = NULL;Torso_node.child = &head_node; 16Angel: Interactive Computer Graphics 5E Addison-Wesley 2009NotesThe position of figure is determined by 11 joint angles stored in theta11Animate by changing the ang
16、les and redisplayingWe form the required matrices using glRotate and glTranslate More efficient than softwareBecause the matrix is formed in model-view matrix, we may want to first push original model-view matrix on matrix stack17Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Preorder Tr
17、aversalvoid traverse(treenode *root) if(root = NULL) return; glPushMatrix(); glMultMatrix(root-m); root-f(); if(root-child != NULL) traverse(root-child); glPopMatrix(); if(root-sibling != NULL) traverse(root-sibling);18Angel: Interactive Computer Graphics 5E Addison-Wesley 2009NotesWe must save mode
18、l-view matrix before multiplying it by node matrix Updated matrix applies to children of node but not to siblings which contain their own matricesThe traversal program applies to any left-child right-sibling treeThe particular tree is encoded in the definition of the individual nodesThe order of traversal matters because of possible state changes in the functions19Angel: Interactive Computer Gr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 汉英儿童二语分级读物对比研究
- 社区心理健康普及
- 风湿病用药护理
- 2025年学校安全日教育主题活动
- 海外宠物培训课件
- 电商文化培训
- 同济大学内科学教学体系
- 预防接种知识培训课件
- 顺利消防2021课件
- 项目总工程师培训课件
- 2025年省国有资本运营控股集团有限公司人员招聘笔试备考试题及答案详解(名校卷)
- 2025年辅警招聘考试试题库完整答案
- 宿州萧县乡镇事业单位招聘考试真题2024
- 2025至2030全球及中国近炸引信传感器行业项目调研及市场前景预测评估报告
- 部编版三年级语文上册 写字表
- 工厂十周年活动策划方案
- 黑启动操作培训课件
- 天津汇融商业管理有限公司招聘笔试题库2025
- 肿瘤的健康科普
- 广东教育学院德育研究中心
- 2025至2030中国清洁机器人市场经营效益与投融资发展状况报告
评论
0/150
提交评论