Esempio n. 1
0
func surfacePosNormList(surf *md3.Surface, frame int, output chan<- surfaceStringPair) {
	buffer := new(bytes.Buffer)
	vertCount := surf.NumVertices()

	for vertIndex := 0; vertIndex < vertCount; vertIndex++ {
		posNorm := surf.Vertex(frame, vertIndex)
		if *swapYZ {
			var t float32
			t = posNorm.Origin.Y
			posNorm.Origin.Y = posNorm.Origin.Z
			posNorm.Origin.Z = t
			t = posNorm.Normal.Y
			posNorm.Normal.Y = posNorm.Normal.Z
			posNorm.Normal.Z = t
		}
		_, err := fmt.Fprintf(buffer,
			"v %f %f %f\nvn %f %f %f\n",
			posNorm.Origin.X, posNorm.Origin.Y, posNorm.Origin.Z,
			posNorm.Normal.X, posNorm.Normal.Y, posNorm.Normal.Z)
		if err != nil {
			panic(err)
		}
	}

	output <- surfaceStringPair{surf, buffer.String()}
}
Esempio n. 2
0
func surfaceTexCoordList(surf *md3.Surface, output chan<- surfaceStringPair) {
	buffer := new(bytes.Buffer)
	vertCount := surf.NumVertices()

	for vertIndex := 0; vertIndex < vertCount; vertIndex++ {
		texCoord := surf.TexCoord(vertIndex)

		if *flipUVs {
			texCoord.T = 1.0 - texCoord.T
		}

		_, err := fmt.Fprintf(buffer, "vt %f %f\n",
			texCoord.S, texCoord.T)
		if err != nil {
			panic(err)
		}
	}

	output <- surfaceStringPair{surf, buffer.String()}
}