Esempio n. 1
0
File: mm3ddump.go Progetto: iand/go
func main() {
	flag.Parse()

	if flag.NArg() < 1 {
		fmt.Fprintf(os.Stderr, "Not enough arguments.\n\nUsage: %s <file.mm3d>\n", os.Args[0])
		os.Exit(2)
	}

	fname := flag.Arg(0)
	f, err := os.Open(fname)
	die(err)
	defer f.Close()

	model, err := mm3dmodel.Read(f)
	die(err)

	fmt.Printf("Version: %d.%d\n", model.MajorVersion(), model.MinorVersion())
	fmt.Printf("Model flags: 0x%02x\n", model.ModelFlags())
	fmt.Printf("Num dirty segments: %d\n\n", model.NDirtySegments())

	printMetadata(model)
	printVertices(model)
	printTriangles(model)
	printTriangleNormals(model)
	printTextureCoordinates(model)
}
Esempio n. 2
0
// Function LoadModel loads and returns an MM3D model.
func LoadModel(filename string) (model *mm3dmodel.Model) {
	fmt.Printf("Loading model: %s\n", filename)
	f, err := os.Open(filename)
	if err != nil {
		panic(err)
	}
	defer f.Close()

	model, err = mm3dmodel.Read(f)
	if err != nil {
		panic(err)
	}

	if model.NDirtySegments() > 0 {
		fmt.Fprintf(os.Stderr, "***** MM3D Warning: Found %d dirty segments in %s! Tell Kier to add more functionality!\n", model.NDirtySegments(), filename)

		for i := 0; i < model.NDirtySegments(); i++ {
			fmt.Fprintf(os.Stderr, "***** MM3D Warning:   * Offset type 0x%04X\n", model.DirtySegment(i).OffsetType())
		}
	}

	return model
}