FirstPersonManipulator and moving step, Close GConsoleRef by pressing ~

13 views
Skip to first unread message

Loki

unread,
Dec 5, 2009, 5:36:21 AM12/5/09
to G3D Users
Good day!

I rendered a sight in such way:

void App::renderCross(RenderDevice* rd)
{
rd->push2D();
rd->setTexture(0, cross);
rd->setBlendFunc(RenderDevice::BLEND_SRC_ALPHA,
RenderDevice::BLEND_ONE_MINUS_SRC_ALPHA);
Draw::rect2D(
Rect2D::xywh(rd->width()/2 -32, rd->height()/2 - 32, 64, 64),
rd, Color4(1,1,1,0.7f));
rd->pop2D();
}

This works fine but have a little problem. A sight is moving not per
pixel but more pixels. I tried to change FirstPersonManipulatorRef-
>setTurnRate(1.0) and when I describe a circle by mouse, a sight
describe rhombus. How to change this behavior?

And another question. I want the console is closed by pressing "~" not
ESC. I suppose I should create new class which inherits GConsole
public methods and override onUserInput() or onEvent(). Which method
must be overridden?

Thanks.

Morgan McGuire

unread,
Dec 5, 2009, 12:31:49 PM12/5/09
to g3d-...@googlegroups.com

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan


On Sat, Dec 5, 2009 at 5:36 AM, Loki <lok...@gmail.com> wrote:
I rendered a sight in such way:

That's how I do it too.
 
This works fine but have a little problem. A sight is moving not per
pixel but more pixels. I tried to change FirstPersonManipulatorRef-
>setTurnRate(1.0) and when I describe a circle by mouse, a sight
describe rhombus. How to change this behavior?

So if you move the mouse so that your hand is tracing a circle on the mouse pad, you see the view moving in a slanted square?  The only way I could imagine that happening is if your frame rate is so low that you're getting only very few samples.

The turn rate is specified in radians per second, which has nothing to do with pixels. 1.0 would be a little low. 

Note also G3D::FirstPersonManipulator::MouseMode
 
And another question. I want the console is closed by pressing "~" not
ESC. I suppose I should create new class which inherits GConsole
public methods and override onUserInput() or onEvent(). Which method
must be overridden?


I recommend that you make a complete copy of GConsole and then edit it as you like because the class is deprecated and going away soon.  Having your own copy means that your code won't break when you upgrade to the next G3D.

Beware that the reason ~ doesn't close the console is that you need ~ to type paths into the console on Unix.  On Windows you don't have to worry about that of course.

-m
 
Thanks.

--

You received this message because you are subscribed to the Google Groups "G3D Users" group.
To post to this group, send email to g3d-...@googlegroups.com.
To unsubscribe from this group, send email to g3d-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/g3d-users?hl=en.



Loki

unread,
Dec 5, 2009, 3:15:30 PM12/5/09
to G3D Users
> So if you move the mouse so that your hand is tracing a circle on the mouse
> pad, you see the view moving in a slanted square?  The only way I could
> imagine that happening is if your frame rate is so low that you're getting
> only very few samples.

Yes, exactly. I tried to run it on 260gtx and the result was the same.
With enabled showRenderingStats fps is shown averaging 60

> The turn rate is specified in radians per second, which has nothing to do
> with pixels. 1.0 would be a little low.

You're right, it's too low but at least it's moving smoothly not
discretely.

> Beware that the reason ~ doesn't close the console is that you need ~ to
> type paths into the console on Unix.  On Windows you don't have to worry
> about that of course.

I just thought about it. User's home directory.

Morgan McGuire

unread,
Dec 5, 2009, 3:18:29 PM12/5/09
to g3d-...@googlegroups.com
On Sat, Dec 5, 2009 at 3:15 PM, Loki <lok...@gmail.com> wrote:
> So if you move the mouse so that your hand is tracing a circle on the mouse
> pad, you see the view moving in a slanted square?  The only way I could
> imagine that happening is if your frame rate is so low that you're getting
> only very few samples.

Yes, exactly. I tried to run it on 260gtx and the result was the same.
With enabled showRenderingStats fps is shown averaging 60


Sorry, I've never seen this problem.  I'd debug it by debugPrintf-ing the mouse coordinates in onUserInput to see if your mouse is interacting with the underlying OS API in some weird way.

-m
 

> The turn rate is specified in radians per second, which has nothing to do
> with pixels. 1.0 would be a little low.

You're right, it's too low but at least it's moving smoothly not
discretely.

> Beware that the reason ~ doesn't close the console is that you need ~ to
> type paths into the console on Unix.  On Windows you don't have to worry
> about that of course.

I just thought about it. User's home directory.

Loki

