예제 #1
0
파일: main.go 프로젝트: go3d/go-ngine
func processFile(srcFilePath string) (keepWalking bool) {
	if strings.HasSuffix(srcFilePath, ".tga") {
		var (
			outFilePath      = strings.Replace(strings.Replace(srcFilePath, *fSrcDirPath, *fOutDirPath, -1), ".tga", ".png", -1)
			dirPath          = filepath.Dir(outFilePath)
			tgaFile, pngFile *os.File
			img              image.Image
			err              error
		)
		if err = uio.EnsureDirExists(dirPath); err != nil {
			log.Printf("ERR MkDir %v: %v\n", dirPath, err)
		} else if uio.DirExists(dirPath) {
			if tgaFile, err = os.OpenFile(srcFilePath, os.O_RDONLY, os.ModePerm); err != nil {
				log.Printf("ERR OpenFile %v: %v\n", srcFilePath, err)
			} else {
				defer tgaFile.Close()
				if img, err = tga.Decode(tgaFile); err != nil {
					log.Printf("ERR Decode %v: %v\n", srcFilePath, err)
				} else {
					if pngFile, err = os.Create(outFilePath); err != nil {
						log.Printf("ERR CreateFile %v: %v\n", outFilePath, err)
					} else {
						defer pngFile.Close()
						if err = png.Encode(pngFile, img); err != nil {
							log.Printf("ERR Encode %v: %v\n", outFilePath, err)
						} else {
							log.Printf("DONE %v\n", outFilePath)
						}
					}
				}
			}
		}
	}
	return true
}
예제 #2
0
파일: main.go 프로젝트: nizvoo/go-collada
func main() {
	var (
		flagSrcFilePath = flag.String("src", "", "File path to the Collada 1.4.1 source document to be loaded.")
		flagDstFilePath = flag.String("dst", "", "File path to the Collada 1.5 destination document to be written.")
	)
	runtime.LockOSThread()
	xmlx.IndentPrefix = "\t"
	flag.Parse()
	if (len(*flagSrcFilePath) > 0) && (len(*flagDstFilePath) > 0) {
		convert(*flagSrcFilePath, *flagDstFilePath)
	} else {
		const dbp = "Dropbox/oga/collada"
		for _, baseDirPath := range []string{filepath.Join("Q:", dbp), filepath.Join(ugo.UserHomeDirPath(), dbp)} {
			if uio.DirExists(baseDirPath) {
				for _, subDirName := range []string{"cube-poly", "cube-tris", "duck-poly", "duck-tris", "mgmidget", "bikexsi", "diningroom", "berlin", "sponza"} {
					convert(filepath.Join(baseDirPath, subDirName, "obj.dae"), filepath.Join(baseDirPath, subDirName, "obj15.dae"))
				}
			}
		}
	}
}