## RB: Sphere mapping?

I was wondering if it is possible to acheive a reflection map on objects using RB3D (quesa)? I'm not sure what the correct terminology is, but is it called a spheremap? All I want is a 2D texture shrinkrapped onto an object with the same orientation, no matter which way the object is facing. Can I acheive this by editing the 3DMF file, or do I need extra coding?

Sorry for the confusing question, but I'm sure someone out there will understand!

Thanks

Remember, if you use a square image, you'll probably get noticeable distortions at the top and bottom, I believe circular images are the way to go for nice-looking results. You may need two circular ones (one for northern, one for southern hemisphere) otherwise there'll be much more detail on one side.

I cant understand ProjectBuilder / Cocoa, but is this method similar to the method used in the UseSphereMap example in the GLUTexamples folder?

Thanks

I don't know whether that's exposed in any way, shape or form by Quesa, though.

If you look at the OpenGL specification, you should be able to find the mathematical formulae used to generate the sphere mapping texture coordinates, if that's useful to you.

it shouldn't be too tricky; let me try again.

I'm assuming that you have, at each vertex, a normal vector and a pair of texture co-ordinates.

Then, for each visible vertex, do the following:

1: get a vector pointing from the camera to the vertex.

2: reflect this vector in the plane defined by (perpendicular to) the vertex's normal.

3: convert the resulting vector into spherical polar co-ordinates (without worrying about its magnitude).

You'll end up with two numbers which represent, essentially, longitude and latitude - and so each one can be multiplied by some constant to give you u and v co-ordinates on a rectangular texture. Then just give your vertex the new texture coordinates, and render as normal.

u = longitude * textureWidth/TwoPi

v = (latitude + PiByTwo) * textureHeight/Pi

(assuming you're using radians)

Reflecting the vector shouldn't be too hard, and there must be any number of places on the web to tell you how to convert to spherical polar co-ordinates.

I hope this helps.

ps If you're programming in 3d it'd really help to learn some 3d vector maths, if you haven't already. It'll make things much easier.

pps watch out: those polygons which cross over the horizontal edge of the map may (will) look funny if you don't do some extra checks. This should get you started, thoughÃ–

V = vector pointing from vertex to camera

N = normal vector at vertex

R = reflected vector

R = (2N.V)N - V

them convert R to spherical polar and you're away.

ps if you know 3d maths already, sorry to be patronising. pls forgive

[edit] I think V should be normalised. Presumably N is already.

Hello Cookie

Did you go to the Apple show last month in Adelaide?

Did you go to the Apple show last month in Adelaide?

No, Adelaide's a bit far & expensive, especially with a new computer in the house

I haven't even been as far as Auckland for an Apple event...

I notice that there're a growing number of south-pacific-ers on this forum, though. I think so far I've counted five New Zealanders and four or five Australians. Maybe there's an opportunity there to have a south pacific Mac-Game-Dev meeting...

Quote:Originally posted by OneSadCookie

I notice that there're a growing number of south-pacific-ers on this forum, though. I think so far I've counted five New Zealanders and four or five Australians. Maybe there's an opportunity there to have a south pacific Mac-Game-Dev meeting...

This is going a bit off topic now, but I had thought of a Mac-Game-Dev meeting for us Oceanics as well, but we seem a bit spread out, aside from the two Adelaideans on this thread.

Thanks also to monte, I'll see if I can find it.

Baldock- unfortunately the Apple show was during the middle of my exam week; so I didnt have time to go. Did you go? What was it like?