350 likes | 648 Views
Ogre. [1] Ungeheuer n , Menschenfresser m http://dict.leo.org [2] Abk. f. O pen G L G r abb e r http://www.fh-karlsruhe.de/~juan0014. Thema. 3D-Screenshot. Inhalt. Technische Architektur OpenGL vs. VRML Geometrie Transformationen Material und Texturen Beleuchtung
E N D
Ogre [1] Ungeheuer n, Menschenfresser m http://dict.leo.org [2] Abk. f. OpenGL Grabber http://www.fh-karlsruhe.de/~juan0014
Thema 3D-Screenshot
Inhalt • Technische Architektur • OpenGL vs. VRML • Geometrie • Transformationen • Material und Texturen • Beleuchtung • OpenGL-Spezialitäten • Logging • Ausblick
Technische Architektur Anwendung opengl32.dll glu32.dll Treiber
Technische Architektur Anwendung opengl32.dll Ogre glu32.dll Treiber VRML
Technische Architektur • Anwendungsverzeichnis • Anwendung.exe • opengl32.dll (=Ogre) • Systemverzeichnis • opengl32.dll • glu32.dll
OpenGL vs. VRML Beispiel
Licht OpenGL vs. VRML VRML Welt Transformation Ansicht Form Material Textur Geometrie
OpenGL vs. VRML VRML #VRML V2.0 utf8 DirectionalLight { ambientIntensity 0.5 color 0.9 0.9 0.9 direction -100 -50 -100 } Transform { rotation 1 1 1 0.65 scale 2.5 2.5 2.5 children [ Shape { appearance Appearance { material Material { ambientIntensity 1 diffuseColor 1 0 0 emissiveColor 0 0 0 shininess 1 specularColor 1 1 1 } texture ImageTexture { url "IRTEX67B.jpg" repeatS TRUE repeatT TRUE } } geometry Box { size 2 2 2 } } ] }
OpenGL vs. VRML OpenGL glLight Licht glRotate Transformation glMaterial Material glTexImage2D Textur glNormal Geometrie glVertex
OpenGL vs. VRML OpenGL // lighting float diffuseLightColor[4] = {0.9f, 0.9f, 0.9f, 1.0f}; float ambientLightColor[4] = {0.45f, 0.45f, 0.45f, 1.0f); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLightColor); glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLightColor); // transformation glRotated(37.24, 1.0, 1.0, 1.0); // material float diffuseColor[4] = {1.0f, 0.0f, 0.0f, 0.0f}; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, diffuseColor); // texture glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); // geometry glBegin(GL_QUADS); glNormal3d(0.0, 0.0, -1.0); glTexCoord2d(0.0, 0.0); glVertex3d(-1.0, 1.0, -1.0); glTexCoord2d(0.0, 1.0); glVertex3d( 1.0, 1.0, -1.0); glTexCoord2d(1.0, 1.0); glVertex3d( 1.0, -1.0, -1.0); glTexCoord2d(1.0, 0.0); glVertex3d(-1.0, -1.0, -1.0); ... glEnd();
VRMLScene SceneState GLState OpenGL vs. VRML Klassenstruktur
Points Lines,Line strip,Line loop Polygon Triangles,Triangle strip,Triangle fan Quads,Quad strip Evaluators PointSet IndexedLineSet IndexedFaceSet [Box, Sphere, etc.] ElevationGrid Geometrie
VRMLScene Vertex Normal SceneState GLState Geometrie Klassenstruktur * * 1 1 1
VRMLLineStrip VRMLLineLoop VRMLLines VRMLPointSet VRMLPolygon VRMLTriangleStrip VRMLGeometry VRMLIndexed VRMLLineSet VRMLTriangleFan VRMLFaces VRMLTriangles VRMLQuadStrip VRMLQuads Geometrie Klassenstruktur
Geometrie Beispiel // geometry glBegin(GL_QUADS); glNormal3d(0.0, 0.0, -1.0); glVertex3d(-1.0, 1.0, -1.0); glVertex3d( 1.0, 1.0, -1.0); glVertex3d( 1.0, -1.0, -1.0); glVertex3d(-1.0, -1.0, -1.0); glNormal3d(0.0, 0.0, 1.0); glVertex3d(-1.0, -1.0, 1.0); glVertex3d( 1.0, -1.0, 1.0); glVertex3d( 1.0, 1.0, 1.0); glVertex3d(-1.0, 1.0, 1.0); ... glEnd(); geometry IndexedFaceSet { coord Coordinate { point [ -1 1 -1, 1 1 -1, 1 -1 -1, -1 -1 -1, -1 -1 1, 1 -1 1, 1 1 1, -1 1 1, ... ] } normal Normal { vector [ 0 0 -1, 0 0 -1, 0 0 -1, 0 0 -1, 0 0 1, 0 0 1, 0 0 1, 0 0 1, ... coordIndex [ 0 1 2 3 -1, 4 5 6 7 -1, ... ] }
Stack Modelview, Projection, Texture Baum Transform, Viewpoint, TextureTransform Transformationen
Skalierung Translation Rotation X Rotation Y Rotation X Transformationen Zerlegung einer Transformationsmatrix
BasicTransformation Transformation TransformationStack SceneState Modelview, Projection, Lights Transformationen Klassenstruktur * 1 * 1 10 1
Translation Transformationen Klassenstruktur BasicTransformation LoadIdentity MultIdentity SimpleTransformation MatrixTransformation Rotation Scale Frustum LoadMatrix MultMatrix Ortho
Transformationen Beispiel // transformation glRotated(37.24, 1.0, 1.0, 1.0); glScaled(2.5, 2.5, 2.5); glBegin(GL_QUADS); ... glEnd(); ... glPushMatrix(); glTranslated(-10.0, 20.0, 0.0); ... glPopMatrix(); ... Transform { rotation 1 1 1 0.65 children [ Transform { scale 2.5 2.5 2.5 children [ Shape { ... } ... Transform { translation -10 20 0 children [ ...
Unterscheidung nach Vorder- und Rückseite nicht-texturierte Glanzlichter Material und Texturen • Material: Ambient, Diffuse, Specular, Emission, Shininess • Farbe pro Eckpunkt
Multitexturing(Lightmaps, Bumpmapping, Environment Mapping, ...) Material und Texturen • Texturen und Texturkoordinaten
SceneState TexCoord GLState Color Ambient & Diffuse & Specular & Emissive (Front & Back), Vertex (if lighting is off), AmbientScene Texture2DParams Material und Texturen Klassenstruktur 1 * 1 * 10 1 *
Material und Texturen Beispiel Material // material float diffuseColor[4] = {1.0f, 0.0f, 0.0f, 0.0f}; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, diffuseColor); float specularColor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; glMaterialfv(GL_FRONT, GL_SPECULAR, specularColor); glMateriali(GL_FRONT, GL_SHININESS, 128); Shape { appearance Appearance { material Material { diffuseColor 1 0 0 ambientIntensity 1 specularColor 1 1 1 shininess 1 } } geometry IndexedFaceSet { ... } }
Material und Texturen Beispiel Texturen // texture glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); // geometry glBegin(GL_QUADS); glTexCoord2d(0.0, 0.0); glVertex3d(-1.0, 1.0, -1.0); glTexCoord2d(0.0, 1.0); glVertex3d( 1.0, 1.0, -1.0); glTexCoord2d(1.0, 1.0); glVertex3d( 1.0, -1.0, -1.0); glTexCoord2d(1.0, 0.0); glVertex3d(-1.0, -1.0, -1.0); ... glEnd(); Shape { appearance Appearance { texture ImageTexture { url "IRTEX67B.jpg" } } geometry IndexedFaceSet { coord Coordinate { point [ -1 1 -1, 1 1 -1, 1 -1 -1, -1 -1 -1, ... ] } coordIndex [ 0 1 2 3 -1, ... ] texCoord TextureCoordinate { point [ 0 0, 0 1, 1 1, 1 0, ... ] } } }
Ambientes Licht für gesamte Szene komplett verschiedene Beleuchtung pro Objekt Beleuchtung • PointLight, DirectionalLight, Spotlight • Parameter: Ambient, Diffuse, Specular, Spot, Attenuation
VRMLScene VRMLLight VRMLDirectionalLight VRMLPointLight SceneState VRMLSpotLight GLState LightParams Beleuchtung Klassenstruktur 1 8
Beleuchtung Beispiel // lighting float diffuseLightColor[4] = {0.9f, 0.9f, 0.9f, 1.0f}; float ambientLightColor[4] = {0.45f, 0.45f, 0.45f, 1.0f); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLightColor); glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLightColor); DirectionalLight { ambientIntensity 0.5 color 0.9 0.9 0.9 direction -100 -50 -100 }
_T _T _T, _T2 ProxyArray OpenGL-Spezialitäten Arrays glNormal3d(0.0, 0.0, -1.0); glTexCoord2d(0.0, 0.0); glVertex3d(-1.0, 1.0, -1.0); glTexCoord2d(0.0, 1.0); glVertex3d( 1.0, 1.0, -1.0); ... PseudoArray vs. glNormalPointer(...); glTexCoordPointer(...); glVertexPointer(...); glDrawArrays(...); glDrawElements(...); SequenceArray
glNewList(1, GL_COMPILE); glBegin(); ... glEnd(); DisplayList glEndList(); ... glCallList(); CommandStore OpenGL-Spezialitäten Display-Listen GLState 1 * 1 *
OpenGL-Spezialitäten GLU- und GLUT-Funktionen Extensions glu32.dll opengl32.dll glut.dll glGetString(GL_EXTENSIONS); Anwendung " ... GL_ARB_multitexture GL_EXT_abgr ... " opengl32.dll wglGetProcAddress ("glMultiTexCoord2fARB");
Debugging Lerneffekt 60 GB-Platten ausnutzen Logging Protokoll aller Funktionsaufrufe glBegin -- Return address: 0x00425B48 mode: GL_QUADS glTexCoord4d -- Return address: 0x0543DE36 s: 0.273438 t: 0.472656 r: 0 q: 1
Ausblick • Zusammenfassung:OpenGL rein, VRML raus • Lightmaps:VRML-Extensions / Nachberechnung • 2,5-D vs. 3-D:Transform & Lighting • Portierung (MacOS, Linux) • Robustheit • weitere Ausgabeformate • ...