cassius Posted June 29, 2013 Share Posted June 29, 2013 The scene in my game has a lot of flicker particularly when I move the mouse. Does anyone know how I can apply some linear smoothing? Or whatever else will work. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Marleys Ghost Posted June 29, 2013 Share Posted June 29, 2013 Can you define "flicker" Cass? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
cassius Posted June 29, 2013 Author Share Posted June 29, 2013 its a very slight flicker of character (third person) when I move it. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Marleys Ghost Posted June 29, 2013 Share Posted June 29, 2013 Can you post a video? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
cassius Posted June 29, 2013 Author Share Posted June 29, 2013 No I am unable to do that. aggror mentioned smoothing but didn't elaborate on it Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Marleys Ghost Posted June 29, 2013 Share Posted June 29, 2013 Demo .exe? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
AggrorJorn Posted June 29, 2013 Share Posted June 29, 2013 I don't think smoothing is the answer here. It looks like it is something completely different. Can you export the project as an exe? Quote Link to comment Share on other sites More sharing options...
cassius Posted June 30, 2013 Author Share Posted June 30, 2013 I was wrong about mouse movement causing this flickering. It only happens with keyboard movement. ie w.a.s.d.The code is largely aggrors third person tutorial code exept I have replaced the cylinder with my character. The only other change is in the value of maxcamoffset which I changed to -1.2 to bring character nearer to camera. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Marleys Ghost Posted June 30, 2013 Share Posted June 30, 2013 Can you post your routine? and more info on how you are setting up the parenting with the pivot? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
cassius Posted June 30, 2013 Author Share Posted June 30, 2013 #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } //Camera storage Vec3 camRotation; Vec2 centerMouse; Vec2 mouseDifference; float mouseSensitivity; Vec3 position;// for entity distance float dist; //Player Model* jane = NULL; Entity* player = NULL; Model* badguy = NULL; //Speeds Vec3 playerMovement; float moveSpeed; float strafeSpeed; //jump and crouch float jumpForce; float tempJumpForce; bool crouched; float playerHeight = 6; float playerCrouchHeight; // animation sequences int janeseq; int badguyseq; float cameraTopAngle; float cameraBottomAngle; float camSmoothing; //TPS controls Pivot* fpsPivot; Pivot* tpsPivot; Entity* bg_control; float maxCamOffset; float minCamOffset; Vec3 oldCamPos; // flags bool jane_alive = true; bool badguy_alive = true; bool App::Start() { //Create a window window = Window::Create("ThirdPerson04", 200, 0, 1200,900); //Create a context context = Context::Create(window); //Create a world world = World::Create(); //Create a camera camera = Camera::Create(); camera->Move(0,2,-5); //Hide the mouse cursor window->HideMouse(); Map::Load("Maps/start.map"); //Move the mouse to the center of the screen centerMouse = Vec2(context->GetWidth()/2,context->GetHeight()/2 ); window->SetMousePosition(centerMouse.x, centerMouse.y); mouseSensitivity = 20; //Create the player player = Pivot::Create(); player->SetPosition(0,4,0); player->SetMass(60); player->SetPhysicsMode(Entity::CharacterPhysics); //Create camera pivot fpsPivot = Pivot::Create(); tpsPivot = Pivot::Create(); // Load characters jane = Model::Load("Models/characters/fem/fem.mdl"); badguy = Model::Load("Models/characters/badguy/badguy.mdl"); //--------------------------------------- jane->SetParent(player,false); //jane->SetScale(0.2,0,0); jane->SetPosition(0,1.0,0); //Set some variables moveSpeed = 2; strafeSpeed = 2; crouched = false; playerHeight = 1.8; playerCrouchHeight = 0.8; jumpForce = 7; cameraTopAngle = -45; cameraBottomAngle = 80; camSmoothing = 8.0; badguy_setup(); //Tps camera maxCamOffset =-1.5; minCamOffset = 4.5; return true; } // **************** Main loop ************ bool App::Loop() { if (window->Closed()||window->KeyHit(Key::Escape)) return false; while(jane_alive) { Vec3 currentMousePos = window->GetMousePosition(); mouseDifference.x = currentMousePos.x - centerMouse.x; mouseDifference.y = currentMousePos.y - centerMouse.y; //Adjust and set the camera rotation float tempX = camRotation.x + (mouseDifference.y / mouseSensitivity); if(tempX > cameraTopAngle && tempX < cameraBottomAngle ) camRotation.x = tempX; camRotation.y += mouseDifference.x / mouseSensitivity; fpsPivot->SetRotation(camRotation); window->SetMousePosition(centerMouse.x, centerMouse.y); //Player Movement playerMovement.x = (window->KeyDown(Key:) - window->KeyDown(Key::A)) * Time::GetSpeed() * strafeSpeed; playerMovement.z = (window->KeyDown(Key::W) - window->KeyDown(Key::S)) * Time::GetSpeed() * moveSpeed; if(window->KeyDown(Key::W) || window->KeyDown(Key::S)) { janeseq = 14;// walk animate_jane(); } // Check for jumping tempJumpForce = 0; if(window->KeyHit(Key::Space) && !(player->GetAirborne()) ) tempJumpForce = jumpForce; if(window->KeyHit(Key::C)) crouched = !crouched; player->SetInput(camRotation.y, playerMovement.z, playerMovement.x, tempJumpForce * Time::GetSpeed(), crouched, 1); Vec3 tempFpsPos = fpsPivot->GetPosition(); Vec3 playerPos = player->GetPosition(); playerPos.y += (crouched ? playerCrouchHeight : playerHeight); tempFpsPos.y = Math::Curve(playerPos.y, tempFpsPos.y, camSmoothing * Time::GetSpeed()); tempFpsPos = Vec3(playerPos.x, tempFpsPos.y ,playerPos.z); fpsPivot->SetPosition(tempFpsPos); camera->SetPosition(fpsPivot->GetPosition()); camera->SetRotation(fpsPivot->GetRotation()); //Calculate the furthest TPS pivot position tpsPivot->SetPosition(fpsPivot->GetPosition()); tpsPivot->SetRotation(fpsPivot->GetRotation()); tpsPivot->Move(0, -0.5, maxCamOffset, false); camera->SetPosition(tpsPivot->GetPosition()); PickInfo pick; if(world->Pick(fpsPivot->GetPosition(), tpsPivot->GetPosition(), pick, 0, true )) { //Store distance float distance = fpsPivot->GetPosition().DistanceToPoint(pick.position); printf((String(distance) + "\n").c_str()); if(distance < minCamOffset) { camera->SetPosition(fpsPivot->GetPosition()); } else { camera->SetPosition(pick.position); } } else { camera->SetPosition(tpsPivot->GetPosition()); } //---- Position characters ----------------------------- //---------------------------------------------------- // badguy walking position = jane->GetPosition(true); dist = position.DistanceToPoint(badguy->GetPosition(true)); if(dist <= 19) { badguy->Point(jane,2,Time::GetSpeed()*0.1); badguyseq = 2; // walk animate_badguy(); bg_control->Follow(player, 2.0, 100); //bg_control->GoToPoint(player->GetPosition(),2,1); } //----------------------------------------------- Time::Update(); world->Update(); world->Render(); context->Sync(true); return true; } } // *************************** FUNCTIONS ******************** void animate_jane() { jane->SetAnimationFrame(Time::GetCurrent()/25.0,1,janeseq); } // ------------------------------------------- void badguy_setup() { bg_control = Pivot::Create(); bg_control->SetMass(90); bg_control->SetPhysicsMode(Entity::CharacterPhysics); bg_control->SetPosition(-8.5,5.75,1.25); badguy->SetParent(bg_control,false); badguy->Move(0,1.4,0); } void animate_badguy() { badguy->SetAnimationFrame(Time::GetCurrent()/40.0,1,badguyseq); } //--------------------------------------------------------------- //------------------------------------------------------------------------------------------- Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 1, 2013 Share Posted July 1, 2013 Could you also post an exe? If you uncomment the badguy creation and everything else that has nothing to do with the player, do you get the same result? Quote Link to comment Share on other sites More sharing options...
cassius Posted July 1, 2013 Author Share Posted July 1, 2013 I found that if I alter the niaxcamoffset value then alter the mincamoffset by a similar amount it works smoothly but strafe causes flutter of character. But I won't need that feature as I have no animation for sidestepping character.Your code works fine with the cylinder. Have you tried it with a character?Thanks for reply.I will try what you suggest. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
cassius Posted July 2, 2013 Author Share Posted July 2, 2013 I thought what I said in my previouse thread (above) had solved the problem but it did not. However it seems that parenting to the player was causing the flutter.I removed parenting and it now works perfectly. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.