realbasic-games
[Top] [All Lists]

Re: OBJ and 3DS support for vertex colors

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: OBJ and 3DS support for vertex colors
From: Lo Saeteurn <realbasic at miensoftware dot com>
Date: Sat, 20 Aug 2005 21:53:24 -0700
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <8DF2BB08-78E5-4A06-B484-895B5868CC47 at miensoftware dot com> <98D5C6A8-4D28-4AAC-9D45-664AA46DD36E at chaoticbox dot com> <D962D06D-00DB-4899-A24F-5553090F959B at miensoftware dot com> <CAE9040D-2C53-47E2-81EC-3B54FA9F6C50 at chaoticbox dot com> <C67E7CE8-E64B-4C39-A825-14CD0A88C271 at miensoftware dot com> <75099C14-B525-45F5-B96A-6FF18C435514 at chaoticbox dot com> <D1B36A2F-97EE-4B71-BC3B-BD3A5548541A at miensoftware dot com> <049C1457-8F68-4A08-A591-E874CF0EC7B7 at chaoticbox dot com> <034341D7-ECC5-4072-8B76-7E9F1DC660DD at miensoftware dot com> <668F9E8B-AD29-4B01-B08E-67F41622722E at miensoftware dot com> <C9ED2AF5-4F2C-4D9C-BC0C-D19340F96E96 at chaoticbox dot com>
Well, it doesn't light properly if the object has been rotated.

Here's how I'm transforming the vertices (after I getting it from the vertex list of a Trimesh) to match what you see in the world:

******START OF CODE
dim q,q2 as Quaternion, Scale, mYaw, mPitch as double
dim Pnt as vector3D

    Pnt.MultiplyBy Scale //scale it to its current scale
//rotate the vertex <--- The rotation code starts here
    q=new Quaternion
    q2=new Quaternion
    q2.SetRotateAboutAxis 0,1,0,mYaw//yaw it this amount
    q=q2.Times(q)
    q2.SetRotateAboutAxis 1,0,0,mPitch//then pitch it upward
    q=q2.Times(q)
    Pnt.Copy q.Transform(Pnt)
//-- <--- The rotation code ends here
    Pnt.Add Position //translate the point to world coordinates
******END OF CODE

To get to its proper rotation, I yaw the object first then pitch it by the same mYaw and mPitch values. mYaw and mPitch are in radians. I'm trying to do the same to the vertices, but it is not working correctly.

What am I doing wrong?


Please post some screenshots when you've got something to show - I'm curious to see the results!

Sure. The default light color is the ambient color * ambient light. Each light that hits a vertex is added onto the current vertex color. The lighting is a bit different because of the specular light (shininess) on the original models. After rendering, I turned on NullShading so that RB/Quesa's dynamic lights do not affect it. I didn't have my own scenes yet to test with so I hope Jeff and Joe don't mind me using theirs (from Renegades).

Before:
http://www.miensoftware.com/darkawakening/vertexlight/screen1.jpg

After:
http://www.miensoftware.com/darkawakening/vertexlight/screen2.jpg
http://www.miensoftware.com/darkawakening/vertexlight/screen3.jpg

Before:
http://www.miensoftware.com/darkawakening/vertexlight/screen4.jpg

After:
http://www.miensoftware.com/darkawakening/vertexlight/screen5.jpg
http://www.miensoftware.com/darkawakening/vertexlight/screen6.jpg


The next step is to expand on this and create per pixel lighting by ray-tracing the entire scene and generating a mesh-based lightmap, but I'll leave this for another day if I decide to do it...


Not sure what you mean by a "mesh-based" lightmap (a highly tessellated version of the original mesh?)

A mesh generated by the rays hitting a surface. Or, instead, attach the new points onto the mesh that the ray hits so that the shadows are sharper and more accurate.


Either way it's pretty much impossible to render per-pixel lightmaps through Quesa, as it only allows one texture per triangle (and one set of UV's for that matter).

That's what I mean. Since Quesa cannot support multiple UVs, the 2nd texture must be on a separate mesh that is slightly shifted over the original. Since we know where the ray hits, a mesh can be generated over the original surface with a light map texture.

This already sounds complex, but I'll leave it for another day to tackle if I really feel it is needed.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>