Simplificando meshes

Junio 13, 2008

Para algunas aplicaciones se necesitan meshes con el mayor numero de vertices y caras para mostrar detalle.  Para otras no se necesita tanto, por ejemplo aplicaciones en tiempo real, colisiones, etc.  “Qslim” es uno de los algoritmos más usados ya que reduce los meshes de triangulas rapidamente y sin perder detalles hasta que se simplifica demasiado.

Pude compilar la version de linea de comandos en MacOS X leopard, pero no la version de interface grafica.  http://graphics.cs.uiuc.edu/~garland/software/qslim.html

  • Michael Garland and Paul S. Heckbert, Surface Simplification Using Quadric Error Metrics, in Proceedings of SIGGARPH’97, pp. 209-216, 1997.

For more accurate results, NSA (Normal-Based Simplification Algorithm for Meshes) can be used as well

http://www.di.ubi.pt/~fsilva/nsa/


Rigid Body Collision and how to make a Distance Field from Triangle mesh

Febrero 14, 2008

“Non-convex rigid bodies with stacking” by Eran Guendelman, Robert Bridson and Ronald Fedkiw
http://www.rowlhouse.co.uk/jiggle/index.html

Generating Signed Distance Fields From Triangle , J. Andreas Bærentzen and Henrik Aanæs

http://www-cs-students.stanford.edu/~eparker/files/PhysicsEngine/


Voxelization of Geometric Objects

Febrero 14, 2008

The vxf library for voxelization, described in “Alias-free Voxelization og Geometric Objects” by M. Sarmek and A. E. Kaufman, can be found under GPL at:

http://www.cs.sunysb.edu/~vislab/vxtools/

Distance to triangle code, by Geometric Tools Inc. (alias Magic Software)

http://www.geometrictools.com/LibFoundation/Distance/Distance.html


Ray-Triangle intersection

Enero 18, 2008

http://www.softsurfer.com/Archive/algorithm_0105/algorithm_0105.htm

See also Moller Trumbore 1997

Codigo C++ 

Mas Codigos C++


Obj Loader

Enero 18, 2008

http://www.cs.rpi.edu/~cutler/classes/advancedgraphics/S07/hw2_meshes.html

(Provided Files)


Linux Free Games

Octubre 31, 2007

Import OBJ Sequence MEL Script

Septiembre 9, 2007

global proc objSequence(string $path, string $fileName, string $objectName, int $frameStart, int $frameEnd, int $repeats){

int $i=1;
for($i=$frameStart;$i<=$frameEnd;$i++){
//String concatenation uses +
string $name=($path+”/”+$fileName+”_”+$i+”.obj”);
file -import -type “OBJ” -namespace “mesh” -options “mo=1″ -pr $name;
}

//Make Visible one per frame frame
//set time to 1 frame
float $myTime=1;//`currentTime -query`;
currentTime  $myTime -update no;

for($i=$frameStart;$i<=$frameEnd;$i++){
//Set Key Frames
setAttr ($objectName+”_”+$i+”.visibility”) off;
setKeyframe  ($objectName+”_”+$i+”.visibility”);
$myTime++;
currentTime  $myTime -update no;
setAttr ($objectName+”_”+$i+”.visibility”) on;
setKeyframe  ($objectName+”_”+$i+”.visibility”);
//Make invisible previus one
if($i!=$frameStart){  //if not the first one
setAttr ($objectName+”_”+($i-1)+”.visibility”) off;
setKeyframe  ($objectName+”_”+($i-1)+”.visibility”);
}
}

}

//usar:  objSequence(”meshes/”,”mesh”,”mesh”,1,30,0);


writeOBJFile (Writes an OBJ file)

Septiembre 8, 2007

void Mesh::writeOBJ(ostream& os)
{
os << “# mesh?.obj” << endl;
os << “#” << endl;
os << endl;
os << “g mesh” << endl;
os << endl;

int numVertices = (int)vertices.size();
for (int i = 0; i < numVertices; ++i)
{
os << “v ” << vertices[i][0] << ‘ ‘ << vertices[i][1] << ‘ ‘ << vertices[i][2] << endl;
}
os << endl;

for (int i = 0; i < numVertices; ++i)
{
os << “vn ” << vNormals[i][0] << ‘ ‘ << vNormals[i][1] << ‘ ‘ << vNormals[i][2] << endl;
}
os << endl;

int numFaces = (int) faces.size();
//out << “\t\t” << numFaces << “,” << endl;
for (int i = 0; i < numFaces; ++i)
{
int f1 = faces[i][0]+1;
int f2 = faces[i][1]+1;
int f3 = faces[i][2]+1;

os << “f ” << f1 << “//” << f1 << ‘ ‘ << f2 << “//” << f2 << ‘ ‘ << f3 << “//” << f3 << endl;
}
os << endl;

}


Cube.OBJ

Septiembre 4, 2007

[sourcecode]
# cube.obj
#

g cube

v 0.0 0.0 0.0
v 0.0 0.0 1.0
v 0.0 1.0 0.0
v 0.0 1.0 1.0
v 1.0 0.0 0.0
v 1.0 0.0 1.0
v 1.0 1.0 0.0
v 1.0 1.0 1.0

vn 0.0 0.0 1.0
vn 0.0 0.0 -1.0
vn 0.0 1.0 0.0
vn 0.0 -1.0 0.0
vn 1.0 0.0 0.0
vn -1.0 0.0 0.0

f 1//2 7//2 5//2
f 1//2 3//2 7//2
f 1//6 4//6 3//6
f 1//6 2//6 4//6
f 3//3 8//3 7//3
f 3//3 4//3 8//3
f 5//5 7//5 8//5
f 5//5 8//5 6//5
f 1//4 5//4 6//4
f 1//4 6//4 2//4
f 2//1 6//1 8//1
f 2//1 8//1 4//1
[/sourcecode]
Has to be in windows format (even on Mac). Open with Maya (for example).


AVI to DPG video in ubuntu (to play videos on a Nintendo DS)

Julio 15, 2007

Install mencoder, mplayer from Synaptic.

Download ucbmpeg

http://ftp.interlegis.gov.br/pub/ubuntu/archive/pool/multiverse/u/ucbmpeg/

Compile mpeg_stats (needs libc6-dev)

optional, copy mpeg_stats to /bin

download dpgconv python script

http://theli.ho.com.ua/dpgconv/index.html

make it executable:

chmod -x dpgconv.py

use it (python should be installed):

dpgconv.py myavi.avi