Hey all, I'm trying to use the 'dbShiftMatrix' commands to simulate a never-ending landscape, but they don't seem to be working.. at all.
I'm basing this on the tank example from DBC:
gridunitsize#=(landsize*2)/25.0
shx#=shx#+(x#-oldx#)
shz#=shz#+(z#-oldz#)
if shx#<0.0 then shx#=shx#+gridunitsize# : shift matrix right 1
if shx#>=gridunitsize# then shx#=shx#-gridunitsize# : shift matrix left 1
if shz#<0.0 then shz#=shz#+gridunitsize# : shift matrix down 1
if shz#>=gridunitsize# then shz#=shz#-gridunitsize# : shift matrix up 1
mx#=(x#-landsize)-shx# : mz#=(z#-landsize)-shz#
position matrix 1,mx#,0,mz#
My code is using the exact same logic, as shown here:
void Terrain::Follow(Vector3 pos, Vector3 old)
{
_shiftX += pos.X - old.X;
_shiftZ += pos.Z - old.Z;
if (_shiftX < 0)
{
_shiftX += _tileSizeX;
dbShiftMatrixRight(_terNo);
}
if (_shiftX >= _tileSizeX)
{
_shiftX -= _tileSizeX;
dbShiftMatrixLeft(_terNo);
}
if (_shiftZ < 0)
{
_shiftZ += _tileSizeZ;
dbShiftMatrixDown(_terNo);
}
if (_shiftZ >= _tileSizeZ)
{
_shiftZ -= _tileSizeZ;
dbShiftMatrixUp(_terNo);
}
float mx = (pos.X - _width / 2) - _shiftX;
float mz = (pos.Z - _depth / 2) - _shiftZ;
Position(Vector3(mx, 0, mz));
}
I'm simply getting the entire matrix moving along with the player, with no shifting. Funny thing is, if I remove the shift commands, I get the exact same results.
Does anyone know what's causing this? Anyone know an easy way to simulate the commands manually?
Thanks
"everyone forgets a semi-colon sometimes." - Phaelax