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
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
About the author
email me at medan121@gmail.com
Recent Threads
#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
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
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
if your rendering the squares using uv coordinates:
then using
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;
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
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*
11/21/2010 (10:03 am)
@DeepscratchOh, 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
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.
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
It should be like this:
The position of the camera can be calculated as follows:
The viewing direction can be calculated as follows:
Now set the camera:
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.
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 EyeIt should be like this:
.
X Camera
/|
/ |
/ |
/ |
/ |
/ |
---------------_____________----------------
Mirror\ | Mirror Plane
\ |
\ |
\ |
\ |
\|
X EyeThe 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.......
Torque 3D Owner Marcus L