Game Development Community

how do I flip the X? watch the vid

by deepscratch · in Torque 3D Professional · 11/12/2010 (11:18 pm) · 10 replies

hi all,
shit news aside,
how can I flip the camera's X?
through the fustrum?
or via the scheneState?

why?
mirrors
even got a video of them in action, and mounted to a vehicle,



see what X I need to flip??
anyone know how???
thanks

#1
11/20/2010 (2:10 pm)
Deepscratch, may i ask you, how did you make these mirrors? Is it modified water blocks? I know how to flip the X btw.
#2
11/20/2010 (3:07 pm)
awesome effect i been wondering how you would achieve that effect in T3D. I believe Ron had a pretty good solution in tgea, for windows and what not but please keep us posted on the status of the effect.
#3
11/20/2010 (10:42 pm)
@Marcus,
no, they are camera views rendered to textures.
Please can you explain how you'd flip the X?
maybe you can catch me on msn messenger? (medan121 at gmail dot com)

it would be a huge help
#4
11/21/2010 (7:24 am)
If you're rendering to a texture then mapping that onto the model, just reverse the U texture coordinate on the part of the mesh that you use for the mirror.
#5
11/21/2010 (9:24 am)
not quite so simple, Guy
#6
11/21/2010 (9:32 am)
hmm, why not?

if your rendering the squares using uv coordinates:

0,0-------1,0
 |         | 
 |         |
0,1-------1,1

then using

1,0-------0,0
 |         |
 |         |
1,1-------0,1

will flip the x

so if you're drawing the quads completely from in the engine, that should be easy.

If you're doing it in a shader, then you should be able to achieve the same thing using something like
out.texCoord.u = 1 - in.texCoord.u;
#7
11/21/2010 (10:03 am)
@Deepscratch
Oh, i tought maybe you'd used some sort of shader. I can try to help you out if you want. *Adding you on messenger*
#8
12/01/2010 (10:25 pm)
Hey that is neat,

Can I ask how you get the camera view to render on objects?

A thought to flipping the X might be to use a double sided texture.
#9
12/02/2010 (7:16 pm)
Looks like the camera position is not being mirrored across the mirror plane properly.

.
             X  Camera
              \
               \
                \
                 \
                  \
                   \
---------------_____________----------------
               Mirror\          Mirror Plane
                      \
                       \
                        \
                         \
                          \
                           X  Eye

It should be like this:

.
                           X  Camera
                          /|
                         / |
                        /  |
                       /   |
                      /    |
                     /     |
---------------_____________----------------
               Mirror\     |    Mirror Plane
                      \    |
                       \   |
                        \  |
                         \ |
                          \|
                           X  Eye

The position of the camera can be calculated as follows:

Point3F CamPos;

CamPos = EyePos-(2.0*MirrorPlane.distToPlane(EyePos)*MirrorPlane.getNormal());

The viewing direction can be calculated as follows:

Point3F CamRot;

// Note: might be able to get away with simply using view vector pointing
// from CamPos to a node in the center of the mirror, instead of actually
// reflecting the view vector across the mirror plane
Reflected = MathUtils::reflect(-EyeDir, MirrorPlane.getNormal());
Reflected.normalize();  // Should already be, but to be safe

MathUtils::getAnglesFromVector(Reflected, CamRot.z, CamRot.x);
CamRot.x *= -1.0f;

Now set the camera:

Camera.setPosition(CamPos, CamRot);

Edit: removed some unnecessary code. And after watching the vid again, I think you'd still need to flip the texture coords like Guy said, after implementing the above. You might be able to flip the image by swapping the left and right frustum planes (not sure), but the texture coord swap would work for sure and is not any more computationally expensive.
#10
12/03/2010 (4:08 pm)
wow, Ryan, that looks as if it may work, I'll see if it does now.......