+ All Categories
Home > Documents > Casing3d opengl

Casing3d opengl

Date post: 13-Jan-2015
Category:
Upload: gowell
View: 319 times
Download: 0 times
Share this document with a friend
Description:
python opengl 套管3维成像系统
Popular Tags:
24
Casing3D套管3维成像系统 pyopengl qtopengl实现
Transcript
Page 1: Casing3d opengl

Casing3D套管3维成像系统  

pyopengl  qtopengl实现  

Page 2: Casing3d opengl

议程  

•  casing3D程序演示  •  Opengl特征  •  Opengl架构演变  •  Qtopengl框架  •  casing3D使用的子集  

Page 3: Casing3d opengl

实例截图  

Page 4: Casing3d opengl

OpenGL基本观念  

•  OpenGL被设计为只有输出功能,只提供渲染  •  核心api没有窗口系统、音频、打印、键盘概念  •  跨平台开发。  •  GLUT库以可移植的方式提供基本的窗口功能。  •  类冯、诺依曼状态机结构,开发像是使用汇编语言操作控制寄存器来达到效果。  

•  实际开发需根据业务,自行封装提高抽象层次  

Page 5: Casing3d opengl

OpenGL’s  State  Machine  

•  All  rendering  a<ributes  are  encapsulated  in  the  OpenGL  State  –  rendering  styles  – shading  –  ligh?ng  –  texture  mapping  

5  

Page 6: Casing3d opengl

Manipula?ng  OpenGL  State  

•  Appearance  is  controlled  by  current  state        for  each  (  primi?ve  to  render  )  {  

     update  OpenGL  state        render  primi?ve  

     }  •  Manipula?ng  vertex  a<ributes  is  most        common  way  to  manipulate  state  

glColor*() / glIndex*() glNormal*() glTexCoord*()

6  

Page 7: Casing3d opengl

Controlling  current  state  

•  SeKng  State  glPointSize( size ); glLineStipple( repeat, pattern ); glShadeModel( GL_SMOOTH );

•  Enabling  Features  glEnable( GL_LIGHTING ); glDisable( GL_TEXTURE_2D );

7  

Page 8: Casing3d opengl

Camera  Analogy  

•  3D  is  just  like  taking  a  photograph  (lots  of  photographs!)  

8  

camera  

tripod   model  

viewing  volume  

Page 9: Casing3d opengl

Camera  Analogy  and  Transforma?ons  

•  Projec?on  transforma?ons  – adjust  the  lens  of  the  camera  

•  Viewing  transforma?ons  –  tripod–define  posi?on  and  orienta?on  of  the  viewing  volume  in  the  world  

•  Modeling  transforma?ons  – moving  the  model  

•  Viewport  transforma?ons  – enlarge  or  reduce  the  physical  photograph  

9  

Page 10: Casing3d opengl

Transforma?on  Pipeline  

•  other  calcula?ons  here  –  material  è  color  –  shade  model  (flat)  –  polygon  rendering  mode  –  polygon  culling  –  clipping  

10  

v e r t e x

Modelview Matrix

Projection Matrix

Perspective Division

Viewport Transform

Modelview

Modelview

Projection

l l l

object eye clip normalized device

window

CPU   DL  

Poly.   Per  Vertex  

Raster   Frag   FB  

Pixel  

Texture  

Page 11: Casing3d opengl

Projec?on  Tutorial  

11  

Page 12: Casing3d opengl

Opengl架构演变  

Page 13: Casing3d opengl

From the 1994 OpenGL 1.1 Data Flow…

vertex  processing  

rasteriza?on  &  fragment  coloring  

texture  raster  

opera?ons   framebuffer  

pixel  unpack  

pixel  pack  

vertex  puller  

client  memory  

pixel  transfer  

glReadPixels / glCopyPixels / glCopyTex{Sub}Image

glDrawPixels glBitmap glCopyPixels

glTex{Sub}Image  glCopyTex{Sub}Image  

glDrawElements  glDrawArrays  

selec<on  /  feedback  /  transform  feedback  

glVertex*  glColor*  glTexCoord*  etc.    

blending  depth  tes<ng  stencil  tes<ng  accumula<on  

storage  access  

opera<ons  

内存到显存,顶点向量运算,纹理贴图的像素运算,到光栅化显示  

Page 14: Casing3d opengl

…OpenGL 1.0 in detail

Vertex  processing  

Pixel  processing  

Texture  mapping  

Image  primi?ve  processing  

Raster  opera?ons   Framebuffer  

Command  parser  

Pixel  unpacking  

Pixel  packing  

Vertex  assembly  

texture  image  specifica?on  

image  rectangles,  bitmaps  

 primi?ve  topology,  transformed  vertex  data  

stenciling,  depth  tes?ng,  blending,  accumula?on  

pixel  image  

primi?ve  batch  type,  vertex  a<ributes  

primi?ve  batch  type,  

vertex  data  

fragment  texture  fetches  

pixel  image  or  texture  image  specifica?on  

image  and  bitmap  fragments  

point,  line,  and  polygon  fragments  

pixels  to  pack  

unpacked  pixels  

pixels  

fragments  

filtered  texels  

buffer  data  

ver?ces  

Legend  

programmable  opera?ons  

fixed-­‐func?on  opera?ons  

copy  pixels,  copy  texture  image  

Fragment  processing  

Geometric  primi?ve  assembly  &  processing  

顶点矢量  

贴图像素  

光栅化成像  

Page 15: Casing3d opengl

…to the 2009 OpenGL 3.2 Data Flow

Vertex  processing  

Pixel  processing  

Texture  mapping  

Geometric  primi?ve  assembly  &  processing  

Image  primi?ve  processing  

Raster  opera?ons   Framebuffer  

Command  parser  

