A simple question:
When I position a DirectLabel based on the mouse position I need todo this:
self.cursor.setPos(1.33*x, 0, y)
What is the easiest way to get the aspect ratio for the window? Are there a couple of nice funcitons that give me the current window height and width?
If you look in direct/showbase/ShowBase.py you will find a function called getAspectRatio() I forget what you need to pass in
Also, there is a function called enableSoftwareMouse or something which shows you how to setup a software mouse pointer.
Sorry I cant be more specific at the moment, but hopefully this will put you on the right tracks.
That was me. Forgot I was not logged in.
Right, Im home I can construct a real reply now
To get the aspect ratio for the main window use…
Or, if this is for a different window then use…
Now the fun bit. Try this out…
The code for this is handy to know ( taken from ShowBase.py )…
Creates some geometry and parents it to render2d to show
the currently-known mouse position. Useful if the mouse
pointer is invisible for some reason.
mouseViz = self.render2d.attachNewNode('mouseViz')
lilsmiley = loader.loadModel('lilsmiley')
aspectRatio = self.getAspectRatio()
# Scale the smiley face to 32x32 pixels.
32.0 / self.win.getHeight() / aspectRatio,
1.0, 32.0 / self.win.getHeight())
If you will use a similar scale, then remember to change the self.win to base.win
Hope this helps!
Thanks Sandman, thats exactly what I needed.