Exemplo n.º 1
0
void AMouseController::PlayerTick(float DeltaTime)
{
	Super::PlayerTick(DeltaTime);
	FHitResult hit;
	auto gameMode = Cast<AProjectTapGameMode>(GetWorld()->GetAuthGameMode());

	//cast a ray for every 1/10 of a second
	if (raycastElapseTimeCounter < raycastElapseTime)
	{
		raycastElapseTimeCounter += DeltaTime;
		raycasted = false;
	}
	else
	{
		raycastElapseTimeCounter = 0.0f;
		raycasted = true;
		GetHitResultUnderCursor(ECC_Visibility, false, hit);
	}

	if (raycasted)
	{
		FVector origin;
		FVector direction;
		GetCameraRay(origin, direction);
		btManager.SetCameraRay(hit, origin, direction);
		checkObjectHighlight(hit);
	}

	if (bCheckForSwipe)
	{
		SendGroupedBlockingTile(hit);
	}

	btManager.Tick(DeltaTime);
}
Exemplo n.º 2
0
void main( void )
{
	Ray currentRay;

	vec3 adjustment = vec3(0.3, 1.5, 0.3);
	GetCameraRay(cam_pos + adjustment, cam_pos + cam_lookat + adjustment, currentRay);

	gl_FragColor = GetRayColor(currentRay);
}
void SceneView3D::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
{

    // Visualize the currently selected nodes
    if (selectedNode_.NotNull())
    {
        DrawNodeDebug(selectedNode_, debugRenderer_);

    }

    if (!MouseInView())
        return;

    Input* input = GetSubsystem<Input>();

    mouseLeftDown_ = false;

    if (input->GetMouseButtonPress(MOUSEB_LEFT))
    {
        if (!mouseMoved_ && !sceneEditor_->GetGizmo()->Selected())
        {
            Ray camRay  = GetCameraRay();
            PODVector<RayQueryResult> result;

            RayOctreeQuery query(result, camRay, RAY_TRIANGLE, camera_->GetFarClip(), DRAWABLE_GEOMETRY, 0x7fffffff);
            octree_->RaycastSingle(query);

            if (query.result_.Size())
            {
                const RayQueryResult& r = result[0];

                if (r.drawable_)
                {

                    VariantMap neventData;
                    neventData[EditorActiveNodeChange::P_NODE] = r.drawable_->GetNode();
                    SendEvent(E_EDITORACTIVENODECHANGE, neventData);

                }
            }
        }

        mouseMoved_ = false;

    }
    else if (!input->GetMouseButtonDown(MOUSEB_LEFT))
    {

        Ray camRay  = GetCameraRay();
        PODVector<RayQueryResult> result;

        mouseMoved_ = false;

        /*
        Array<int> pickModeDrawableFlags = {
            DRAWABLE_GEOMETRY,
            DRAWABLE_LIGHT,
            DRAWABLE_ZONE
        };
        */

        RayOctreeQuery query(result, camRay, RAY_TRIANGLE, camera_->GetFarClip(), DRAWABLE_GEOMETRY, 0x7fffffff);
        octree_->RaycastSingle(query);

        if (query.result_.Size())
        {
            const RayQueryResult& r = result[0];

            if (r.drawable_)
            {
                debugRenderer_->AddNode(r.drawable_->GetNode(), 1.0, false);
                r.drawable_->DrawDebugGeometry(debugRenderer_, false);
            }

        }
    }
    else
    {
        mouseLeftDown_ = true;
        if (Abs(input->GetMouseMoveX() > 3 || input->GetMouseMoveY() >  3))
        {
            mouseMoved_ = true;
        }
    }

}