unread,
Dec 6, 2009, 3:32:45 PM12/6/09
to G3D Users
debugPrintf shows nothing :(( Where does it logs?

On 6 дек, 01:18, Morgan McGuire <morga...@gmail.com> wrote:
> > g3d-users+...@googlegroups.com<g3d-users%2Bunsu...@googlegroups.com>
> > .

Morgan McGuire

unread,
Dec 6, 2009, 4:52:08 PM12/6/09
to g3d-...@googlegroups.com
debugPrintf goes to the console on Unix and the Output window in Visual Studio.

-m


Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan


To unsubscribe from this group, send email to g3d-users+...@googlegroups.com.

corey taylor

unread,
Dec 6, 2009, 5:37:43 PM12/6/09
to g3d-...@googlegroups.com
You can also use screenPrintf if you just want to see the last set of values.
 
 
corey

Loki

unread,
Dec 6, 2009, 11:29:43 PM12/6/09
to G3D Users
Thank you, Morgan and Corey!

Unfortunately, neither debugPrintf nor screenPrintf (I also tried
console->printf()) showed nothing special. I noticed some feature.
When I trace circle on mouse pad slowly, it works fine. But when I
accelerates it start to cut corners (turn circle to slanted square).
It appears only when first-person camera control is enabled. In case
first-person camera control is disabled cursor moves fine in any way.

I'm going to try compiling binary file on another computer to locate
problem.

Thanks a lot

corey taylor

unread,
Dec 8, 2009, 12:15:37 AM12/8/09
to g3d-...@googlegroups.com
What happens when you don't hide the mouse cursor?  Does the OS cursor match what you see in G3D?
 
 
Ignore the documentation errors telling you to look at other functions -- not sure why it says that.  Set it to 0 to make the mouse visible (this is confusing).
 
corey

Loki

unread,
Dec 8, 2009, 12:55:13 PM12/8/09
to G3D Users
Thanks for suggestion...

I set setMouseHideCount to 0. The cursor and sight are not
synchronized. I think it is normal 'cause defaultControll has turn
rate parameter in radians per second unit but the cursor uses 2D-
coordinate area. I start to believe that it's normal behavior. Could
someone tell me if your sight moves smoothly or not. Additionally with
low TurnRate (I use 1.0 for testing purposes) starts to "cut corners"
in a circle. And I am sorry if I explain something not clear 'cause
English is not native for me

corey taylor

unread,
Dec 8, 2009, 8:58:50 PM12/8/09
to g3d-...@googlegroups.com
Post some sample code, and I will look at it.
 
corey

Loki

unread,
Dec 9, 2009, 7:54:46 AM12/9/09
to G3D Users
What exact code do you mean? I use demos/starter as a starting point
and mouse works so without any modifications demo. It's feeling that
the values are rounded. I trace quadrant on a mouse pad but sight
moves line under 45 degrees. I tried such hint just:

void App::onUserInput(UserInput *ui)
{
if (debuged)
logPrintf("%f\t%f\n", ui->mouseDX(), ui->mouseDY());
}

Then I tried to trace quadrant as decribe above and have got 2 columns
of float digits in a logfile. I built diagram from its and it looked
as almost straight line slanted 45 degrees

Loki

unread,
Dec 9, 2009, 1:57:35 PM12/9/09
to G3D Users
Good day!

I was able to localize the problem. If I reduce system mouse rate in
WinXP then mouse in G3D starts to work fine without "cutting corners".
The problem wasn't in neither G3D::UserInput nor
G3D::FirstPersonManipulator

Morgan and Corey, thank you for your patience.

corey taylor

unread,
Dec 9, 2009, 2:02:30 PM12/9/09
to g3d-...@googlegroups.com

I'm interested in this problem.  Can you point me to the configuration you changed or a msdn article on it?

What was the value before you changed?

corey

On Dec 9, 2009 1:57 PM, "Loki" <lok...@gmail.com> wrote:

Good day!

I was able to localize the problem. If I reduce system mouse rate in
WinXP then mouse in G3D starts to work fine without "cutting corners".
The problem wasn't in neither G3D::UserInput nor
G3D::FirstPersonManipulator

Morgan and Corey, thank you for your patience.

On 9 дек, 17:54, Loki <loki...@gmail.com> wrote: > What exact code do you mean? I use demos/starter...

Loki

unread,
Dec 9, 2009, 2:24:12 PM12/9/09
to G3D Users
Actually I didn't read any article of MSDN and didn't make any changes
in sources. I just reduced WinXP's mouse rate from 4 points to 1. And
I noticed that FirstPersonManipulator's turn rate dependes on OS API
mouse rate, is it true?

On 10 дек, 00:02, corey taylor <corey.tay...@gmail.com> wrote:
> I'm interested in this problem.  Can you point me to the configuration you
> changed or a msdn article on it?
>
> What was the value before you changed?
>
> corey
>

Loki

unread,
Dec 9, 2009, 2:25:35 PM12/9/09
to G3D Users
Of course it's too slow (1 point system rate) but now it's clear where
my problem was

Loki

unread,
Dec 14, 2009, 10:00:10 AM12/14/09
to G3D Users
Good day!

I've finally resolved the problem. I've copied
FirstPersonManipulator.cpp, FirstPersonManipulator.h into my project.
Then I modified first file and replaced these strings in "onSimulation
(...)":
delta = m_userInput->mouseDXY() / 100.0f;
m_yaw += delta.x;
m_pitch += delta.y;
with these ones:
delta = m_userInput->mouseDXY() / 2500.0f;
m_yaw += delta.x * m_maxTurnRate;
m_pitch += delta.y * m_maxTurnRate;
and commented out "Turn Rate Limiter". Then I created my own
manipulator as default. Now sight moves smoothly without any "cutting
corners"

Thanks to you, Morgan and Corey...

Morgan McGuire

unread,
Dec 15, 2009, 12:33:15 PM12/15/09
to g3d-...@googlegroups.com
Actually, thanks to you.  I patched the code in CVS with:

        // Time is not a factor in rotation because the mouse movement has already been
        // integrated over time (unlike keyboard presses)
        delta = m_maxTurnRate * m_userInput->mouseDXY() / 2000.0f;

and removed the rate limiter.  I haven't decided whether that 2000 should be window->width() * 1.5 or just constant as it is here.


-m

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan


Reply all
Reply to author
Forward
0 new messages