.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BlenderImport 3pm" .TH BlenderImport 3pm "2000-01-30" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XRacer::BlenderImport \- Import files exported by xracer\-blenderexport.py .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XRacer::BlenderImport; \& \& $world = parse XRacer::BlenderImport [ $filename ]; \& \& $index = $world\->add_vertex ($vertex); \& $verticesref = $world\->get_vertices; \& %layerinfo = $world\->get_layer_info; \& \& @objects = $world\->get_meshes_in_layer ($layer); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`XRacer::BlenderImport\*(C'\fR module contains functions for importing special XRacer-specific Blender files into Perl scripts. These Blender files have been previously exported by the \&\f(CW\*(C`xracer\-blenderexport.py\*(C'\fR Python script for Blender. .PP The \f(CW\*(C`XRacer::BlenderImport\*(C'\fR module parses the \*(L"blender.export\*(R" file, cleans it up (removing multiple vertices, for example) and presents an internal \fIworld\fR representation. The world is divided into layers (corresponding to the layers in the original Blender image), and in each of these layers is a set of meshes. .SS "\s-1FUNDAMENTAL TYPES\s0" .IX Subsection "FUNDAMENTAL TYPES" Vertices are stored in a global list, so that common vertices are only stored once. A vertex structure looks like this: .PP .Vb 4 \& $vertex = { coords => [ $x, $y, $z, 0 ], \& texcoords => [ $u, $v ], \& normal => [ $nx, $ny, $nz, 0 ], \& colour => [ $r, $g, $b, $a ] }; .Ve .PP The fields are (in order): the coordinates of the vertex, the texture coordinates, the normal vector at this point and the colour of the vertex. .PP Faces are stored simply as a list of vertex indices (relative to the global list of vertices). A face looks like this: .PP .Vb 1 \& $face = { vertices => [ $index0, $index1, $index2, ... ] } .Ve .PP Faces have at least three vertices, and maybe more. .PP A mesh is a list of faces and additional information, such as the name of the mesh (object). A mesh structure looks like this: .PP .Vb 7 \& $mesh = { name => $name, \& layer => $layer, \& faces => \e@faces, \& material => [ $red, $green, $blue ], \& has_colours => $has_colours, \& has_texcoords => $has_texcoords, \& has_material => $has_material }; .Ve .PP The fields are: the name of the mesh (or object), the layer on which the object exists, the list of faces, the material and then three flags which are passed to us from Blender: did the user supply vertex colours? did the user supply texture coordinates? and did the user supply a material? .SH "CLASS METHODS" .IX Header "CLASS METHODS" .ie n .IP "$world = parse XRacer::BlenderImport [ $filename ];" 4 .el .IP "\f(CW$world\fR = parse XRacer::BlenderImport [ \f(CW$filename\fR ];" 4 .IX Item "$world = parse XRacer::BlenderImport [ $filename ];" Parse the import file \f(CW$filename\fR (or \*(L"blender.export\*(R" if no filename is given) and generate a \fIworld\fR representation. If the file could not be parsed, then this function will print an error message and return \f(CW\*(C`undef\*(C'\fR. .SH "OBJECT METHODS" .IX Header "OBJECT METHODS" .ie n .IP "$index = $world\->add_vertex ($vertex)" 4 .el .IP "\f(CW$index\fR = \f(CW$world\fR\->add_vertex ($vertex)" 4 .IX Item "$index = $world->add_vertex ($vertex)" This function adds a single vertex to the world object (vertices are stored in a large shared list so that common vertices are folded into one). It returns the vertex index of the new vertex. If another vertex with the same position, texture coordinates, normal and colour existed, then this function would return the index of the other vertex, rather than creating a fresh vertex object. .ie n .IP "$verticesref = $world\->get_vertices" 4 .el .IP "\f(CW$verticesref\fR = \f(CW$world\fR\->get_vertices" 4 .IX Item "$verticesref = $world->get_vertices" This returns a reference to the global list of vertices. You \&\fBmust not\fR update or change this list. Use the \f(CW\*(C`add_vertex\*(C'\fR method instead. .ie n .IP "%layerinfo = $world\->get_layer_info" 4 .el .IP "\f(CW%layerinfo\fR = \f(CW$world\fR\->get_layer_info" 4 .IX Item "%layerinfo = $world->get_layer_info" This method returns a hash. The \fIkeys\fR of the hash are layers which contain at least one object. The \fIvalues\fR of the hash are the number of objects in that layer. .Sp For example, if the world contained 3 objects on layer 1, 1 object on layer 2 and 4 objects on layer 5, then the hash returned would be equivalent to: .Sp .Vb 1 \& %layerinfo = ( 1 => 3, 2 => 1, 5 => 4 ); .Ve .ie n .IP "@objects = $world\->get_meshes_in_layer ($layer)" 4 .el .IP "\f(CW@objects\fR = \f(CW$world\fR\->get_meshes_in_layer ($layer)" 4 .IX Item "@objects = $world->get_meshes_in_layer ($layer)" Get a list of the objects (i.e. meshes) found in layer \f(CW$layer\fR. See the \s-1DESCRIPTION\s0 section above for a description of the mesh structure. .SH "AUTHOR" .IX Header "AUTHOR" .Vb 1 \& Richard W.M. Jones, .Ve .SH "COPYRIGHT" .IX Header "COPYRIGHT" XRacer is copyright (C) 1999\-2000 Richard W.M. Jones (rich@annexia.org) and other contributors listed in the \s-1AUTHORS\s0 file. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIperl\fR\|(1), \fIxracer\fR\|(6).