Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
Computer Graphics
Università dell’Insubria
Facoltà di Scienze MFN di Varese
Corso di Laurea in Informatica
LezioneLezioneLezioneLezione 10: 10: 10: 10: meshes
Marco Tarini
Corso di Laurea in Informatica
Anno Accademico 2010/11
Mesh triangolare (o mesh simpliciale)
• Un insieme di triangoli adiacenti
faccevertici
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
spigoli(o edges)
Altre mesh
• Mesh bidimensionali– Mesh di triangoli (o tri-mesh, o simpliciali)– Mesh di quadrilateri (o quad-mesh)– Mesh miste (quad e tri)
• Spesso, mesh prevalemtemente di quads (quad-dominant )– Mesh di poligoni
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
– Mesh di poligoni
• Mesh volumetriche– Mesh tetraedrali (o simpliciali 3D)– ...
Caratteristiche topologiche di una mesh
• Two Manifold ("varietà due") oppure no– in generale: two-manifold = localmente è una superficie– per le mesh:
two-manifold = ogni edge condiviso da max 2 faccie• two manifold = bene• non two manifold = male
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
• non two manifold = male• (molti algoritmi su mesh necessitano che sia two-manifold)
NONONONO SISISISI
Caratteristiche topologiche di una mesh
• Chiusa o aperta– se chiusa, ogni edge condiviso da 2 faccie– se aperta, alcuni edge sono di bordo
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Caratteristiche topologiche di una mesh
• Orientabile, non orientabile– è possibile assegnare un orientamento ad ogni
faccia coerentemente?– orientabile = normali coerenti!
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
1
23
1
23
senso opposto, edge coerente
A
BC
D
Caratteristiche topologiche di una mesh
• Orientabile, non orientabile– esempi di mesh non orientabili:
• mesh non two-manifold• e...
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Nastro di Moebius(non orientabile, aperta)
Bottiglia di Klein(non orientabile, chiusa)
Come definisco una mesh?
• Una mesh è un insieme di triangoli adiacenti• Strutture dati?• Modo diretto:
– un vettore di triangoli– e per ogni triangolo tre vertici
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
– e per ogni triangolo tre vertici– e per ogni vertice tre coordinate
• Ma: replicazione dati– poco efficiente in spazio– oneroso fare updates
Come definisco una mesh?• Modo indexedindexedindexedindexed
– Lista ordinata di vertici• per ogni vertice, la posizione
– Lista ordinata di facce• per ogni faccia, 3 indici di vertici
– Se serve: lista ordinata di edges
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
– Se serve: lista ordinata di edges• per ogni edge, 2 indici ai vertici
E gli attributi?
• Tipicamente definiti:– per vertice
• un attributo nella struttura di ogni vertice– per faccia
• un attributo nella struttura di ogni faccia– per wedge (vertice di faccia)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
– per wedge (vertice di faccia)• tre attributi nella struttura di ogni faccia (caso più generico!)
– per edge (raro)• Attributi più comuni:
– colore– coordinate texture– normali...
Formati files per mesh (una Torre di Babele!)
– 3DS - 3D Studio Max file format
– MA, MB – Maya file format
– 3DX – Rinoceros file format
– BLEND – Blender file format
– DAE – Collada file format
– OBJ –Another file format for 3D objects
– X – Direct X object
– BYU - Movie BYU file format
– DEM - Digital Elevation Models
– SLDPTR – SolidWork "part"
– WINGS – Wings3D object
– NFF - Used by Sense8's WorldToolKit
– OBJ - Wavefront Object Files
– OFF - A general 3D mesh Object File Format
– OOGL - Object Oriented Graphics Library
– PLG - Used by REND386/AVRIL
– POV - Persistence of Vision ray-tracer– QD3D - Apple's QuickDraw 3D Metafile format
– TDDD -
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
– DEM -– DXF – (exchange format used by Autodesk's AutoCAD)
– FIG - Used by REND386/AVRIL
– FLT - MulitGen Inc.'s OpenFlight format
– HDF - Hierarchical Data Format
– IGES - Initial Graphics Exchange Specification
– IV - Open Inventor File Format Info
– LWO, LWB & LWS - Lightwave 3D file formats
– MAZ - Used by Division's dVS/dVISE
– MGF - Materials and Geometry Format
– MSDL - Manchester Scene Description Language
– 3DML – by Flatland inc.
– C4D – Cinema 4D file format
– TDDD - for Imagine & Turbo Silver ray-tracers
– NFF & ENFF - (Extended) Neutral File Format
– VIZ - Used by Division's dVS/dVISE
– VRML - Virtual Reality Modeling Language
– VRML97 - ISO Specification di VRML
– X3D – successore di VRML
– PLY – Used by Cyberware
– DICOM – Dalla casa omonima
– Renderman – per l'omonimo visualizzatore
– RWX – RenderWare Object
– Z3D – ZModeler File format
– etc, etc, etc...
Esempio di file format : formato PLY
• E' un formato digitale per mesh superficiali• Può essere in binario, o in ASCII (testo)
– binario: più compatto e veloce da leggere– ascii: direttamente leggibile con un editore di testo
• In ogni caso, comincia con un header in ASCII
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
• In ogni caso, comincia con un header in ASCII
cubo.ply
Esempio di file format : formato PLY
• Esempio:ply
format ascii 1.0
comment proprio un cubetto
element vertex 8
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
element vertex 8
property float x
property float y
property float z
element face 12
property list uchar int vertex_indices
end_header
<dati...>
LetteraL.off
Esempio di file format : formato OFF
• Esempio:
1 5 10 5 14 3 2 1 04 5 4 3 0
OFF12 10 400 0 03 0 0
# vertici
# facce # edges
x,y,zprima faccia:4 vertici:
indice 0indice 1
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
4 5 4 3 04 6 7 8 94 6 9 10 114 0 1 7 64 1 2 8 74 2 3 9 84 3 4 10 94 4 5 11 104 5 0 6 11
3 0 03 1 01 1 01 5 00 5 00 0 13 0 13 1 11 1 1
x,y,z2ndo vert
4 vertici:con indici3, 2, 1 e 0
indice 3indice 2indice 1
Mesh editing: applicativi
• 3D Studio Max (autodesk) , Maya (alias) , Cinema4D (maxon)– generici, potenti, completi
• Blender– idem, ma open-source (stile: Gimp VS. Adobe Photoshop per 2D images)
• AutoCAD (autodesk), SolidWorks (SolidThinking) – per CAD
• ZBrush (pixologic) , Mudbox (autodesk)– scultura virtuale, specializzato in ritocco manuale dettagli hi-freq, bumpmapping, normalmaps…– scultura virtuale, specializzato in ritocco manuale dettagli hi-freq, bumpmapping, normalmaps…
• Wings3D– open-source, specializzato in low-poly editing, subdivision surfaces
• Rhinoceros– parametric surfaces (NURBS)
• MeshLab– open-source, grande collezione algoritmi di ritocco, trasformazione, cleaning, seplificaz, …
• …• + moltissimi strumenti per contesti specifici
– (editing di umani, di interni architetturali, di paesaggi, o editor specifici per game-engines, etc...)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Mesh editing: librerie
• VCG-Lib (CNR, it)
– Vision and Computer Graphic Lib• OpenMesh (RWTH, de)
• CGAL (~INRIA, fr)
– Computational Geometry Algorithms Library– Computational Geometry Algorithms Library
– tutte e tre: C++, open-suorce.
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Mesh: task comuni
• Data una mesh:– magari appena caricata
• trovare il AABB(axis aligned bounding box)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h i c s ‧ 2 0 1 0 / 1 1 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
(axis aligned bounding box)– utile ad esempio
per translare e scalarel'oggetto opportunamente
– come si fa?• (si itera sui vertici:
trovare il max e il mindi tutte le x, le y e le z)