Transform  feedback  

Pixel  unpacking  

Pixel  packing  

Vertex  assembly  

pixels  in  framebuffer  object  textures  

texture  buffer  objects  

texture  image  specifica?on  

image  rectangles,  bitmaps  

 primi?ve  topology,  transformed  vertex  data  

vertex  texture  fetches  

pixel  pack  buffer  objects  

pixel  unpack  buffer  objects  

vertex  buffer  objects  

transform  feedback  buffer  objects  

buffer  data,  unmap  buffer  

geometry  texture  fetches  

primi?ve  batch  type,  vertex  indices,  vertex  a<ributes  

primi?ve  batch  type,  

vertex  data  

fragment  texture  fetches  

pixel  image  or  texture  image  specifica?on  

map  buffer,  get  buffer  

data    

transformed  vertex  a<ributes  

image  and  bitmap  fragments  

point,  line,  and  polygon  fragments  

pixels  to  pack  

unpacked  pixels  

pixels  

fragments  

filtered  texels  

buffer  data  

ver?ces  

Legend  

programmable  opera?ons  

fixed-­‐func?on  opera?ons  

copy  pixels,  copy  texture  image  

Buffer  store  

uniform/  parameters  buffer  objects  

Fragment  processing  

stenciling,  depth  tes?ng,  blending,  accumula?on  

Buffer  cache  

Page 16: Casing3d opengl

Vertex  processing  

Pixel  processing  

Texture  mapping  

Geometric  primi?ve  assembly  &  processing  

Image  primi?ve  processing  

Raster  opera?ons   Framebuffer  

Command  parser  

Transform  feedback  

Pixel  unpacking  

Pixel  packing  

Vertex  assembly  

pixels  in  framebuffer  object  textures  

texture  buffer  objects  

texture  image  specifica?on  

image  rectangles,  bitmaps  

 primi?ve  topology,  transformed  vertex  data  

vertex  texture  fetches  

pixel  pack  buffer  objects  

pixel  unpack  buffer  objects  

vertex  buffer  objects  

transform  feedback  buffer  objects  

buffer  data,  unmap  buffer  

geometry  texture  fetches  

primi?ve  batch  type,  vertex  indices,  vertex  a<ributes  

primi?ve  batch  type,  

vertex  data  

fragment  texture  fetches  

pixel  image  or  texture  image  specifica?on  

map  buffer,  get  buffer  

data    

transformed  vertex  a<ributes  

image  and  bitmap  fragments  

point,  line,  and  polygon  fragments  

pixels  to  pack  

unpacked  pixels  

pixels  

fragments  

filtered  texels  

buffer  data  

ver?ces  

Legend  

programmable  opera?ons  

fixed-­‐func?on  opera?ons  

copy  pixels,  copy  texture  image  

Buffer  store  

Fragment  processing  

stenciling,  depth  tes?ng,  blending,  accumula?on  

Control  point  processing  

Patch  assembly  &  processing  

Patch  tessella?on  genera?on  

Patch  evalua?on  processing  

patch  control  points  

transformed  control  points  

transformed  patch  

transformed  patch,  bivariate  

domain  transformed  patch  tessella?on  

texture  fetches  

 patch  topology,  evaluated  patch  vertex  

patch  data  

OpenGL  4  

Page 17: Casing3d opengl

Buffer Centric View of OpenGL

Vertex  Array  Buffer  Object  (VaBO)  

Transform  Feedback  Buffer  

(XBO)  

Parameter  Buffer  (PaBO)  

Pixel  Unpack  Buffer  (PuBO)  

Pixel  Pack  Buffer  (PpBO)  Bindable  

Uniform  Buffer  (BUB)  

Texture  Buffer  Object  

(TexBO)  Vertex  Puller  

Vertex  Shading  

Geometry  Shading  

Fragment  Shading  

Texturing  

Array  Element  Buffer  Object  

(VeBO)  

Pixel  Pipeline  

vertex  data  

texel  data  

pixel  data  

parameter  data  (not  ARB  func<onality  yet)  

glBegin,  glDrawElements,  etc.  

glDrawPixels,  glTexImage2D,  etc.  

glReadPixels,  etc.  

Framebuffer  

Page 18: Casing3d opengl

pyopengl  

Page 19: Casing3d opengl

GLUT  Basics  

•  Applica?on  Structure  – Configure  and  open  window  –  Ini?alize  OpenGL  state  – Register  input  callback  func?ons  

•  render  •  resize  •  input:  keyboard,  mouse,  etc.  

– Enter  event  processing  loop  

19  

Page 20: Casing3d opengl

Hello,  World  from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * glutInit("Hello, World") glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB |GLUT_DEPTH) glutInitWindowSize(400,400) glutCreateWindow("Hello, World") glClearColor(0.,0.,0.,1.) glutSetDisplayFuncCallback(display) glutDisplayFunc() glutMainLoop()

©  2000  Richard  P.  Muller  

Page 21: Casing3d opengl

OpenGL  Geometric  Primi?ves  

•  All  geometric  primi?ves  are  specified  by  ver?ces  

21  

GL_QUAD_STRIP

GL_POLYGON

GL_TRIANGLE_STRIP GL_TRIANGLE_FAN

GL_POINTS

GL_LINES

GL_LINE_LOOP GL_LINE_STRIP

GL_TRIANGLES

GL_QUADS

Page 22: Casing3d opengl

Shapes  Tutorial  

22  

Page 23: Casing3d opengl

Qtopengl  from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * class Casing3DApp(QtGui.QWidget): class Casing3DGLWidget(QtOpenGL.QGLWidget): def initializeGL(self): def paintGL(self): def resizeGL(self, width, height): def mouseMoveEvent(self, event):

Page 24: Casing3d opengl

谢谢  


Recommended