Changeset 404 for branches/thune

Show
Ignore:
Timestamp:
06/01/07 06:15:44 (18 months ago)
Author:
krobillard
Message:

Thune (ts) - to/as converts vec3! -> coord!.
obj_to_gx script handles diffuse color.

Location:
branches/thune/thread_safe
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/thune/thread_safe/eval.c

    r403 r404  
    11031103            break; 
    11041104 
     1105        case UT_COORD: 
     1106            if( ur_is(val, UT_VEC3) ) 
     1107            { 
     1108                val->coord.elem[0] = (int) val->vec3.xyz[0]; 
     1109                val->coord.elem[1] = (int) val->vec3.xyz[1]; 
     1110                val->coord.elem[2] = (int) val->vec3.xyz[2]; 
     1111                ur_initType(val, UT_COORD); 
     1112                val->coord.len = 3; 
     1113            } 
     1114            break; 
     1115 
    11051116        case UT_BINARY: 
    11061117            if( ur_is(val, UT_STRING) ) 
     
    11591170            { 
    11601171                val->vec3.xyz[2] = (val->coord.len > 2) ? 
    1161                                     (float) val->coord.elem[2] : 0.0f; 
     1172                                     (float) val->coord.elem[2] : 0.0f; 
    11621173                val->vec3.xyz[1] = (float) val->coord.elem[1]; 
    11631174                val->vec3.xyz[0] = (float) val->coord.elem[0]; 
  • branches/thune/thread_safe/scripts/obj_to_gx.t

    r291 r404  
    2222    [] :normals 
    2323    [] :uvs 
    24     [] :surfs 
     24    none :surfs 
    2525    [] :faces 
    2626] 
     
    2828 
    2929 
    30 [type color] 
    31 [ 
    32     color ift ( 
    33         ["   " type '[' color ']'] print 
    34     ) 
     30/* 
     31[type color] [ 
     32    color ift (["   " type '[' color ']'] print) 
    3533] 
    3634func :write-color 
    37  
    38  
    39 [rejoin print] proc :jprint       ; (blk -- ) 
     35*/ 
     36[vec3! swap make print] proc :write-rgb     ; (color-blk -- ) 
    4037 
    4138 
     
    4340[ 
    4441    surf/name ift ( 
    45         [{;    name "} surf/name '"'] jprint 
    46     ) 
    47     ;"ambient"  surf/ambient  write-color 
    48     "diffuse"  surf/diffuse   write-color 
    49     "specular" surf/specular  write-color 
     42        [{  ; usemtl "} surf/name {"^/}] prin.pack 
     43    ) 
     44    "  color " prin  surf/diffuse write-rgb 
     45    /* 
     46    "ambient"  surf/ambient  write-color 
     47    "diffuse"  surf/diffuse  write-color 
     48    "specular" surf/specular write-color 
    5049    surf/color_map ift ( 
    51         [";   color_map [ %" surf/color_map " ]"] jprint 
     50        ["    color_map [ %" surf/color_map " ]^/"] prin.pack 
    5251    ) 
    5352    surf/bump_map ift ( 
    54         [";   bump_map [ %" surf/bump_map " ]"] jprint 
    55     ) 
    56 ] 
    57 func :write-surf 
     53        ["    bump_map [ %" surf/bump_map " ]^/"] prin.pack 
     54    ) 
     55    */ 
     56] 
     57func :write-surf    ; (surf -- ) 
    5858 
    5959 
     
    7676 
    7777    geo/name ift ( 
    78         [{;  name "} geo/name {"^/} ] jprint 
     78        [{;  name "} geo/name {"^/} ] prin.pack 
    7979    ) 
    8080 
     
    9797    ) 
    9898 
    99     geo/surfs empty? [ 
    100         "  color 0.8,0.8,0.8" print 
    101     ][ 
    102         geo/surfs [write-surf] each 
    103     ] either 
     99    geo/surfs if/keep write-surf 
     100    ;"  color 0.8,0.8,0.8" print 
    104101 
    105102 
     
    149146    ";]^/" print 
    150147] 
    151 func :write-geo 
     148func :write-geo     ; (geo -- ) 
    152149 
    153150 
     
    180177    verts [dec] map 
    181178 
    182     geo/faces key append verts append drop 
     179    geo/faces key append verts appen 
    183180] 
    184181func :convert-face 
     
    193190 
    194191    ; Material 
    195     file exists? ift ( 
     192    file exists? [ 
    196193        file read [ 
    197194              '#' thru eol 
    198195            | "newmtl" cl (gx-surf [data trim :name] make :surf 
    199                            sfs surf append drop) 
     196                           sfs surf/name append surf appen) 
    200197            | "Ns" sl 
    201198            | "d"  sl 
     
    207204            | "map_Kd"    cl (data trim :surf/color_map) 
    208205            | "map_Bump"  cl (data trim :surf/bump_map) 
    209             | cl ([";" data] print) 
     206            | sl  ; cl ([";" data] print) 
    210207            | end skip 
    211208        ] 
    212209        parse.some 
    213     ) 
     210    ][ 
     211        ["; Material file not found:" file eol] print 
     212    ] 
     213    either 
    214214 
    215215    sfs 
     
    218218 
    219219 
    220 [file string! | mtl main geo cl sl data] 
     220[file string! | mtllib main geo cl sl data] 
    221221[ 
    222222    [:data to eol data: skip] :cl 
     
    229229    file read [ 
    230230          '#' thru eol 
    231         | "mtllib" cl (data trim load-mtl :mtl) 
    232         | "usemtl" sl 
     231        | "mtllib" cl (data trim load-mtl :mtllib) 
     232        | "usemtl" cl (data trim mtllib select :geo/surfs) 
    233233        | "g"  sl 
    234         | "o"  cl (geo ift (geo write-geo) 
     234        | "o"  cl (geo if/keep write-geo 
    235235                   gx-geom [ 
    236236                     data trim copy :name 
    237                      mtl :surfs 
    238237                     main/uvs :uvs 
    239238                     main/normals :normals