1 /* -----------------------------------------------------------------------------
5 Copyright (c) 2002, Randy Reddig & seaw0lf
8 Redistribution and use in source and binary forms, with or without modification,
9 are permitted provided that the following conditions are met:
11 Redistributions of source code must retain the above copyright notice, this list
12 of conditions and the following disclaimer.
14 Redistributions in binary form must reproduce the above copyright notice, this
15 list of conditions and the following disclaimer in the documentation and/or
16 other aseMaterialList provided with the distribution.
18 Neither the names of the copyright holders nor the names of its contributors may
19 be used to endorse or promote products derived from this software without
20 specific prior written permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ----------------------------------------------------------------------------- */
39 /* uncomment when debugging this module */
40 //#define DEBUG_PM_ASE
41 //#define DEBUG_PM_ASE_EX
45 #include "picointernal.h"
52 static picoColor_t white = { 255, 255, 255, 255 };
54 /* jhefty - multi-subobject material support */
56 /* Material/SubMaterial management */
57 /* A material should have 1..n submaterials assigned to it */
59 typedef struct aseSubMaterial_s
61 struct aseSubMaterial_s* next;
67 typedef struct aseMaterial_s
69 struct aseMaterial_s* next;
70 struct aseSubMaterial_s* subMtls;
74 /* Material/SubMaterial management functions */
75 static aseMaterial_t* _ase_get_material ( aseMaterial_t* list , int mtlIdParent )
77 aseMaterial_t* mtl = list;
81 if ( mtlIdParent == mtl->mtlId )
90 static aseSubMaterial_t* _ase_get_submaterial ( aseMaterial_t* list, int mtlIdParent , int subMtlId )
92 aseMaterial_t* parent = _ase_get_material ( list , mtlIdParent );
93 aseSubMaterial_t* subMtl = NULL;
97 _pico_printf ( PICO_ERROR , "No ASE material exists with id %i\n" , mtlIdParent );
101 subMtl = parent->subMtls;
104 if ( subMtlId == subMtl->subMtlId )
108 subMtl = subMtl->next;
113 static aseMaterial_t* _ase_add_material( aseMaterial_t **list, int mtlIdParent )
115 aseMaterial_t *mtl = _pico_calloc( 1, sizeof( aseMaterial_t ) );
116 mtl->mtlId = mtlIdParent;
124 static aseSubMaterial_t* _ase_add_submaterial( aseMaterial_t **list, int mtlIdParent, int subMtlId, picoShader_t* shader )
126 aseMaterial_t *parent = _ase_get_material( *list, mtlIdParent );
127 aseSubMaterial_t *subMtl = _pico_calloc( 1, sizeof ( aseSubMaterial_t ) );
131 parent = _ase_add_material ( list , mtlIdParent );
134 subMtl->shader = shader;
135 subMtl->subMtlId = subMtlId;
136 subMtl->next = parent->subMtls;
137 parent->subMtls = subMtl;
142 static void _ase_free_materials( aseMaterial_t **list )
144 aseMaterial_t* mtl = *list;
145 aseSubMaterial_t* subMtl = NULL;
147 aseMaterial_t* mtlTemp = NULL;
148 aseSubMaterial_t* subMtlTemp = NULL;
152 subMtl = mtl->subMtls;
155 subMtlTemp = subMtl->next;
156 _pico_free ( subMtl );
167 static void _ase_print_materials( aseMaterial_t *list )
169 aseMaterial_t* mtl = list;
170 aseSubMaterial_t* subMtl = NULL;
174 _pico_printf ( PICO_NORMAL , "ASE Material %i" , mtl->mtlId );
175 subMtl = mtl->subMtls;
178 _pico_printf ( PICO_NORMAL , " -- ASE SubMaterial %i - %s\n" , subMtl->subMtlId , subMtl->shader->name );
179 subMtl = subMtl->next;
184 #endif //DEBUG_PM_ASE
186 /* ASE Face management */
187 /* These are used to keep an association between a submaterial and a face definition */
188 /* They are kept in parallel with the current picoSurface, */
189 /* and are used by _ase_submit_triangles to lookup the proper material/submaterial IDs */
190 typedef struct aseFace_s
192 struct aseFace_s* next;
198 /* ASE Face management functions */
199 void _ase_add_face( aseFace_t **list, aseFace_t **tail, aseFace_t *newFace )
201 aseFace_t* face = *list;
202 aseFace_t* tempFace = NULL;
204 /* insert as head of list */
211 (*tail)->next = newFace;
215 newFace->next = NULL;
217 //tag the color indices so we can detect them and apply the default color to them
218 newFace->index[6] = -1;
219 newFace->index[7] = -1;
220 newFace->index[8] = -1;
223 aseFace_t* _ase_get_face_for_index( aseFace_t *list, int index )
226 aseFace_t* face = list;
228 while ( counter < index )
235 static void _ase_free_faces (aseFace_t** list, aseFace_t** tail )
237 aseFace_t* face = *list;
238 aseFace_t* tempFace = NULL;
242 tempFace = face->next;
252 * - apply material specific uv offsets to uv coordinates
256 * validates a 3dsmax ase model file.
258 static int _ase_canload( PM_PARAMS_CANLOAD )
263 /* quick data length validation */
265 return PICO_PMV_ERROR_SIZE;
267 /* keep the friggin compiler happy */
268 *fileName = *fileName;
270 /* create pico parser */
271 p = _pico_new_parser( (picoByte_t*) buffer, bufSize );
273 return PICO_PMV_ERROR_MEMORY;
275 /* get first token */
276 if( _pico_parse_first( p ) == NULL)
278 return PICO_PMV_ERROR_IDENT;
281 /* check first token */
282 if( _pico_stricmp( p->token, "*3dsmax_asciiexport" ) )
284 _pico_free_parser( p );
285 return PICO_PMV_ERROR_IDENT;
288 /* free the pico parser object */
289 _pico_free_parser( p );
291 /* file seems to be a valid ase file */
297 /* _ase_submit_triangles - jhefty
298 use the surface and the current face list to look up material/submaterial IDs
299 and submit them to the model for proper processing
301 The following still holds from ydnar's _ase_make_surface:
302 indexes 0 1 2 = vert indexes
303 indexes 3 4 5 = st indexes
304 indexes 6 7 8 = color indexes (new)
307 static void _ase_submit_triangles ( picoSurface_t* surface , picoModel_t* model , aseMaterial_t* materials , aseFace_t* faces )
310 aseSubMaterial_t* subMtl;
312 picoVec3_t* normal[3];
314 picoColor_t* color[3];
318 while ( face != NULL )
320 /* look up the shader for the material/submaterial pair */
321 subMtl = _ase_get_submaterial( materials, face->mtlId, face->subMtlId );
324 /* ydnar: trying default submaterial */
325 subMtl = _ase_get_submaterial( materials, face->mtlId, 0 );
328 _pico_printf( PICO_ERROR, "Could not find material/submaterial for id %d/%d\n", face->mtlId, face->subMtlId );
333 /* we pull the data from the surface using the facelist data */
334 for ( i = 0 ; i < 3 ; i ++ )
336 xyz[i] = (picoVec3_t*) PicoGetSurfaceXYZ ( surface, face->index[ i ] );
337 normal[i] = (picoVec3_t*) PicoGetSurfaceNormal( surface, face->index[ i ] );
338 st[i] = (picoVec2_t*) PicoGetSurfaceST ( surface, 0, face->index[ i + 3 ] );
340 if ( face->index [ i + 6] >= 0 )
342 color[i] = (picoColor_t*)PicoGetSurfaceColor ( surface, 0, face->index[ i + 6 ] );
351 /* submit the triangle to the model */
352 PicoAddTriangleToModel ( model , xyz , normal , 1 , st , 1 , color , subMtl->shader );
354 /* advance to the next face */
360 * loads a 3dsmax ase model file.
362 static picoModel_t *_ase_load( PM_PARAMS_LOAD )
365 picoSurface_t *surface = NULL;
367 char lastNodeName[ 1024 ];
369 aseFace_t* faces = NULL;
370 aseFace_t* facesTail = NULL;
371 aseMaterial_t* materials = NULL;
374 clock_t start, finish;
380 #define _ase_error_return(m) \
382 _pico_printf( PICO_ERROR,"%s in ASE, line %d.",m,p->curLine); \
383 _pico_free_parser( p ); \
384 PicoFreeModel( model ); \
387 /* create a new pico parser */
388 p = _pico_new_parser( (picoByte_t *)buffer,bufSize );
389 if (p == NULL) return NULL;
391 /* create a new pico model */
392 model = PicoNewModel();
395 _pico_free_parser( p );
399 PicoSetModelFrameNum( model, frameNum );
400 PicoSetModelName( model, fileName );
401 PicoSetModelFileName( model, fileName );
403 /* initialize some stuff */
404 memset( lastNodeName,0,sizeof(lastNodeName) );
406 /* parse ase model file */
409 /* get first token on line */
410 if (_pico_parse_first( p ) == NULL)
413 /* we just skip empty lines */
414 if (p->token == NULL || !strlen( p->token ))
417 /* we skip invalid ase statements */
418 if (p->token[0] != '*' && p->token[0] != '{' && p->token[0] != '}')
420 _pico_parse_skip_rest( p );
423 /* remember node name */
424 if (!_pico_stricmp(p->token,"*node_name"))
427 char *ptr = _pico_parse( p,0 );
429 _ase_error_return("Node name parse error");
431 /* remember node name */
432 strncpy( lastNodeName,ptr,sizeof(lastNodeName) );
434 /* model mesh (originally contained within geomobject) */
435 else if (!_pico_stricmp(p->token,"*mesh"))
437 /* finish existing surface */
438 //_ase_make_surface( model, &surface );
439 _ase_submit_triangles (surface, model ,materials,faces);
440 _ase_free_faces (&faces,&facesTail);
442 /* allocate new pico surface */
443 surface = PicoNewSurface( NULL );
446 PicoFreeModel( model );
450 /* mesh material reference. this usually comes at the end of */
451 /* geomobjects after the mesh blocks. we must assume that the */
452 /* new mesh was already created so all we can do here is assign */
453 /* the material reference id (shader index) now. */
454 else if (!_pico_stricmp(p->token,"*material_ref"))
459 /* we must have a valid surface */
460 if( surface == NULL )
461 _ase_error_return("Missing mesh for material reference");
463 /* get the material ref (0..n) */
464 if (!_pico_parse_int( p,&mtlId) )
465 _ase_error_return("Missing material reference ID");
467 /* fix up all of the aseFaceList in the surface to point to the parent material */
468 /* we've already saved off their subMtl */
470 while ( face != NULL )
476 /* model mesh vertex */
477 else if (!_pico_stricmp(p->token,"*mesh_vertex"))
482 /* we must have a valid surface */
483 if( surface == NULL )
486 /* get vertex data (orig: index +y -x +z) */
487 if (!_pico_parse_int( p,&index ))
488 _ase_error_return("Vertex parse error");
489 if (!_pico_parse_vec( p,v ))
490 _ase_error_return("Vertex parse error");
493 PicoSetSurfaceXYZ( surface,index,v );
495 /* model mesh vertex normal */
496 else if (!_pico_stricmp(p->token,"*mesh_vertexnormal"))
501 /* we must have a valid surface */
502 if( surface == NULL )
505 /* get vertex data (orig: index +y -x +z) */
506 if (!_pico_parse_int( p,&index ))
507 _ase_error_return("Vertex parse error");
508 if (!_pico_parse_vec( p,v ))
509 _ase_error_return("Vertex parse error");
512 PicoSetSurfaceNormal( surface,index,v );
514 /* model mesh face */
515 else if (!_pico_stricmp(p->token,"*mesh_face"))
517 picoIndex_t indexes[3];
520 /* we must have a valid surface */
521 if( surface == NULL )
525 if (!_pico_parse_int( p,&index ))
526 _ase_error_return("Face parse error");
528 /* get 1st vertex index */
530 if (!_pico_parse_int( p,&indexes[0] ))
531 _ase_error_return("Face parse error");
533 /* get 2nd vertex index */
535 if (!_pico_parse_int( p,&indexes[1] ))
536 _ase_error_return("Face parse error");
538 /* get 3rd vertex index */
540 if (!_pico_parse_int( p,&indexes[2] ))
541 _ase_error_return("Face parse error");
543 /* set face indexes (note interleaved offset!) */
544 PicoSetSurfaceIndex( surface, (index * 9 + 0), indexes[2] );
545 PicoSetSurfaceIndex( surface, (index * 9 + 1), indexes[1] );
546 PicoSetSurfaceIndex( surface, (index * 9 + 2), indexes[0] );
548 /* parse to the subMaterial ID */
552 if (!_pico_stricmp (p->token,"*MESH_MTLID" ))
557 _pico_parse_int ( p , &subMtlId );
558 newFace = _pico_calloc ( 1 , sizeof ( aseFace_t ));
560 /* we fix up the mtlId later when we parse the material_ref */
562 newFace->subMtlId = subMtlId;
563 newFace->index[0] = indexes[2];
564 newFace->index[1] = indexes[1];
565 newFace->index[2] = indexes[0];
567 _ase_add_face ( &faces,&facesTail,newFace );
573 /* model texture vertex */
574 else if (!_pico_stricmp(p->token,"*mesh_tvert"))
579 /* we must have a valid surface */
580 if( surface == NULL )
583 /* get uv vertex index */
584 if (!_pico_parse_int( p,&index ))
585 _ase_error_return("UV vertex parse error");
587 /* get uv vertex s */
588 if (!_pico_parse_float( p,&uv[0] ))
589 _ase_error_return("UV vertex parse error");
591 /* get uv vertex t */
592 if (!_pico_parse_float( p,&uv[1] ))
593 _ase_error_return("UV vertex parse error");
595 /* ydnar: invert t */
596 uv[ 1 ] = 1.0f - uv[ 1 ];
598 /* set texture vertex */
599 PicoSetSurfaceST( surface,0,index,uv );
601 /* ydnar: model mesh texture face */
602 else if( !_pico_stricmp( p->token, "*mesh_tface" ) )
604 picoIndex_t indexes[3];
608 /* we must have a valid surface */
609 if( surface == NULL )
613 if (!_pico_parse_int( p,&index ))
614 _ase_error_return("Texture face parse error");
616 /* get 1st vertex index */
617 if (!_pico_parse_int( p,&indexes[0] ))
618 _ase_error_return("Texture face parse error");
620 /* get 2nd vertex index */
621 if (!_pico_parse_int( p,&indexes[1] ))
622 _ase_error_return("Texture face parse error");
624 /* get 3rd vertex index */
625 if (!_pico_parse_int( p,&indexes[2] ))
626 _ase_error_return("Texture face parse error");
628 /* set face indexes (note interleaved offset!) */
629 PicoSetSurfaceIndex( surface, (index * 9 + 3), indexes[2] );
630 PicoSetSurfaceIndex( surface, (index * 9 + 4), indexes[1] );
631 PicoSetSurfaceIndex( surface, (index * 9 + 5), indexes[0] );
633 face = _ase_get_face_for_index(faces,index);
634 face->index[3] = indexes[2];
635 face->index[4] = indexes[1];
636 face->index[5] = indexes[0];
638 /* model color vertex */
639 else if (!_pico_stricmp(p->token,"*mesh_vertcol"))
645 /* we must have a valid surface */
646 if( surface == NULL )
649 /* get color vertex index */
650 if (!_pico_parse_int( p,&index ))
651 _ase_error_return("UV vertex parse error");
653 /* get R component */
654 if (!_pico_parse_float( p,&colorInput ))
655 _ase_error_return("color vertex parse error");
656 color[0] = (picoByte_t)(colorInput * 255);
658 /* get G component */
659 if (!_pico_parse_float( p,&colorInput ))
660 _ase_error_return("color vertex parse error");
661 color[1] = (picoByte_t)(colorInput * 255);
663 /* get B component */
664 if (!_pico_parse_float( p,&colorInput ))
665 _ase_error_return("color vertex parse error");
666 color[2] = (picoByte_t)(colorInput * 255);
668 /* leave alpha alone since we don't get any data from the ASE format */
671 /* set texture vertex */
672 PicoSetSurfaceColor( surface,0,index,color );
674 /* model color face */
675 else if (!_pico_stricmp(p->token,"*mesh_cface"))
677 picoIndex_t indexes[3];
681 /* we must have a valid surface */
682 if( surface == NULL )
686 if (!_pico_parse_int( p,&index ))
687 _ase_error_return("Face parse error");
689 /* get 1st cvertex index */
690 // _pico_parse( p,0 );
691 if (!_pico_parse_int( p,&indexes[0] ))
692 _ase_error_return("Face parse error");
694 /* get 2nd cvertex index */
695 // _pico_parse( p,0 );
696 if (!_pico_parse_int( p,&indexes[1] ))
697 _ase_error_return("Face parse error");
699 /* get 3rd cvertex index */
700 // _pico_parse( p,0 );
701 if (!_pico_parse_int( p,&indexes[2] ))
702 _ase_error_return("Face parse error");
704 /* set face indexes (note interleaved offset!) */
705 PicoSetSurfaceIndex( surface, (index * 9 + 6), indexes[2] );
706 PicoSetSurfaceIndex( surface, (index * 9 + 7), indexes[1] );
707 PicoSetSurfaceIndex( surface, (index * 9 + 8), indexes[0] );
709 face = _ase_get_face_for_index(faces,index);
710 face->index[6] = indexes[2];
711 face->index[7] = indexes[1];
712 face->index[8] = indexes[0];
715 else if( !_pico_stricmp( p->token, "*material" ) )
717 aseSubMaterial_t* subMaterial = NULL;
718 picoShader_t *shader;
719 int level = 1, index;
720 char materialName[ 1024 ];
721 float transValue = 0.0f, shineValue = 1.0f;
722 picoColor_t ambientColor, diffuseColor, specularColor;
723 char *mapname = NULL;
724 int subMtlId, subMaterialLevel = -1;
727 /* get material index */
728 _pico_parse_int( p,&index );
731 if (!_pico_parse_check(p,1,"{"))
732 _ase_error_return("Material missing opening brace");
734 /* parse material block */
738 if (_pico_parse(p,1) == NULL) break;
739 if (!strlen(p->token)) continue;
742 if (p->token[0] == '{') level++;
743 if (p->token[0] == '}') level--;
746 if( level == subMaterialLevel )
748 /* set material name */
749 PicoSetShaderName( shader, materialName);
751 /* set shader's transparency */
752 PicoSetShaderTransparency( shader,transValue );
754 /* set shader's ambient color */
755 PicoSetShaderAmbientColor( shader,ambientColor );
757 /* set diffuse alpha to transparency */
758 diffuseColor[3] = (picoByte_t)( transValue * 255.0 );
760 /* set shader's diffuse color */
761 PicoSetShaderDiffuseColor( shader,diffuseColor );
763 /* set shader's specular color */
764 PicoSetShaderSpecularColor( shader,specularColor );
766 /* set shader's shininess */
767 PicoSetShaderShininess( shader,shineValue );
769 /* set material map name */
770 PicoSetShaderMapName( shader, mapname );
772 subMaterial = _ase_add_submaterial( &materials, index, subMtlId, shader );
773 subMaterialLevel = -1;
776 /* parse submaterial index */
777 if (!_pico_stricmp(p->token,"*submaterial"))
779 /* allocate new pico shader */
780 _pico_parse_int( p , &subMtlId );
782 shader = PicoNewShader( model );
785 PicoFreeModel( model );
788 subMaterialLevel = level;
790 /* parse material name */
791 else if (!_pico_stricmp(p->token,"*material_name"))
793 char* name = _pico_parse(p,0);
795 _ase_error_return("Missing material name");
797 strcpy ( materialName , name );
798 /* skip rest and continue with next token */
799 _pico_parse_skip_rest( p );
802 /* parse material transparency */
803 else if (!_pico_stricmp(p->token,"*material_transparency"))
805 /* get transparency value from ase */
806 if (!_pico_parse_float( p,&transValue ))
807 _ase_error_return("Material transparency parse error");
809 /* skip rest and continue with next token */
810 _pico_parse_skip_rest( p );
813 /* parse material shininess */
814 else if (!_pico_stricmp(p->token,"*material_shine"))
817 * - not sure but instead of '*material_shine' i might
818 * need to use '*material_shinestrength' */
820 /* get shine value from ase */
821 if (!_pico_parse_float( p,&shineValue ))
822 _ase_error_return("Material shine parse error");
824 /* scale ase shine range 0..1 to pico range 0..127 */
827 /* skip rest and continue with next token */
828 _pico_parse_skip_rest( p );
831 /* parse ambient material color */
832 else if (!_pico_stricmp(p->token,"*material_ambient"))
835 /* get r,g,b float values from ase */
836 if (!_pico_parse_vec( p,vec ))
837 _ase_error_return("Material color parse error");
839 /* setup 0..255 range color values */
840 ambientColor[ 0 ] = (int)( vec[ 0 ] * 255.0 );
841 ambientColor[ 1 ] = (int)( vec[ 1 ] * 255.0 );
842 ambientColor[ 2 ] = (int)( vec[ 2 ] * 255.0 );
843 ambientColor[ 3 ] = (int)( 255 );
845 /* skip rest and continue with next token */
846 _pico_parse_skip_rest( p );
849 /* parse diffuse material color */
850 else if (!_pico_stricmp(p->token,"*material_diffuse"))
854 /* get r,g,b float values from ase */
855 if (!_pico_parse_vec( p,vec ))
856 _ase_error_return("Material color parse error");
858 /* setup 0..255 range color */
859 diffuseColor[ 0 ] = (int)( vec[ 0 ] * 255.0 );
860 diffuseColor[ 1 ] = (int)( vec[ 1 ] * 255.0 );
861 diffuseColor[ 2 ] = (int)( vec[ 2 ] * 255.0 );
862 diffuseColor[ 3 ] = (int)( 255 );
864 /* skip rest and continue with next token */
865 _pico_parse_skip_rest( p );
868 /* parse specular material color */
869 else if (!_pico_stricmp(p->token,"*material_specular"))
873 /* get r,g,b float values from ase */
874 if (!_pico_parse_vec( p,vec ))
875 _ase_error_return("Material color parse error");
877 /* setup 0..255 range color */
878 specularColor[ 0 ] = (int)( vec[ 0 ] * 255 );
879 specularColor[ 1 ] = (int)( vec[ 1 ] * 255 );
880 specularColor[ 2 ] = (int)( vec[ 2 ] * 255 );
881 specularColor[ 3 ] = (int)( 255 );
883 /* skip rest and continue with next token */
884 _pico_parse_skip_rest( p );
887 /* material diffuse map */
888 else if (!_pico_stricmp(p->token,"*map_diffuse") )
892 /* parse material block */
896 if (_pico_parse(p,1) == NULL) break;
897 if (!strlen(p->token)) continue;
900 if (p->token[0] == '{') sublevel++;
901 if (p->token[0] == '}') sublevel--;
902 if (!sublevel) break;
904 /* parse diffuse map bitmap */
905 if (!_pico_stricmp(p->token,"*bitmap"))
907 char* name = _pico_parse(p,0);
909 _ase_error_return("Missing material map bitmap name");
910 mapname = _pico_alloc ( strlen ( name ) + 1 );
911 strcpy ( mapname, name );
912 /* skip rest and continue with next token */
913 _pico_parse_skip_rest( p );
918 /* end map_diffuse block */
920 /* end material block */
922 if( subMaterial == NULL )
924 /* allocate new pico shader */
925 shader = PicoNewShader( model );
928 PicoFreeModel( model );
932 /* set material name */
933 PicoSetShaderName( shader,materialName );
935 /* set shader's transparency */
936 PicoSetShaderTransparency( shader,transValue );
938 /* set shader's ambient color */
939 PicoSetShaderAmbientColor( shader,ambientColor );
941 /* set diffuse alpha to transparency */
942 diffuseColor[3] = (picoByte_t)( transValue * 255.0 );
944 /* set shader's diffuse color */
945 PicoSetShaderDiffuseColor( shader,diffuseColor );
947 /* set shader's specular color */
948 PicoSetShaderSpecularColor( shader,specularColor );
950 /* set shader's shininess */
951 PicoSetShaderShininess( shader,shineValue );
953 /* set material map name */
954 PicoSetShaderMapName( shader, mapname );
956 /* this is just a material with 1 submaterial */
957 subMaterial = _ase_add_submaterial( &materials, index, 0, shader );
960 /* ydnar: free mapname */
961 if( mapname != NULL )
962 _pico_free( mapname );
963 } // !_pico_stricmp ( "*material" )
965 /* skip unparsed rest of line and continue */
966 _pico_parse_skip_rest( p );
969 /* ydnar: finish existing surface */
970 // _ase_make_surface( model, &surface );
971 _ase_submit_triangles (surface, model ,materials,faces);
972 _ase_free_faces (&faces,&facesTail);
975 _ase_print_materials(materials);
977 elapsed = (double)(finish - start) / CLOCKS_PER_SEC;
978 _pico_printf( PICO_NORMAL, "Loaded model in in %-.2f second(s)\n", elapsed );
979 #endif //DEBUG_PM_ASE
981 _ase_free_materials(&materials);
983 /* return allocated pico model */
987 /* pico file format module definition */
988 const picoModule_t picoModuleASE =
990 "1.0", /* module version string */
991 "Autodesk 3DSMAX ASCII", /* module display name */
992 "Jared Hefty, seaw0lf", /* author's name */
993 "2003 Jared Hefty, 2002 seaw0lf", /* module copyright */
995 "ase",NULL,NULL,NULL /* default extensions to use */
997 _ase_canload, /* validation routine */
998 _ase_load, /* load routine */
999 NULL, /* save validation routine */
1000 NULL /* save routine */