| 1 | puts "========" |
| 2 | puts "0029303: Data Exchange - add RWObj_CafWriter tool for wavefront OBJ file" |
| 3 | puts "Write textured plane OBJ model into OBJ file" |
| 4 | puts "========" |
| 5 | |
| 6 | pload XDE OCAF MODELING VISUALIZATION |
| 7 | Close D -silent |
| 8 | Close D1 -silent |
| 9 | |
| 10 | XNewDoc D1 |
| 11 | XSetLengthUnit D1 cm |
| 12 | ReadObj D1 [locate_data_file "P-51 Mustang.obj"] -nocreatedoc -unit 1 |
| 13 | XGetOneShape s1 D1 |
| 14 | set aLProps1 [uplevel #0 sprops $s1] |
| 15 | |
| 16 | set aTmpObjBase "${imagedir}/${casename}_tmp" |
| 17 | set aTmpObj "${aTmpObjBase}.obj" |
| 18 | lappend occ_tmp_files $aTmpObj |
| 19 | lappend occ_tmp_files "${aTmpObjBase}.mtl" |
| 20 | lappend occ_tmp_files "${aTmpObjBase}_textures" |
| 21 | |
| 22 | WriteObj D1 "$aTmpObj" |
| 23 | |
| 24 | XNewDoc D |
| 25 | XSetLengthUnit D cm |
| 26 | ReadObj D "$aTmpObj" -nocreatedoc -unit 1 |
| 27 | XGetOneShape s D |
| 28 | set aLProps2 [uplevel #0 sprops $s] |
| 29 | checknbshapes s -face 14 -compound 1 |
| 30 | checktrinfo s -tri 4309 -nod 4727 |
| 31 | |
| 32 | regexp {Mass\s:\s*([0-9\.]+)} $aLProps1 dummy anArea1 |
| 33 | regexp {Mass\s:\s*([0-9\.]+)} $aLProps2 dummy anArea2 |
| 34 | if {abs($anArea1 - $anArea2) > 1e-8 * $anArea1} { |
| 35 | puts "Error: invalid area $anArea1 instead of $anArea2" |
| 36 | } |
| 37 | |
| 38 | vclear |
| 39 | vinit View1 |
| 40 | XDisplay -dispMode 1 D |
| 41 | vaxo |
| 42 | vfit |
| 43 | vdump ${imagedir}/${casename}.png |