Trick to rayCast against waterBlocks ?
by Orion Elenzil · in Torque Game Engine · 11/18/2007 (11:49 am) · 2 replies
I suspect we probably just broke something,
but i'm not getting any hits when casting a ray into a waterblock.
is there a trick ?
the raycast is something like:
- so casting a ray straight down from 0, 0, 100 to 0, 0, -500,
typemask = just water, no exempt object.
the same line returns the expected results when using $TypeMasks::InteriorObjectType instead.
here's my waterblock from the mission file:
also, echo(water.getType() - $TypeMasks::WaterObjectType); yields 0, as one would hope.
have we just hosed our water block in some way, or is there some bit of arcania i'm missing ?
and my second question,
if you were me, where would you start looking for the problem ?
aha: WaterBlock::castRay() is never called, it looks like.
but i'm not getting any hits when casting a ray into a waterblock.
is there a trick ?
the raycast is something like:
containerRayCast("0 0 100", "0 0 -500", $TypeMasks::WaterObjectType, 0);- so casting a ray straight down from 0, 0, 100 to 0, 0, -500,
typemask = just water, no exempt object.
the same line returns the expected results when using $TypeMasks::InteriorObjectType instead.
here's my waterblock from the mission file:
new WaterBlock(Water) {
position = "-416 -544 -99.4";
rotation = "1 0 0 0";
scale = "1024 1024 100";
UseDepthMask = "1";
surfaceTexture = "~/common/water/water4";
ShoreTexture = "~/common/water/water4";
envMapOverTexture = "~/minimal/skies/01-02b/env_water_cityreflect";
specularMaskTex = "~/common/water/specmask";
NormalMapTexture = "~/common/water/waternormalmap";
WaterDynamicFXShader = "~/common/shaders/waterDynamic.fx";
WaterStaticFXShader = "~/common/shaders/waterStatic.fx";
StaticReflectionCubeMap = "~/minimal/skies/01-02b/skycube";
liquidType = "StagnantWater";
density = "1";
viscosity = "10";
waveMagnitude = "0.2";
surfaceOpacity = "0.6";
envMapIntensity = "0.4";
TessSurface = "50";
TessShore = "15";
SurfaceParallax = "0.9";
FlowAngle = "0";
FlowRate = "0.01";
DistortGridScale = "0.01";
DistortMag = "0.005";
DistortTime = "0.9";
ShoreDepth = "6";
DepthGradient = "1";
MinAlpha = "0.1";
MaxAlpha = "1";
removeWetEdges = "1";
specularColor = "0 0.1 0.2 1";
specularPower = "50";
deepColor = "0.05 0.05 0.1 1";
shallowColor = "0.1 0.4 0.7 1";
reflectionColor = "1 1 1 1";
reflectionAmount = "1";
waterAmount = "0.5";
fresnelBias = "0";
fresnelPower = "4";
};also, echo(water.getType() - $TypeMasks::WaterObjectType); yields 0, as one would hope.
have we just hosed our water block in some way, or is there some bit of arcania i'm missing ?
and my second question,
if you were me, where would you start looking for the problem ?
aha: WaterBlock::castRay() is never called, it looks like.
About the author
#2
but i realized that what i really wanted wasn't the intersection w/ the waterblock anyhow,
but instead the intersection with the XY plane. so wrote a lil' console math function to help with that, if anyone's interested:
which PS hats of to the author of PlaneF::intersect()! i didn't realize it could be done so simply.
11/18/2007 (2:04 pm)
I haven't figured this out,but i realized that what i really wanted wasn't the intersection w/ the waterblock anyhow,
but instead the intersection with the XY plane. so wrote a lil' console math function to help with that, if anyone's interested:
ConsoleFunction(intersectPlaneLine, const char*, 5, 5, "(Point ptPlane, Vector normalPlane, Point pt1, Point pt2) Calculate the intersection point of a plane and a line.")
{
char* returnBuffer = Con::getReturnBuffer(256);
Point3F ptPlane;
Point3F nmPlane;
Point3F pt1;
Point3F pt2;
dSscanf(argv[1],"%f %f %f",&ptPlane.x, &ptPlane.y, &ptPlane.z);
dSscanf(argv[2],"%f %f %f",&nmPlane.x, &nmPlane.y, &nmPlane.z);
dSscanf(argv[3],"%f %f %f",&pt1 .x, &pt1 .y, &pt1 .z);
dSscanf(argv[4],"%f %f %f",&pt2 .x, &pt2 .y, &pt2 .z);
PlaneF plane(ptPlane, nmPlane);
F32 dist = plane.intersect(pt1, pt2);
Point3F ptIntersect = (pt2 - pt1) * dist + pt1;
dSprintf(returnBuffer, 256, "%g %g %g", ptIntersect.x, ptIntersect.y, ptIntersect.z);
return returnBuffer;
}which PS hats of to the author of PlaneF::intersect()! i didn't realize it could be done so simply.
Associate Orion Elenzil
Real Life Plus