Zooming into a planet using search in GW

Post here if you want to help developing something for FAF.

Zooming into a planet using search in GW

Postby Exotic_Retard » 14 Jan 2014, 19:28

not long ago zep told me if its so easy to make the "search result" more zoomed out why don't i do it,

so i tried doing it : D


here is the gotoplanet function in glDisplay.py which looks like its responsible for creating a vector between the camera position and where it should be and moving it there.



Code: Select all
def gotoPlanet(self, uid):
        if not uid in self.galaxy.control_points:return
        if not self.galaxy.control_points[uid].isVisible():return
       
        self.timerRotate.stop()
        self.animCam.stop()
        self.animCamMove.stop()
       
        x = self.galaxy.control_points[uid].x
        y = self.galaxy.control_points[uid].y
       
        self.destination = QtGui.QVector3D(x,y,self.zoomMax + 150)
        # here i have added 150 to the x value of the destination, which seems to be the planet coordinates and the maximum zoom in height.

        # compute camera deviation
        ir = 1.0 - (self.zoomMax)/ (self.zoomMin - (self.zoomMax)) 
        lookat = QtGui.QVector3D(self.destination.x(), self.destination.y(), self.destination.z())

        # but to look at the planet and not 150 above it i took away 150 from the z coordinate here
        lookat.setZ(lookat.z() - 151.0)
        lookat.setY(lookat.y() + pow(ir, 5.0))
        # i don't know what this does but it seems to add ~0.9 to the y value for some reason, to make it look slightly above/behind the planet?

        inter = self.rayPlaneIntersect(self.destination, self.destination-lookat, QtGui.QVector3D(0,0,0),QtGui.QVector3D(0,0,1))
        self.destination.setY(self.destination.y() - inter.y())
        self.camOriginPos = QtGui.QVector3D(self.cameraPos.x(),self.cameraPos.y(), self.cameraPos.z())
        self.vectorMove = QtGui.QVector3D(self.destination.x() - self.cameraPos.x(), self.destination.y() - self.cameraPos.y(), (self.destination.z() -self.cameraPos.z()) )

        self.animCamMove.start()

i just downloaded the source and started looking at files in notepad, and came across this function, which i changed a bit to make the destination of the camera further away from the planet (hopefully)

i wasn't sure why there was a complicated calculation for the y coordinate for the camera to look at, but maybe it doesn't matter :/

i think that an alternative way to do this would be to simply change the zoomMax variable from 70 to 220 but this will affect other things as well (like that strange ir variable, which will be slightly smaller)

i think that this is all that needs to be changed
but i dont know anything about python or programming or anything that might be useful for this, so if i was deeply (or otherwise) mistaken, i guess il just shut up on this topic :)

if im right and this works i can do all the official things and get this implemented into the lobby if zep lets me, or he could just add the 3 line change manually or something

anyone's welcome welcome to criticize this of course : )
User avatar
Exotic_Retard
Contributor
 
Posts: 1470
Joined: 21 Mar 2013, 22:51
Has liked: 557 times
Been liked: 626 times
FAF User Name: Exotic_Retard

Re: Zooming into a planet using search in GW

Postby Ze_PilOt » 14 Jan 2014, 21:36

I don't want it more zoomed out.

And your code is at best a workaround. The look at computation is necessary because of the camera tilt. If you don''t do it, you have to enter manually some offset.
- That will not work all the time.
- It will break as soon as anything change map-wise.
Nossa wrote:I've never played GPG or even heard of FA until FAF started blowing up.
User avatar
Ze_PilOt
Supreme Commander
 
Posts: 8985
Joined: 24 Aug 2011, 18:41
Location: fafland
Has liked: 18 times
Been liked: 376 times
FAF User Name: Ze_PilOt


Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest