View Single Post
Old 15th April 2012, 22:30   #3
Forum King
jheriko's Avatar
Join Date: Aug 2002
Location: a twist in the fabric of space
Posts: 2,150
Send a message via ICQ to jheriko
this code performs a raytrace - with some hacks - to achieve its effect. the idea is to get the equation of a line, from a direction and start position, and intersect it with the equations of planes describing the cube to find the texture coordinates we want on the cube's surface.

ox,oy,oz are a camera position

y=y*af is aspect ratio correction

the big block of code involving sx, cx, sy... are rotations

the k = lines are solving the raytrace and picking the correct solution

x and y are then set based on the results. these are texture coordinates. alpha provides the fading to hide ugly edges.

if you try and recreate this approach from scratch without copying code you should get a good understanding of the technique and be able to apply it to arbitrary situations...

AVS code like this is not easy to pick apart or follow, the coding style we all used to use, the lack of comments and the obscurity of the problems all pile up to make it very difficult.

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote