Hi!
Working on the gizmo for moving objects in my map editor I crashed in the a wall I can't tear down or walk around..
Here is the function checking for "dragging"
public void CheckCompDrag()
{
// Drar brukeren i X aksen?
if (SMED.Interoper.PickObject(DarkGDK.IO.Mouse.X, DarkGDK.IO.Mouse.Y, CompX.Id, CompX.Id) > 0)
{
Vec3 CameraPos = SMED.Interoper.GetCameraPosition();
Vec3 GizmoPos = Position;
float CamDist = SMED.Math.Distance3D(CameraPos, GizmoPos);
float CamAngleY = DarkGDK.Core.WrapValue(DarkGDK.Core.ATanFull(CameraPos.x - GizmoPos.x, CameraPos.z - GizmoPos.z));
if(DarkGDK.Core.WrapValue(CamAngleY - 90.0f) >= 180.0f)
{
GizmoPos.x = GizmoPos.x +-(SMED.dgdkApplication.MouseMoveX *(0.002f*CamDist));
}
else
{
GizmoPos.x = GizmoPos.x + (SMED.dgdkApplication.MouseMoveX*(0.002f*CamDist));
}
SMED.Interoper.SetPosition(SMED.fMain.list_Objects[SMED.fMain.list_SelectedObjects[0]].Id, GizmoPos);
Position = GizmoPos;
return;
}
// Drar brukeren i Y aksen?
if (SMED.Interoper.PickObject(DarkGDK.IO.Mouse.X, DarkGDK.IO.Mouse.Y, CompY.Id, CompY.Id) > 0)
{
Vec3 CameraPos = SMED.Interoper.GetCameraPosition();
Vec3 GizmoPos = Position;
float CamDist = SMED.Math.Distance3D(CameraPos, GizmoPos);
float CamAngleY = DarkGDK.Core.WrapValue(DarkGDK.Core.ATanFull(CameraPos.x - GizmoPos.x, CameraPos.z - GizmoPos.z));
GizmoPos.y = GizmoPos.y + -(SMED.dgdkApplication.MouseMoveY * (0.002f * CamDist));
SMED.Interoper.SetPosition(SMED.fMain.list_Objects[SMED.fMain.list_SelectedObjects[0]].Id, GizmoPos);
Position = GizmoPos;
return;
}
// Drar brukeren i Z aksen?
if (SMED.Interoper.PickObject(DarkGDK.IO.Mouse.X, DarkGDK.IO.Mouse.Y, CompZ.Id, CompZ.Id) > 0)
{
Vec3 CameraPos = SMED.Interoper.GetCameraPosition();
Vec3 GizmoPos = Position;
float CamDist = SMED.Math.Distance3D(CameraPos, GizmoPos);
float CamAngleY = DarkGDK.Core.WrapValue(DarkGDK.Core.ATanFull(CameraPos.x - GizmoPos.x, CameraPos.z - GizmoPos.z));
if (DarkGDK.Core.WrapValue(CamAngleY) >= 180.0f)
{
GizmoPos.z = GizmoPos.z + -(SMED.dgdkApplication.MouseMoveX * (0.002f * CamDist));
}
else
{
GizmoPos.z = GizmoPos.z + (SMED.dgdkApplication.MouseMoveX * (0.002f * CamDist));
}
SMED.Interoper.SetPosition(SMED.fMain.list_Objects[SMED.fMain.list_SelectedObjects[0]].Id, GizmoPos);
Position = GizmoPos;
return;
}
}
The program can be found at filer.raskweb.no/smed_bug.zip <- copy url into your browser.
But im pretty sure the problem is in the code..
Keep it simple.
Questions? Mail me
