Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Image:get in 3d?

edited April 2014 in Questions Posts: 22

So I'm trying to test a pixel in an image. But when I overlap them with a 3d world. It just shows up as the background color, because it can't access depth. (According to my knowledge) Here I'll post some code.

    pushMatrix() 
    setContext(screen)
    background(0, 0, 0, 0)
    perspective(FieldOfView,WIDTH/HEIGHT)
    angle = (angle + RotationRate.y / math.abs(Gravity.y/2))
    local x, y, z = math.sin(math.rad(angle)), Gravity.z , math.cos(math.rad(angle))
    camera(0, 0, 0,x, y, z, 0, 1, 0)
    rectMode(CENTER)

    translate(0, 0, 100)

    translate(0,0,0)
    stroke(0, 2, 255, 255)
    rect(0,0,5,5)
    translate(50,0,0)
    stroke(14, 255, 0, 255)
    rect(0,0,5,5)
    translate(-100,0,0)
    stroke(255, 0, 3, 255)
    rect(0,0,5,5)
    color_red,color_green,color_blue = screen:get(WIDTH/2,HEIGHT/2)
    setContext()
    popMatrix()
    ortho()
    resetMatrix()
    viewMatrix(matrix())

So I'm learning 3d programming by the way, so I know it looks sloppy. But can any one help me with this?

Tagged:

Comments

  • Posts: 1,595

    You need to get the image after you close setContext you're doing it one line before.

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Leviathan - you don't need to put this at the end

    ortho()
    resetMatrix()
    viewMatrix(matrix())
    

    (unless you are planning to write some text on the screen afterwards)

  • Posts: 22

    Oh, sorry didn't notice that. I was following a tutorial from cool codea, and I just added that in. While coding.

Sign In or Register to comment.