more render improvements

This commit is contained in:
Mark Vejvoda 2013-06-12 01:24:10 +00:00
parent a516b0eb0d
commit 836172f87c
4 changed files with 61 additions and 48 deletions

View File

@ -2105,13 +2105,16 @@ void Game::update() {
float angle=rotation+180;
#ifdef USE_STREFLOP
c.z=c.z+4*streflop::cosf(static_cast<streflop::Simple>(degToRad(angle)));
c.x=c.x+4*streflop::sinf(static_cast<streflop::Simple>(degToRad(angle)));
#else
c.z=c.z+4*cosf(degToRad(angle));
c.x=c.x+4*sinf(degToRad(angle));
#endif
//#ifdef USE_STREFLOP
// c.z=c.z+4*streflop::cosf(static_cast<streflop::Simple>(degToRad(angle)));
// c.x=c.x+4*streflop::sinf(static_cast<streflop::Simple>(degToRad(angle)));
//#else
// c.z=c.z+4*cosf(degToRad(angle));
// c.x=c.x+4*sinf(degToRad(angle));
//#endif
c.z=c.z+4*std::cos(degToRad(angle));
c.x=c.x+4*std::sin(degToRad(angle));
c.y=c.y+currentCameraFollowUnit->getType()->getHeight()/2.f+2.0f;
getGameCameraPtr()->setPos(c);

View File

@ -145,11 +145,12 @@ void GameCamera::update(){
//free state
if(state==sFree ){
#ifdef USE_STREFLOP
if(streflop::fabs(static_cast<streflop::Simple>(rotate)) == 1){
#else
if(fabs(rotate) == 1){
#endif
//#ifdef USE_STREFLOP
// if(streflop::fabs(static_cast<streflop::Simple>(rotate)) == 1){
//#else
// if(fabs(rotate) == 1){
//#endif
if(std::fabs(rotate) == 1){
rotateHV(speed*5*rotate, 0);
}
if(move.y>0){
@ -226,15 +227,18 @@ Quad2i GameCamera::computeVisibleQuad() {
float farDist = 90.f * (pos.y > nearDist ? pos.y / 15.f : 1.f);
const float viewDegree = 180.f;
#ifdef USE_STREFLOP
Vec2f v(streflop::sinf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng))), streflop::cosf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng))));
Vec2f v1(streflop::sinf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng - fov))), streflop::cosf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng - fov))));
Vec2f v2(streflop::sinf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng + fov))), streflop::cosf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng + fov))));
#else
Vec2f v(sinf(degToRad(viewDegree - hAng)), cosf(degToRad(viewDegree - hAng)));
Vec2f v1(sinf(degToRad(viewDegree - hAng - fov)), cosf(degToRad(viewDegree - hAng - fov)));
Vec2f v2(sinf(degToRad(viewDegree - hAng + fov)), cosf(degToRad(viewDegree - hAng + fov)));
#endif
//#ifdef USE_STREFLOP
// Vec2f v(streflop::sinf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng))), streflop::cosf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng))));
// Vec2f v1(streflop::sinf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng - fov))), streflop::cosf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng - fov))));
// Vec2f v2(streflop::sinf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng + fov))), streflop::cosf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng + fov))));
//#else
// Vec2f v(sinf(degToRad(viewDegree - hAng)), cosf(degToRad(viewDegree - hAng)));
// Vec2f v1(sinf(degToRad(viewDegree - hAng - fov)), cosf(degToRad(viewDegree - hAng - fov)));
// Vec2f v2(sinf(degToRad(viewDegree - hAng + fov)), cosf(degToRad(viewDegree - hAng + fov)));
//#endif
Vec2f v(std::sin(degToRad(viewDegree - hAng)), std::cos(degToRad(viewDegree - hAng)));
Vec2f v1(std::sin(degToRad(viewDegree - hAng - fov)), std::cos(degToRad(viewDegree - hAng - fov)));
Vec2f v2(std::sin(degToRad(viewDegree - hAng + fov)), std::cos(degToRad(viewDegree - hAng + fov)));
v.normalize(false);
v1.normalize(false);
@ -341,13 +345,15 @@ void GameCamera::rotateToVH(float v, float h) {
}
void GameCamera::zoom(float dist) {
#ifdef USE_STREFLOP
float flatDist = dist * streflop::cosf(static_cast<streflop::Simple>(degToRad(vAng)));
Vec3f offset(flatDist * streflop::sinf(static_cast<streflop::Simple>(degToRad(hAng))), dist * streflop::sinf(static_cast<streflop::Simple>(degToRad(vAng))), flatDist * -streflop::cosf(static_cast<streflop::Simple>(degToRad(hAng))));
#else
float flatDist = dist * cosf(degToRad(vAng));
Vec3f offset(flatDist * sinf(degToRad(hAng)), dist * sinf(degToRad(vAng)), flatDist * -cosf(degToRad(hAng)));
#endif
//#ifdef USE_STREFLOP
// float flatDist = dist * streflop::cosf(static_cast<streflop::Simple>(degToRad(vAng)));
// Vec3f offset(flatDist * streflop::sinf(static_cast<streflop::Simple>(degToRad(hAng))), dist * streflop::sinf(static_cast<streflop::Simple>(degToRad(vAng))), flatDist * -streflop::cosf(static_cast<streflop::Simple>(degToRad(hAng))));
//#else
// float flatDist = dist * cosf(degToRad(vAng));
// Vec3f offset(flatDist * sinf(degToRad(hAng)), dist * sinf(degToRad(vAng)), flatDist * -cosf(degToRad(hAng)));
//#endif
float flatDist = dist * std::cos(degToRad(vAng));
Vec3f offset(flatDist * std::sin(degToRad(hAng)), dist * std::sin(degToRad(vAng)), flatDist * -std::cos(degToRad(hAng)));
destPos += offset;
}
@ -421,11 +427,12 @@ void GameCamera::clampAng() {
//move camera forwad but never change heightFactor
void GameCamera::moveForwardH(float d, float response) {
#ifdef USE_STREFLOP
Vec3f offset(streflop::sinf(static_cast<streflop::Simple>(degToRad(hAng))) * d, 0.f, -streflop::cosf(static_cast<streflop::Simple>(degToRad(hAng))) * d);
#else
Vec3f offset(sinf(degToRad(hAng)) * d, 0.f, -cosf(degToRad(hAng)) * d);
#endif
//#ifdef USE_STREFLOP
// Vec3f offset(streflop::sinf(static_cast<streflop::Simple>(degToRad(hAng))) * d, 0.f, -streflop::cosf(static_cast<streflop::Simple>(degToRad(hAng))) * d);
//#else
// Vec3f offset(sinf(degToRad(hAng)) * d, 0.f, -cosf(degToRad(hAng)) * d);
//#endif
Vec3f offset(std::sin(degToRad(hAng)) * d, 0.f, -std::cos(degToRad(hAng)) * d);
destPos += offset;
pos.x += offset.x * response;
pos.z += offset.z * response;
@ -433,11 +440,12 @@ void GameCamera::moveForwardH(float d, float response) {
//move camera to a side but never change heightFactor
void GameCamera::moveSideH(float d, float response){
#ifdef USE_STREFLOP
Vec3f offset(streflop::sinf(static_cast<streflop::Simple>(degToRad(hAng+90))) * d, 0.f, -streflop::cosf(static_cast<streflop::Simple>(degToRad(hAng+90))) * d);
#else
Vec3f offset(sinf(degToRad(hAng+90)) * d, 0.f, -cosf(degToRad(hAng+90)) * d);
#endif
//#ifdef USE_STREFLOP
// Vec3f offset(streflop::sinf(static_cast<streflop::Simple>(degToRad(hAng+90))) * d, 0.f, -streflop::cosf(static_cast<streflop::Simple>(degToRad(hAng+90))) * d);
//#else
// Vec3f offset(sinf(degToRad(hAng+90)) * d, 0.f, -cosf(degToRad(hAng+90)) * d);
//#endif
Vec3f offset(std::sin(degToRad(hAng+90)) * d, 0.f, -std::cos(degToRad(hAng+90)) * d);
destPos += offset;
pos.x += (destPos.x - pos.x) * response;
pos.z += (destPos.z - pos.z) * response;

View File

@ -183,11 +183,12 @@ void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPo
if(d < audibleDist){
float vol= (1.f-d/audibleDist)*fxVolume;
#ifdef USE_STREFLOP
float correctedVol= streflop::log10(streflop::log10(static_cast<streflop::Simple>(vol*9+1))*9+1);
#else
float correctedVol= log10(log10(vol*9+1)*9+1);
#endif
//#ifdef USE_STREFLOP
// float correctedVol= streflop::log10(streflop::log10(static_cast<streflop::Simple>(vol*9+1))*9+1);
//#else
// float correctedVol= log10(log10(vol*9+1)*9+1);
//#endif
float correctedVol= std::log10(std::log10(vol*9+1)*9+1);
staticSound->setVolume(correctedVol);

View File

@ -253,12 +253,13 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){
float angleV= radToDeg(std::atan2(flatDirection.length(false), direction.y)) - 90.f;
glRotatef(angleV, rotVector.x, rotVector.y, rotVector.z);
#ifdef USE_STREFLOP
float angleH= radToDeg(streflop::atan2(static_cast<streflop::Simple>(direction.x), static_cast<streflop::Simple>(direction.z)));
#else
float angleH= radToDeg(atan2(direction.x, direction.z));
#endif
//#ifdef USE_STREFLOP
// float angleH= radToDeg(streflop::atan2(static_cast<streflop::Simple>(direction.x), static_cast<streflop::Simple>(direction.z)));
//#else
// float angleH= radToDeg(atan2(direction.x, direction.z));
//#endif
float angleH= radToDeg(std::atan2(direction.x, direction.z));
glRotatef(angleH, 0.f, 1.f, 0.f);
//render