Results 1 to 9 of 9

Thread: To get colour from a 3Dcube

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2002
    Posts
    6

    To get colour from a 3Dcube

    Hi, all!
    Please, help me!
    I have created 3D cube, using OpenGl. I can rotate and scale it.
    When i click on any side of the cube, i need to get a color of this side. How can i make it?
    Thx!!!

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: To get colour from a 3Dcube

    Since you have drawn the cube, you know what colors you have put on each side.
    Just look at how much you have rotated the cube and figure out what side is facing the camera when the mouse button is pressed.

    Example:
    rotation_x = 0; rotation_y = 0; Front of cube facing user.
    rotation_x = 90; rotation_y = 0; Left side of cube facing user.
    rotation_x = 0; rotation_y = 90; Top of cube facing user.

    You also may want to look at object picking, see nehe.gamedev.net for an example of that.

    Originally posted by GMV:
    Hi, all!
    Please, help me!
    I have created 3D cube, using OpenGl. I can rotate and scale it.
    When i click on any side of the cube, i need to get a color of this side. How can i make it?
    Thx!!!


    [This message has been edited by nexusone (edited 05-16-2002).]

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2002
    Posts
    6

    Re: To get colour from a 3Dcube

    Thx.
    What i must to do, to get colour of a point when i click mouse on the cube?

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: To get colour from a 3Dcube

    wouldn't it be better to use selection?

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2002
    Posts
    6

    Re: To get colour from a 3Dcube

    How i can make it?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    184

    Re: To get colour from a 3Dcube

    look up glReadPixels.

    b

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: To get colour from a 3Dcube

    I think that you have not been clear on what you want to do?

    Are you wanting to get the color of a pixel on the screen?
    Or just the color of the side of the cube that is clicked on?
    If you want to get the color of the side clicked on, then my last message explains that.

    Originally posted by GMV:
    Thx.
    What i must to do, to get colour of a point when i click mouse on the cube?


  8. #8
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    14

    Re: To get colour from a 3Dcube

    He's not assuming every side is a solid color. He wants to know how to click on any point on the cube and get the color there.

    Which I suppose would be glReadPixels but he'd probably also need to use a bounding box to make sure he's clicking on the cube and not the background or another object.

  9. #9
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    Eastern USA
    Posts
    218

    Re: To get colour from a 3Dcube

    Ok, then check your mouse coordinates against a simple bounding box, provided the click is in the box, proceed to read the frame buffer within the bounding box into an array, then just use the mouse position to extract (I imagine) R G and B values.

    Nothin' but net.

    Certainly not the only way to do it but one of the more direct ways.

Similar Threads

  1. OpenGL colour not able to render colour
    By mundrapiyush in forum OpenGL: Linux
    Replies: 3
    Last Post: 05-16-2010, 03:15 AM
  2. Custom Colour
    By Eckos in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-27-2008, 12:49 AM
  3. Different colour for TGA font
    By cyam95 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-09-2002, 07:31 AM
  4. colour problem
    By fox in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-07-2001, 10:13 AM
  5. colour
    By fox in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-21-2001, 07:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean