Forums » Questions and answers »
Mouse Click Not working as expected
Added by Edward London 7 months ago
Now that I see my object in the park, I expect to retrieve a menu upon a mouse click. When debugging the mouse click, it appears I am not detecting a collision.
The old code had the following:
if ( _ParkEngine.InputEngine.InputState.CursorCollisionResult CollisionResult.Empty )
return;
I updated it to:
if ( _ParkEngine.InputEngine.InputState.MouseState.CursorCollisionResult CollisionResult.Empty )
return;
I compiled both and when I click on my object, the code returns at both of these lines. In other words, it appears to be returning an empty collision result, and so I would have no way of determining where to display my menu and the code returns.
Any ides or any further information you would need me to provide in order to debug?
Thanks,
Ed
Replies (6)
RE: Mouse Click Not working as expected
-
Added by Craig Presti 7 months ago
In v1.5 an optimisation was introduced around mouse picking that requires one of the following is true for the collisions to be calculated:
- An element has a MouseX trigger (ie MouseClick, MouseEnter, etc)
- EnableGlobalSelection is true
Given your elements aren't being generated with triggers, the collision will not be calculated.
The simplest way to work around this is to flip the global selection flag on during load:
public override void Load()
{
base.Load();
if (!(base.ParkEngine.RenderEngine as VastPark.Horde3D.Systems.RenderEngine).EnableGlobalSelection)
{
(base.ParkEngine.RenderEngine as VastPark.Horde3D.Systems.RenderEngine).EnableGlobalSelection = true;
_GlobalSelectionToggled = true;
}
}
public override void Dispose()
{
if (_GlobalSelectionToggled)
{
(base.ParkEngine.RenderEngine as VastPark.Horde3D.Systems.RenderEngine).EnableGlobalSelection = false;
}
}
Note that it's a slightly hackish way of doing this and that the ability to do this may be removed from future versions of the framework.
RE: Mouse Click Not working as expected
-
Added by Edward London 7 months ago
I will certainly try this for. Since you say this ability may be removed, is there any way you could give me an example of how I would generate an element with a trigger?
Thanks,
Ed
RE: Mouse Click Not working as expected
-
Added by Edward London 7 months ago
I am making a lot of progress thanks to your help. A few more questions:
1) I could see my menus, but no objects, meaning the objects were there, but I could not see them. For my first object, when setting the Material.AlphaThreshold to .7, it appeared with no problem. The subsequent objects had an alpha of 1 and I could not see them. However, when I removed the setting of the AlphaThreshold, the objects appeared. Shouldn't an alpha of 1 be a solid object, and 0 be tranparent?
2) Once I have my objects created, how can I actually move around in the park, rather than simply moving my camera?
I am running out of ways to say thank you :),
Ed
RE: Mouse Click Not working as expected
-
Added by Edward London 7 months ago
Also, is there a limit (adjustable or otherwise) to network messages? It appears that when I am transferring a longer message, it is getting truncated. If not, can you think of some other change from previous version that would cause a message that previously not get truncated to now be truncated?
Many thanks,
Ed
RE: Mouse Click Not working as expected
-
Added by Edward London 7 months ago
Do you have any ideas on the alpha issues?
Also, is there a way for me to navigate through the park, rather than simply look around?
Finally, is there a limit on the number of primitives I can add to the scene? If so, can I up this number or is there something I can do so that all of my objects can be added?
As far as the debugger, it is my understanding that the only way I can attach it is with nuGet, and there is currently not a way to get that with VS Express, is that correct?
Thanks once again,
Ed
RE: Mouse Click Not working as expected
-
Added by Craig Presti 7 months ago
Edward London wrote:
Do you have any ideas on the alpha issues?
The AlphaThreshold and Alpha values work in tandem.
It's mainly for use in scenarios where you have something like tree leaves and the alpha is too strong/weak - it gives you additional flexibility in this scenario.
From memory, a good value for primitive elements is an AlphaThreshold of 0.5
Also, is there a way for me to navigate through the park, rather than simply look around?
There are many ways, you could look at merging in the multi-user code from here or setting up some camera's at different positions around the scene that you transition between.
Finally, is there a limit on the number of primitives I can add to the scene? If so, can I up this number or is there something I can do so that all of my objects can be added?
No there isn't a limit.
Check the debug log (Tools -> Debug) for errors and also the source (View -> Source) to see if anything looks strange in there. If you have physics enabled, try with it disabled.
You might also consider using a hierarchy to batch the loading of the elements, something like this:
var host = new Primitive();
foreach (var node in collection)
{
host.Add(node);
}
base.ParkEngine.Context.Add(host);
As far as the debugger, it is my understanding that the only way I can attach it is with nuGet, and there is currently not a way to get that with VS Express, is that correct?
Hmm, it seems like they left that feature out of the express edition.
You could try to get around this by running this code in your plugin (reference):
Debugger.Launch();
This should cause Visual Studio to show a dialog you can use to attach to the code. It's not clear if this is missing in the express edition also.
(1-6/6)