working texture?
This commit is contained in:
parent
c89a3a9ab5
commit
d69354ea09
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image/color"
|
||||
//"log"
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
@ -15,7 +16,8 @@ func Col2Uint(r, g, b byte) uint {
|
||||
|
||||
func Color2Uint(col color.Color) uint {
|
||||
r, g, b, _ := col.RGBA()
|
||||
return uint((r << 16) | (g << 8) | b)
|
||||
//log.Print(r, g, b)
|
||||
return uint(((r & 0xff00) << 8) | (g & 0xff00) | ((b & 0xff00) >> 8))
|
||||
}
|
||||
|
||||
// Convert uint to rgb (in that order)
|
||||
|
@ -111,7 +111,7 @@ func main() {
|
||||
n = n.Normalize()
|
||||
intensity := n.MultSimp(&light)
|
||||
if intensity > 0 {
|
||||
Triangle3t(&fb, texture, intensity, byte(255*intensity), byte(255*intensity)), sc[0], sc[1], sc[2])
|
||||
Triangle3t(&fb, texture, intensity, sc[0], sc[1], sc[2])
|
||||
//Triangle3(&fb, uint(rand.Int()), sc[0], sc[1], sc[2])
|
||||
//Triangle1(&fb, uint(rand.Int()), sc[0].ToVec2i(), sc[1].ToVec2i(), sc[2].ToVec2i())
|
||||
//Triangle2(&fb, 0xFFFFFF, sc[0], sc[1], sc[2])
|
||||
|
@ -326,7 +326,7 @@ func Triangle3t(fb *Framebuffer, texture image.Image, intensity float32, v0v Ver
|
||||
//log.Print(pz)
|
||||
fb.ZBuffer[x+y*fb.Width] = pz
|
||||
txo := int(float32(tw) * (w0a*v0v.Tex.X + w1a*v1v.Tex.X + w2a*v2v.Tex.X))
|
||||
tyo := int(float32(th) * (w0a*v0v.Tex.Y + w1a*v1v.Tex.Y + w2a*v2v.Tex.Y))
|
||||
tyo := int(float32(th) * (1 - (w0a*v0v.Tex.Y + w1a*v1v.Tex.Y + w2a*v2v.Tex.Y)))
|
||||
col := texture.At(tx+txo, ty+tyo)
|
||||
//c := texture.At()
|
||||
fb.Set(x, y, Color2Uint(col)) //uint(texture.Bounds().Dx())
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "You must pass the basename for the .prof and .ppm"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user