mirror of
https://github.com/glest/glest-source.git
synced 2025-08-22 16:02:50 +02:00
more render improvements
This commit is contained in:
@@ -2105,13 +2105,16 @@ void Game::update() {
|
|||||||
float angle=rotation+180;
|
float angle=rotation+180;
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
c.z=c.z+4*streflop::cosf(static_cast<streflop::Simple>(degToRad(angle)));
|
// 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)));
|
// c.x=c.x+4*streflop::sinf(static_cast<streflop::Simple>(degToRad(angle)));
|
||||||
#else
|
//#else
|
||||||
c.z=c.z+4*cosf(degToRad(angle));
|
// c.z=c.z+4*cosf(degToRad(angle));
|
||||||
c.x=c.x+4*sinf(degToRad(angle));
|
// c.x=c.x+4*sinf(degToRad(angle));
|
||||||
#endif
|
//#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;
|
c.y=c.y+currentCameraFollowUnit->getType()->getHeight()/2.f+2.0f;
|
||||||
|
|
||||||
getGameCameraPtr()->setPos(c);
|
getGameCameraPtr()->setPos(c);
|
||||||
|
@@ -145,11 +145,12 @@ void GameCamera::update(){
|
|||||||
|
|
||||||
//free state
|
//free state
|
||||||
if(state==sFree ){
|
if(state==sFree ){
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
if(streflop::fabs(static_cast<streflop::Simple>(rotate)) == 1){
|
// if(streflop::fabs(static_cast<streflop::Simple>(rotate)) == 1){
|
||||||
#else
|
//#else
|
||||||
if(fabs(rotate) == 1){
|
// if(fabs(rotate) == 1){
|
||||||
#endif
|
//#endif
|
||||||
|
if(std::fabs(rotate) == 1){
|
||||||
rotateHV(speed*5*rotate, 0);
|
rotateHV(speed*5*rotate, 0);
|
||||||
}
|
}
|
||||||
if(move.y>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);
|
float farDist = 90.f * (pos.y > nearDist ? pos.y / 15.f : 1.f);
|
||||||
const float viewDegree = 180.f;
|
const float viewDegree = 180.f;
|
||||||
|
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
Vec2f v(streflop::sinf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng))), streflop::cosf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng))));
|
// 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 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))));
|
// Vec2f v2(streflop::sinf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng + fov))), streflop::cosf(static_cast<streflop::Simple>(degToRad(viewDegree - hAng + fov))));
|
||||||
#else
|
//#else
|
||||||
Vec2f v(sinf(degToRad(viewDegree - hAng)), cosf(degToRad(viewDegree - hAng)));
|
// Vec2f v(sinf(degToRad(viewDegree - hAng)), cosf(degToRad(viewDegree - hAng)));
|
||||||
Vec2f v1(sinf(degToRad(viewDegree - hAng - fov)), cosf(degToRad(viewDegree - hAng - fov)));
|
// Vec2f v1(sinf(degToRad(viewDegree - hAng - fov)), cosf(degToRad(viewDegree - hAng - fov)));
|
||||||
Vec2f v2(sinf(degToRad(viewDegree - hAng + fov)), cosf(degToRad(viewDegree - hAng + fov)));
|
// Vec2f v2(sinf(degToRad(viewDegree - hAng + fov)), cosf(degToRad(viewDegree - hAng + fov)));
|
||||||
#endif
|
//#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);
|
v.normalize(false);
|
||||||
v1.normalize(false);
|
v1.normalize(false);
|
||||||
@@ -341,13 +345,15 @@ void GameCamera::rotateToVH(float v, float h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameCamera::zoom(float dist) {
|
void GameCamera::zoom(float dist) {
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
float flatDist = dist * streflop::cosf(static_cast<streflop::Simple>(degToRad(vAng)));
|
// 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))));
|
// 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
|
//#else
|
||||||
float flatDist = dist * cosf(degToRad(vAng));
|
// float flatDist = dist * cosf(degToRad(vAng));
|
||||||
Vec3f offset(flatDist * sinf(degToRad(hAng)), dist * sinf(degToRad(vAng)), flatDist * -cosf(degToRad(hAng)));
|
// Vec3f offset(flatDist * sinf(degToRad(hAng)), dist * sinf(degToRad(vAng)), flatDist * -cosf(degToRad(hAng)));
|
||||||
#endif
|
//#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;
|
destPos += offset;
|
||||||
}
|
}
|
||||||
@@ -421,11 +427,12 @@ void GameCamera::clampAng() {
|
|||||||
|
|
||||||
//move camera forwad but never change heightFactor
|
//move camera forwad but never change heightFactor
|
||||||
void GameCamera::moveForwardH(float d, float response) {
|
void GameCamera::moveForwardH(float d, float response) {
|
||||||
#ifdef USE_STREFLOP
|
//#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);
|
// Vec3f offset(streflop::sinf(static_cast<streflop::Simple>(degToRad(hAng))) * d, 0.f, -streflop::cosf(static_cast<streflop::Simple>(degToRad(hAng))) * d);
|
||||||
#else
|
//#else
|
||||||
Vec3f offset(sinf(degToRad(hAng)) * d, 0.f, -cosf(degToRad(hAng)) * d);
|
// Vec3f offset(sinf(degToRad(hAng)) * d, 0.f, -cosf(degToRad(hAng)) * d);
|
||||||
#endif
|
//#endif
|
||||||
|
Vec3f offset(std::sin(degToRad(hAng)) * d, 0.f, -std::cos(degToRad(hAng)) * d);
|
||||||
destPos += offset;
|
destPos += offset;
|
||||||
pos.x += offset.x * response;
|
pos.x += offset.x * response;
|
||||||
pos.z += offset.z * 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
|
//move camera to a side but never change heightFactor
|
||||||
void GameCamera::moveSideH(float d, float response){
|
void GameCamera::moveSideH(float d, float response){
|
||||||
#ifdef USE_STREFLOP
|
//#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);
|
// 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
|
//#else
|
||||||
Vec3f offset(sinf(degToRad(hAng+90)) * d, 0.f, -cosf(degToRad(hAng+90)) * d);
|
// Vec3f offset(sinf(degToRad(hAng+90)) * d, 0.f, -cosf(degToRad(hAng+90)) * d);
|
||||||
#endif
|
//#endif
|
||||||
|
Vec3f offset(std::sin(degToRad(hAng+90)) * d, 0.f, -std::cos(degToRad(hAng+90)) * d);
|
||||||
destPos += offset;
|
destPos += offset;
|
||||||
pos.x += (destPos.x - pos.x) * response;
|
pos.x += (destPos.x - pos.x) * response;
|
||||||
pos.z += (destPos.z - pos.z) * response;
|
pos.z += (destPos.z - pos.z) * response;
|
||||||
|
@@ -183,11 +183,12 @@ void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPo
|
|||||||
|
|
||||||
if(d < audibleDist){
|
if(d < audibleDist){
|
||||||
float vol= (1.f-d/audibleDist)*fxVolume;
|
float vol= (1.f-d/audibleDist)*fxVolume;
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
float correctedVol= streflop::log10(streflop::log10(static_cast<streflop::Simple>(vol*9+1))*9+1);
|
// float correctedVol= streflop::log10(streflop::log10(static_cast<streflop::Simple>(vol*9+1))*9+1);
|
||||||
#else
|
//#else
|
||||||
float correctedVol= log10(log10(vol*9+1)*9+1);
|
// float correctedVol= log10(log10(vol*9+1)*9+1);
|
||||||
#endif
|
//#endif
|
||||||
|
float correctedVol= std::log10(std::log10(vol*9+1)*9+1);
|
||||||
|
|
||||||
staticSound->setVolume(correctedVol);
|
staticSound->setVolume(correctedVol);
|
||||||
|
|
||||||
|
@@ -253,12 +253,13 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){
|
|||||||
float angleV= radToDeg(std::atan2(flatDirection.length(false), direction.y)) - 90.f;
|
float angleV= radToDeg(std::atan2(flatDirection.length(false), direction.y)) - 90.f;
|
||||||
glRotatef(angleV, rotVector.x, rotVector.y, rotVector.z);
|
glRotatef(angleV, rotVector.x, rotVector.y, rotVector.z);
|
||||||
|
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
float angleH= radToDeg(streflop::atan2(static_cast<streflop::Simple>(direction.x), static_cast<streflop::Simple>(direction.z)));
|
// float angleH= radToDeg(streflop::atan2(static_cast<streflop::Simple>(direction.x), static_cast<streflop::Simple>(direction.z)));
|
||||||
#else
|
//#else
|
||||||
float angleH= radToDeg(atan2(direction.x, direction.z));
|
// float angleH= radToDeg(atan2(direction.x, direction.z));
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
float angleH= radToDeg(std::atan2(direction.x, direction.z));
|
||||||
glRotatef(angleH, 0.f, 1.f, 0.f);
|
glRotatef(angleH, 0.f, 1.f, 0.f);
|
||||||
|
|
||||||
//render
|
//render
|
||||||
|
Reference in New Issue
Block a user