11 – 3D Modeling for Games

11 – 3D Modeling for Games

CSc 165 Lecture Note Slides 11 - 3D Modeling For Games CSc 165 Computer Game Architecture Overview • Model Characteristics 11 – 3D Modeling • 3D Model File Formats for Games • Model Loaders • Digital Content Creation (DCC) Tools • Skinning and UV-unwrapping 2 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Models Static Data o 3D geometry (vertex data) o Polygon (face) data o Rendering attributes o Wireframe / Faceted / Smooth-shaded o Lighting & Materials o Texturing (“skinning”) data Animation Data (sometimes) o Model structure (skeletons, joints) o Model poses o Animation sequences o walk / run / jump / die … 3 4 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Common 3D Model File Formats .msdl – Manchester Scene Description Language .nff & .enff – (Extended) Neutral File Format .3ds – 3D Studio Max format .obj – Alias|Wavefront Object Files .blend – Blender format .off – 3D mesh Object File Format .dae – COLLADA Digital Asset Exchange format .oogl – Object Oriented Graphics Library .dem – USGS Standard for Digital Elevation Models .ply – Stanford Scanning Repository format .dxf – Autodesk's AutoCAD format .pov – Persistence of Vision ray-tracer .hdf – Hierarchical Data Format .qd3d – Apple's QuickDraw 3D metafile format .iges – Initial Graphics Exchange Specification .viz – used by Division's dVS/dVISE .iv – Open Inventor File Format Info .vrml – Virtual Reality Modeling Language .lwlo, .lwob & .lwsc – Lightwave 3D file formats .x – Microsoft’s DirectX/Direct3D file format .md2/.md3/.md4/.md5 – Quake Model Files .x3d – eXtensible 3D XML-based scene description format .ms3d – Milkshape 3D binary format See wikipedia – list of file formats 5 6 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games .OBJ File Commands .OBJ Example # File: ‘cube.obj’ # This file uses “OBJ” format to define a cube Vertex data Grouping # Define 8 cube vertices o v – geometric data o g – group name v -1.0 -1.0 -1.0 o vt – texture data o s – smoothing group v -1.0 -1.0 1.0 v -1.0 1.0 -1.0 o vn – vertex normals o mg – merging group v -1.0 1.0 1.0 o o – object name v 1.0 -1.0 -1.0 v 1.0 -1.0 1.0 Elements Render Attributes v 1.0 1.0 -1.0 o p – point o usemtl – material name v 1.0 1.0 1.0 o l – line o mtllib – material file name # Specify the file (library) containing materials o f – face o lod – level of detail mtllib cube.mtl o curv – curve o shadow_obj – shadow casting o surf – surface #continued... 7 8 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games OBJ Face/Vertex Data Structures Content Loaders in RAGE Faces Vertices <<interface>> Insert # File ‘man.obj’ Entity v -1.0 -1.0 -1.0 V2 Object in some <<interface>> Scenegraph 1 x y z MeshLoader v -1.0 -1.0 1.0 1 V4 specific file format v -1.0 1.0 -1.0 V3 + loadAsset(fileName) ... 2 x y z Model vt 0.72 0.32 V 1 File GenericEntity vt 0.86 0.33 3 x y z 2 V2 ... V5 vn 1.0 0.0 1.0 4 x y z WavefrontMeshLoader Create vn -1.0 0.0 0.5 Read + loadAsset(fileName) ... V3 5 x y z 3 <<interface>> f 2/1/1 4/2/1 3/3/2 V4 SubEntity V1 f 1/4/2 2/4/2 5/5/3 6 x y z Format-specific GenericSubEntity ... .. loader code - vertexBuffer - TexCoordBuffer - NormalsBuffer 9 10 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Example: .OBJ Content Loader Digital Content Creation (DCC) Tools public class WavefrontMeshLoader implements MeshLoader { ... public void loadAsset(Mesh mesh, Path path) { List<Float> verts = new ArrayList<>(); Too much work to do “by hand” List<Float> norms = new ArrayList<>(); List<Float> texcoords = new ArrayList<>(); BufferedReader br = Files.newBufferedReader(path); Model String line; Model in different format 1 while ((line = br.readLine()) != null) DCC File { if (line.startsWith(VERTEX_COMMAND)) commands { processVertexPositionCommand(line, verts); } Tool else if (line.startsWith(TEXTURE_COORD_COMMAND)) { processVertexTextureCommand(line, texcoords); } Model Model in different format 2 else if (line.startsWith(NORMAL_COMMAND)) File { processVertexNormalCommand(line, norms); } “Import” else if (line.startsWith(FACE_COMMAND)) { processVertexFaceCommand(line); } “Export” else if (line.startsWith(MATERIAL_COMMAND)) Scenegraph { materialLib = line.split(" ")[1]; } } SubMesh sm = mesh.createSubMesh(mesh.getName()); Model Content Entity createVertexBuffers(verts, norms, texcoords); File Loader sm.setVertexBuffer(toFloatBuffer(vertexPositionsList)); sm.setNormalBuffer(toFloatBuffer(vertexNormalsList)); sm.setTextureCoordBuffer(toFloatBuffer(vertexTexCoordsList)); sm.setIndexBuffer(toIntBuffer(vertexIndicesList)); } Model in Content-Loader format ... 11 12 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games DCC Tools Blender Features: Commercial . Modeling, texturing, lighting, UV-mapping . Animation rigging/skinning o Maya . Particle, physics, soft-body, fluid & cloth simulations o 3DStudio Max . Game engine, video post-processing o Lightwave . Python scripting/plugin support . Cross-platform (Windows, Linux, Mac OSX, FreeBSD, Solaris….) o etc., etc. … . Import/export for a wide variety of model file formats Free (or nearly) . Extensive online documentation/wiki support o Blender Availability: . Free (GNU GPL license), at http://www.blender.org o MilkShape3D o Maya / 3DStudio Max for students Tutorials: o etc. … . http://www.blender.org/support/tutorials 13 14 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Example Blender Models Basic Blender Controls Viewing: Object Manipulation (in object mode): • Scroll-wheel: zoom • RMB: select (SHIFT to add) • MMB: orbit (rotate 3D view) • A-key: toggle select-All • Shift-MMB: pan • B-key: activate border-selection (rubber-band select) • Reset view to Top: NUM-7 Front: NUM-1 Side: NUM-3 • DEL-key: delete selected • Z-key: toggle wireframe • LMB: position 3D cursor • NUM-0: switch to camera view • Shift-A: add object (at cursor loc) • NUM-5: toggle ortho/perspective view • Transform selection: • HOME: set view to show all objects R-key: rotate S-key: scale G-key: grab LMB to accept; RMB or ESC to cancel • Ctrl-Z: undo • Quick move: RMB on object, drag, • Ctrl-S: save workspace LMB to drop • Ctrl-N: reset (discard all; new session) • Shift-D: duplicate selection • F12: render (drag to reposition) • TAB: toggle object/edit mode 15 16 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Building Models From Primitives Model Exporting Most DCC tools export a variety of formats Blender supports exporting to: o Collada XML (“.dae”) o Wavefront OBJ (“.obj”) Original Cube Extrude Multiple Extrusions o Stanford Graphics Library (“.ply”) o 3DStudio Max (“.3ds”) o A host of others via “addons” . Including “OgreXML” RAGE has ModelLoaders for Scale Ends Scale Inner Add Bevels o OBJ and Smooth Surfaces o Model concept: The Essential Blender, RAGE Skeletal Animation (custom Blender exporter) Roland Hess, Blender Foundation 17 18 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Exporting Models Advanced Modeling: Sculpting # Blender3D v249 OBJ File: CrossDemo.blend # www.blender3d.org mtllib CrossDemo.mtl v 0.515410 2.745096 -0.496360 v 0.515410 2.745096 0.496359 v -0.477309 2.745096 0.496359 v -0.477309 2.745096 -0.496360 v 0.515410 3.737815 -0.496359 v 0.515410 3.737815 0.496360 v -0.477309 3.737815 0.496359 Original sphere “Add” brush “Grab” brush v -0.477309 3.737815 -0.496360 applied to Sphere v -0.523100 6.135959 0.542150 v -0.523100 6.135958 -0.542150 v 0.561200 6.135959 0.542150 Export: v 0.561201 6.135958 -0.542150 Ogre ...#total 44 vertices OBJ usemtl Material s 1 DAE f 2 6 7 f 5 1 4 f 12 10 9 f 13 14 15 f 1 42 44 f 21 24 44 ...#total 42 faces “Layer” brush “Inflate” brush “Texture” brush Images from: The Essential Blender, 19 20 Roland Hess, Blender Foundation CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Skinning Texture Space Subdivision Applying “texture” to 3D models Texturing meshes by dividing texture space: Problem: texture mapping is per-polygon: Models are collections of polygons Texture Map Polygon Mesh (1,1) Polygon Texture Map (0,0) v v u u 21 22 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Skinning Example Texture Subdivision Difficulties Requires creating a complex mapping (and the model is often curved) . How do we create the texture map? . How do we determine the correct mapping? Mapping texture locations to model coordinates Image credit: Practical Java Game Programming, Image credit: Practical Java Game Programming, Clingman et.al., Charles River Media Clingman et.al., Charles River Media 23 24 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Creating Texture Skins Example: Soup Can GIMP, PhotoShop, … . Create the model Soup Can Model (Cylinder) Create . Flatten the model (“UV Unwrapping”) Texture Unwrap Mark seams Image Cut along seams (“project”) . Save unwrapped (flattened) UV image . Save model with texture coordinates Model with Texture Coords Texture Image . Use UV image as a “pattern” to create tex map Texture GIMP, PhotoShop, ... Mapping . Apply texture map to model Image credit: 3D Game Programming All In One, 25 Kenneth Finney, Premier Press 26 CSc 165 Lecture Note Slides CSc 165 Lecture Note Slides 11 - 3D Modeling For Games 11 - 3D Modeling For Games Blender UV Unwrapping Character Models More complex, but same approach: .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us