Game Development Community

How control the camera by mouse(etc. model viewer)?

by Wang Guojing · in General Discussion · 09/26/2007 (6:15 pm) · 0 replies

I modify TGEA demo's scripts and want to handle mouse event when the application started.I hope that use mouse to control the camera movement and rotation(etc. model viewer).I think use setOrbitMode() function.

if mouseLeftButtonDown and drag it,the camera has been moved;
if mouseRightButtonDown and darg it,the camera has been rotated around a player.

But I have a question about bind mouse event.I changed default.bind.cs in demo\client\scripts directory.In this file,I add these codes:

moveMap.bind( mouse, button0, mouseMove );
moveMap.bind( mouse, button1, mouseRotate );

and

$MouseMove = false;
$MouseRotate = false;

function mouseMove(%val)
{
if(%val >0)
{
$MouseMove = true;
echo("MouseMove = true");
}
else
{
$MouseMove = false;
echo("MouseMove = false");
}
}

function mouseRotate(%val)
{
if(%val >0)
{
$MouseRotate = true;
echo("MouseRotate = true");
}
else
{
$MouseRotate = false;
echo("MouseRotate = false");
}
}

But it does't work.What's wrong these codes?And How tontrol camera by mouse like that model viewer in TGEA?

Thanks!