Rendering 3d properties to bitmap

This is a discussion on Rendering 3d properties to bitmap within the C++ Programming forums, part of the General Programming Boards category; Hey, I'm not sure if anybody here has any experience wth working with 3d geometry but I have a thing ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    158

    Rendering 3d properties to bitmap

    Hey, I'm not sure if anybody here has any experience wth working with 3d geometry but I have a thing I'd like to do and I'm trying to figure out the best way to do it...an example:

    If I want to render out certain characteristics of an object to a bitmap, like surface normal as an example, what is the best way go about that? Do I step through each pixel in the bitmap and determine which face the pixel lies within in the objects uv coordinates then calculate the barycentric coordinates for that point and then get that position in 3d space from those coordinates(relative to the face)?...or is there a more efficient way? Determining in which face each pixel lies can get quite time consuming like that.


  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    I'm not sure I understand you. If you want a normal map there are tried and true methods for generating them.

    Since surface normals should fall in the range 0.0f to 1.0f you could write this to the bitmap at each pixel

    Red - 255.0f * normal[vertex_num].x;
    Green = 255.0f * normal[vertex_num].y;
    Blue = 255.0f * normal[vertex_num].z;
    Alpha = 0.0f;

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    Hey Bubba, yes but that will not fill in the parts between the vertices. I need to find a good way to tell where each pixel lies on the 3d surface.

    I'm thinking of checking an area in the bitmap that is a rectangle around each face and check if the face contains the pixel and if it does get the positon of the pixel relative to the face. That relative place will then also be relative to the face in 3d space.

    I do not actually need to create a normalmap, I rather want to create a map that displays how concave or convex a surface is.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    You cannot do that without doing some nifty uv wnrapping algorithms. You are trying to put a 3D object onto a 2D plane which is exactly what happens when you unwrap a model.

    Good luck with that.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    Hey Bubba, the object already has uv mapping applied so I need not worry about that. The code for determining concavity/convexity is also already written. Anyway I have got something basically working now which is reasonably fast. Now I just need to get it to draw smoothly across edges and stuff.

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    158

    Smile

    For those interested, I managed to complete this tool now (so proud)
    Here is an image showing the generated map and the map applied to the model after some editing in photoshop.

    http://www.cmlcreative.com/Images/cavitytest.jpg

    cheers

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    Wow, that is pretty awsome. Congratulations on your great invention!


    (nobody else said it)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 05:33 AM
  2. 3D rendering of only visible faces
    By Zeeshan in forum Game Programming
    Replies: 5
    Last Post: 02-23-2009, 05:52 PM
  3. Font rendering in Direct3D
    By VirtualAce in forum Game Programming
    Replies: 3
    Last Post: 10-17-2005, 09:56 AM
  4. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  5. 2-D background bitmap behind a 3D wold using OpenGL
    By Laeeqhamid in forum Game Programming
    Replies: 6
    Last Post: 12-28-2002, 03:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21