Search Results

Search found 2 results on 1 pages for 'user1010005'.

Page 1/1 | 1 

  • Zooming to point of interest

    - by user1010005
    I have the following variables: Point of interest which is the position(x,y) in pixels of the place to focus. Screen width,height which are the dimensions of the window. Zoom level which sets the zoom level of the camera. And this is the code I have so far. void Zoom(int pointOfInterestX,int pointOfInterstY,int screenWidth, int screenHeight,int zoomLevel) { glTranslatef( (pointOfInterestX/2 - screenWidth/2), (pointOfInterestY/2 - screenHeight/2),0); glScalef(zoomLevel,zoomLevel,zoomLevel); } And I want to do zoom in/out but keep the point of interest in the middle of the screen. but so far all of my attempts have failed and I would like to ask for some help.

    Read the article

  • Following a set of points?

    - by user1010005
    Lets assume that i have a set of path that an entity should follow : const int Paths = 2 Vector2D<float> Path[Paths] = { Vector2D(100,0),Vector2D(100,50) }; Now i define my entity's position in a 2D vector as follows : Vector2D<float> FollowerPosition(0,0); And now i would like to move the "follower" to the path at index 1 : int PathPosition = 0; //Start with path 1 Currently i do this : Vector2D<float>& Target = Path[PathPosition]; bool Changed = false; if (FollowerPosition.X < Target.X) FollowerPosition.X += Vel,Changed = true; if (FollowerPosition.X > Target.X) FollowerPosition.X -= Vel,Changed = true; if (FollowerPosition.Y < Target.Y) FollowerPosition.Y += Vel;,Changed = true; if (FollowerPosition.Y > Target.Y) FollowerPosition.Y -= Vel,Changed = true; if (!Changed) { PathPosition = PathPosition + 1; if (PathPosition > Paths) PathPosition = 0; } Which works except for one little detail : The movement is not smooth!! ...So i would like to ask if anyone sees anything wrong with my code. Thanks and sorry for my english.

    Read the article

1