Underlying camera position assumption bug?
by Kirk Longendyke · in Torque Game Engine Advanced · 08/20/2007 (7:37 pm) · 4 replies
Fairly certain that this one's not technicly an sdk bug, since there is no real embedded stock suport for a third person fixed veiw, but:
img251.imageshack.us/my.php?image=grrrui3.jpg
Now, I've managed to trace it as far as unremming
ri->calcSortPoint(this, state->getCameraPosition());
in
bool DecalManager::prepRenderImage(SceneState* state, const U32 stateKey,
const U32 /*startZone*/, const bool /*modifyBaseState*/)
and appending
Con::printf("Cam Pos: %f, %f, %f",state->getCameraPosition().x,state->getCameraPosition().y,state->getCameraPosition().z);
For an excerpt, rather than giving the fixed positional data expected, I'm instead getting the following readout...
Cam Pos: -443.055115, -56.440002, 89.999992
Cam Pos: -442.575378, -56.439995, 89.999977
Cam Pos: -442.122284, -56.440002, 89.999992
Cam Pos: -441.691254, -56.439991, 89.999969
this leads me to the assumption that somewhere along the line theres a mismatch going on specificly related to decals' camera positions being reverted to the eyeview of the control object, as rather obviously the rest occlude just fine... thoughts?
img251.imageshack.us/my.php?image=grrrui3.jpg
Now, I've managed to trace it as far as unremming
ri->calcSortPoint(this, state->getCameraPosition());
in
bool DecalManager::prepRenderImage(SceneState* state, const U32 stateKey,
const U32 /*startZone*/, const bool /*modifyBaseState*/)
and appending
Con::printf("Cam Pos: %f, %f, %f",state->getCameraPosition().x,state->getCameraPosition().y,state->getCameraPosition().z);
For an excerpt, rather than giving the fixed positional data expected, I'm instead getting the following readout...
Cam Pos: -443.055115, -56.440002, 89.999992
Cam Pos: -442.575378, -56.439995, 89.999977
Cam Pos: -442.122284, -56.440002, 89.999992
Cam Pos: -441.691254, -56.439991, 89.999969
this leads me to the assumption that somewhere along the line theres a mismatch going on specificly related to decals' camera positions being reverted to the eyeview of the control object, as rather obviously the rest occlude just fine... thoughts?
#2
Wherein we're taking the stock Decal::addDecal function, and applying the position and normal of the surface found with the wheel extention raycast. As to moving the camera in and of it'sself, the bleedthrough begins to occur at an aproximate inclination of 45degrees or so. relevant scource for that can be found www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471
with the following changes for a pseudo-translating tracking-camera
I am _reasonably_ certain that none of that should effect this specific case _in theory_, however, of course, there being no stock implementation actually utilised for decals in the first place, and well over half the code in that fileset remaining remed on out...
08/21/2007 (2:24 pm)
Well, as to adding the decal to the scene, for full context, the full process can be found: www.garagegames.com/mg/forums/result.thread.php?qt=64664 the relvant snippet being if(mSceneManager->getCurrentDecalManager()) mSceneManager->getCurrentDecalManager()->addDecal(wheel->surface.pos, rot, wheel->surface.normal, wheel->tire->decalData[matInst->mFXIndex]);
Wherein we're taking the stock Decal::addDecal function, and applying the position and normal of the surface found with the wheel extention raycast. As to moving the camera in and of it'sself, the bleedthrough begins to occur at an aproximate inclination of 45degrees or so. relevant scource for that can be found www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471
with the following changes for a pseudo-translating tracking-camera
case TrackMode :
//camera translation hack
if (this->getLookAtPos(&objPos))
{
Point3F camPos = this->getCameraPosition();
F32 objDist = mSqrt(mPow(camPos.x-objPos.x,2) + mPow(camPos.y-objPos.y,2) + mPow(camPos.z-objPos.z,2));
F32 fov = 45.0f * ((mClampF((1000 - objDist), 0, 1000))/1000);
fov = mClampF(fov,5.0f,60.0f);
GameSetCameraFov(fov);
cameraPosWorld.x = (mAnchorCameraPos.x + objPos.x*99)/100;
cameraPosWorld.y = (mAnchorCameraPos.y + objPos.y*99)/100;
cameraPosWorld.z = mAnchorCameraPos.z;
setPosition(cameraPosWorld);
}
//end camera translation hackI am _reasonably_ certain that none of that should effect this specific case _in theory_, however, of course, there being no stock implementation actually utilised for decals in the first place, and well over half the code in that fileset remaining remed on out...
#3
Heh, yeah, that could be better.
The slopebias number above could really be the issue if the camera angle matters. I'd try some different values for that and see the result.
08/21/2007 (3:21 pm)
Quote:
and well over half the code in that fileset remaining remed on out...
Heh, yeah, that could be better.
The slopebias number above could really be the issue if the camera angle matters. I'd try some different values for that and see the result.
#4
F32 depthbias = -0.000002f;
F32 slopebias = -0.006f;
(1/10th)
result:
no discernable change
testrun 2-
F32 depthbias = -0.2f;
F32 slopebias = -0.6f;
(base x muchas)
result:
no discernable change
testrun 3-
F32 depthbias = 0.2f;
F32 slopebias = 0.6f;
(inverse base x muchas)
decals go byebye.
aaand finally.
F32 slopebias = -0.000006f;
again, no discernable change...
gotta be something else...
08/21/2007 (4:51 pm)
Testrun 1- F32 depthbias = -0.000002f;
F32 slopebias = -0.006f;
(1/10th)
result:
no discernable change
testrun 2-
F32 depthbias = -0.2f;
F32 slopebias = -0.6f;
(base x muchas)
result:
no discernable change
testrun 3-
F32 depthbias = 0.2f;
F32 slopebias = 0.6f;
(inverse base x muchas)
decals go byebye.
aaand finally.
F32 slopebias = -0.000006f;
again, no discernable change...
gotta be something else...
Torque Owner Brian Richardson
I'd look at two things:
1. How are you adding data to the decal manager, have you confirmed that this is correct? If you move the camera, does it seem to work?
2. There's this block here:
This basically tries to deal with zfighting. But if the numbers are wrong for your scene, then you could see issues similar to your screenshot. You may try blinding dorking around with the numbers to see if it helps you out. ;)
Hope that helps.