XainFaith
12-07-2009 06:41:03
Hi there i have recently been developing as small level editor using Mogre and C# and i have mouse picking so objects selected but i can not seem to get and object to move using the mouse. There was a sample of sorts for this in the tutorials but it does not seem to work nore does the origanal from the tutorials compile but here is what i got and i will describe my problem in a little more depth.
protected virtual void onLeftDragged(MouseEventArgs e)
{
//normalise mouse coordinates to [0,1]
//we could have used the panel's width/height in pixels instead of viewport's width/height
float scrx = (float)e.X / mWindow.Width;
float scry = (float)e.Y / mWindow.Height;
Ray ray = cam.GetCameraToViewportRay(scrx, scry);
RaySceneQuery query = mgr.CreateRayQuery(ray);
query.SetSortByDistance(true);
RaySceneQueryResult results = query.Execute();
foreach (RaySceneQueryResultEntry entry in results)
{
if (entry.worldFragment != null)
{
this.mCurrentObject.Position = entry.worldFragment.singleIntersection;
}
}
return;
}
For the most part this codes nothing mostly because it never gets a World fragment and i am not sure why.
All i really want to do is move the object with the mouse like any 3D modeling program could if someone can tell me what i am doing wrong or if i am missing something that would be great.
Anyways thanks for taking the time to read my post.
protected virtual void onLeftDragged(MouseEventArgs e)
{
//normalise mouse coordinates to [0,1]
//we could have used the panel's width/height in pixels instead of viewport's width/height
float scrx = (float)e.X / mWindow.Width;
float scry = (float)e.Y / mWindow.Height;
Ray ray = cam.GetCameraToViewportRay(scrx, scry);
RaySceneQuery query = mgr.CreateRayQuery(ray);
query.SetSortByDistance(true);
RaySceneQueryResult results = query.Execute();
foreach (RaySceneQueryResultEntry entry in results)
{
if (entry.worldFragment != null)
{
this.mCurrentObject.Position = entry.worldFragment.singleIntersection;
}
}
return;
}
For the most part this codes nothing mostly because it never gets a World fragment and i am not sure why.
All i really want to do is move the object with the mouse like any 3D modeling program could if someone can tell me what i am doing wrong or if i am missing something that would be great.
Anyways thanks for taking the time to read my post.