Navi

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

I'm watching Stroustrup's overview of C++0x and laughed at the coincidental nature of his first real code example. (Around 41 minutes into the presentation)

Basically he rants about the lack of an explicit and inline method to initialize vectors (or any stl container). I had encountered this issue very recently myself and opted for Andrei Alexandrescu's hack (basically we override operator() to do vector::push_back):

Code: Select all

InlineVector<int> myNumbers(3)(5)(72)(1);
According to Bjarne, C++0x will banish this hack (and ugly variadic functions) via "std::initializer_list":

Code: Select all

vector<int> myNumbers = {3, 5, 72, 1};

// OR Even:
myFunction({"Bob", "Sally", "Matt"});
Totally cool, imo. :D
RedEagle
Gnoblar
Posts: 22
Joined: Thu Jan 04, 2007 9:39 pm

Post by RedEagle »

Hy guys!

How can I browse a NaviMaterial? I've tried the injectNaviMaterial...() but what xPos and yPos arguments should I use? I've used arg.state.X.abs and arg.state.Y.abs but had, has expected, aim problems, if you know what I mean...
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

RedEagle wrote:Hy guys!

How can I browse a NaviMaterial? I've tried the injectNaviMaterial...() but what xPos and yPos arguments should I use? I've used arg.state.X.abs and arg.state.Y.abs but had, has expected, aim problems, if you know what I mean...
You will need to handle coordinate translation for NaviMaterials yourself. injectNaviMaterial...() expects coordinates in the local space of the NaviMaterial ([0,0] would be the top-left corner, [400,300] might be the bottom-right corner, etc.).

If you are using it in the context of another GUI or billboard-esque plane (always facing camera), then you would simply translate the mouse coordinates by the location of NaviMaterial on-screen (and maybe also account for any scaling discrepancies).

Using a NaviMaterial on an arbitrary model will require use of a physics/collision library to derive exactly *where* you clicked on the model.


Image
RedEagle
Gnoblar
Posts: 22
Joined: Thu Jan 04, 2007 9:39 pm

Post by RedEagle »

If you are using it in the context of another GUI or billboard-esque plane (always facing camera), then you would simply translate the mouse coordinates by the location of NaviMaterial on-screen (and maybe also account for any scaling discrepancies).
Thanks for the answer ajs15822

In fact I am planning to use it in the context of a plane and despite understanding what must be done I have been trying to do it but with no sucess so far :( Any help would be much apreciated :D
Chaster
OGRE Expert User
OGRE Expert User
Posts: 557
Joined: Wed May 05, 2004 3:19 pm
Location: Portland, OR, USA
Contact:

Post by Chaster »

Hey ajs,

I just got NaviDemo compiled and working, (a bit of a bear, but it works..) and found a few bugs:

First, in Navidemo.cpp line 93:

Code: Select all

	naviMgr.bind("status", "levelChanged", NaviDelegate(this, &NaviDemo::levelChanged), Strings("#level"));
should be:

Code: Select all

	naviMgr.bind("status", "levelChanged", NaviDelegate(this, &NaviDemo::levelChanged), Strings("level"));
(difference is removal of "#" before "level").

Also, in Debug build, when I click "Quit", I get an assert:
ASSERTION: preserved wrapper table not empty at shutdown: 'sPreservedWrapperTable.ops == 0', file c:/mozilla/dom/src/base/nsDOMClassInfo.cpp, line 3583
I am using the version I got from your SVN repository yesterday.

Other than that, I am excited to start playing with this cool piece of work you've made!

Chaster
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

RedEagle wrote:In fact I am planning to use it in the context of a plane and despite understanding what must be done I have been trying to do it but with no sucess so far.
I actually haven't done it myself yet either. :D

This is really a matter that will be handled by a physics engine. If I get around to it, I'll try to write something up on how to do it with NxOgre (my physics engine of choice).
Chaster wrote:Hey ajs,

I just got NaviDemo compiled and working, (a bit of a bear, but it works..) and found a few bugs:

First, in Navidemo.cpp line 93:

Code: Select all

	naviMgr.bind("status", "levelChanged", NaviDelegate(this, &NaviDemo::levelChanged), Strings("#level"));
should be:

Code: Select all

	naviMgr.bind("status", "levelChanged", NaviDelegate(this, &NaviDemo::levelChanged), Strings("level"));
(difference is removal of "#" before "level").

Also, in Debug build, when I click "Quit", I get an assert:
ASSERTION: preserved wrapper table not empty at shutdown: 'sPreservedWrapperTable.ops == 0', file c:/mozilla/dom/src/base/nsDOMClassInfo.cpp, line 3583
I am using the version I got from your SVN repository yesterday.

Other than that, I am excited to start playing with this cool piece of work you've made!

Chaster
Nice job pointing out the issue with the pound-prefix. The actual issue was that NaviData::ensure was doing the map lookup with the key name prematurely (before it substringed past the #). The SVN is updated with the fix.

That little assertion at the quit of debug is normal for the build of Gecko we are using. That bug will be resolved when we *eventually* bump up to a more recent Gecko build (which actually means updating LLMozLib first).

Anyways, good luck and have fun with Navi~!
RedEagle
Gnoblar
Posts: 22
Joined: Thu Jan 04, 2007 9:39 pm

Post by RedEagle »

Hy there!

Thanks for your help ajs15822! By the way is there another way to play videos on a Navi besides on a flash movie? I've tried several types of video files and some only play the sound :( By the way I've set forceUpdate :D Thanks once again
User avatar
Jerrith
Gnoblar
Posts: 13
Joined: Sat May 26, 2007 11:40 pm
Location: Hunt Valley, MD
Contact:

Post by Jerrith »

I've been trying out using Navi together with CEGUI to make a chat window. I've got it basically working, but there's a few things I was wondering if anyone had some ideas about:

1) Is there an easy way to disable Mozilla automatically getting the keyboard input? I haven't hooked up any keyboard input injection yet, but I noticed that once I've clicked on it, I can use the arrow keys (and space) to scroll... I'd rather pass it keys, than have get things on its own.

2) I've noticed at times that it will change the mouse cursor on me, just until I move the mouse again. I've got my own mouse cursor, with a blank / empty windows cursor while in my app window, however Mozilla will cause a standard windows cursor to be drawn for a moment, after events like mouse clicks, or mouse wheel scroll.

For those curious, here's a sample of what it looks like at the moment.

Image

Thanks. :)
Lord LoriK
Goblin
Posts: 254
Joined: Tue Feb 13, 2007 5:33 am

Post by Lord LoriK »

If you acquire the keyboard in exclusive mode before setting up LLMozLib, it won't capture the keys. I'm doing that and passing characters with a JS function. Quite annoying but I'm getting an issue with composite characters if I don't. Here's my (ugly) code:

Code: Select all

var focus_obj = null;
var key_up = null;

function input_init()
{
	var el = document.forms[0].elements;

	for (var i = 0; i < el.length; i++)
	{
		el[i].onfocus = function() { focus_obj = this; }
	}
}

function get_focused_element()
{
	return focus_obj;
}

var L_SHIFT = false;
var L_CONTROL = false;
var L_ALT = false;
var L_WIN = false;
var R_SHIFT = false;
var R_CONTROL = false;
var R_ALT = false;
var R_WIN = false;

function inject_key_up(key)
{
	switch (key)
	{
	case 42:					// KEY_LEFTSHIFT
		L_SHIFT = false;
		break;
	case 29:					// KEY_LEFTCONTROL
		L_CONTROL = false;
		break;
	case 56:					// KEY_LEFTALT
		L_ALT = false;
		break;
	case 219:					// KEY_LEFTWIN
		L_WIN = false;
		break;
	case 54:					// KEY_RIGHTSHIFT
		R_SHIFT = false;
		break;
	case 157:					// KEY_RIGHTCONTROL
		R_CONTROL = false;
		break;
	case 184:					// KEY_RIGHTALT
		R_ALT = false;
		break;
	case 220:					// KEY_RIGHTWIN
		R_WIN = false;
		break;
	case 28:
	case 156:
		if (typeof key_up == 'function')
		{
			key_up(13);
		}
		break;
	}
}

function inject_key_down(key)
{
	switch (key)
	{
	case 14:					// KEY_BACKSPACE
		element = get_focused_element();
		if (element)
		{
			element.value = element.value.substr(0, element.value.length - 1);
		}
		break;
	case 42:					// KEY_LEFTSHIFT
		L_SHIFT = true;
		break;
	case 29:					// KEY_LEFTCONTROL
		L_CONTROL = true;
		break;
	case 56:					// KEY_LEFTALT
		L_ALT = true;
		break;
	case 219:					// KEY_LEFTWIN
		L_WIN = true;
		break;
	case 54:					// KEY_RIGHTSHIFT
		R_SHIFT = true;
		break;
	case 157:					// KEY_RIGHTCONTROL
		R_CONTROL = true;
		break;
	case 184:					// KEY_RIGHTALT
		R_ALT = true;
		break;
	case 220:					// KEY_RIGHTWIN
		R_WIN = true;
		break;
	}
}

function inject_char(char)
{
	if (L_CONTROL || R_CONTROL || L_WIN || R_WIN) return;
	element = get_focused_element();
	if (element)
	{
		element.value += char;
		if (typeof key_up == 'function')
		{
			key_up(0 + char);
		}
	}
}
It works this way: you set things up calling input_init(). This will set up a function to get the current focused control. Then you pass each keypress with inject_key_down() and inject_key_up(), plus an inject_char() to inject characters.

If you want to run an event after each injected char, you assign a function to key_up taking one argument (the char, duh).

This "works" but not fully: now you cannot move the cursor, nor copy/paste text. Only writing works. The numbers you see are OIS keycodes. Refer to OIS for additional info.

Hope it helps. If anyone feels like improving my crappy JS, go ahead but please send me the improved version.
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

RedEagle wrote:Hy there!

Thanks for your help ajs15822! By the way is there another way to play videos on a Navi besides on a flash movie? I've tried several types of video files and some only play the sound :( By the way I've set forceUpdate :D Thanks once again
The problem with external video plugins (quicktime, windows media, etc.) is that they are rendered onto a separate surface and positioned on the page to look as if they are actually 'embedded'. Thus, when we grab the page via LLMozLib, all we get is a black box where the external video might be. We would have to delve into LLMozLib to figure out how to circumvent this issue.

Jerrith wrote:I've been trying out using Navi together with CEGUI to make a chat window. I've got it basically working, but there's a few things I was wondering if anyone had some ideas about:

1) Is there an easy way to disable Mozilla automatically getting the keyboard input? I haven't hooked up any keyboard input injection yet, but I noticed that once I've clicked on it, I can use the arrow keys (and space) to scroll... I'd rather pass it keys, than have get things on its own.

2) I've noticed at times that it will change the mouse cursor on me, just until I move the mouse again. I've got my own mouse cursor, with a blank / empty windows cursor while in my app window, however Mozilla will cause a standard windows cursor to be drawn for a moment, after events like mouse clicks, or mouse wheel scroll.

For those curious, here's a sample of what it looks like at the moment.

I recommend doing what LordLoriK said (exclusive keyboard mode). I will see what I can do to provide an interface for manually injecting keyboard input without automatic injection (requires modification to LLMozLib).

To really get rid of the system cursor when its over the app, NaviMouse uses the win32 call 'ShowCursor(false)'.

I lol'd @ your Chat's text. The design is very slick!

Lord LoriK wrote:If you acquire the keyboard in exclusive mode before setting up LLMozLib, it won't capture the keys. I'm doing that and passing characters with a JS function. Quite annoying but I'm getting an issue with composite characters if I don't. Here's my (ugly) code:

Code: Select all

*<snip/>*
It works this way: you set things up calling input_init(). This will set up a function to get the current focused control. Then you pass each keypress with inject_key_down() and inject_key_up(), plus an inject_char() to inject characters.

If you want to run an event after each injected char, you assign a function to key_up taking one argument (the char, duh).

This "works" but not fully: now you cannot move the cursor, nor copy/paste text. Only writing works. The numbers you see are OIS keycodes. Refer to OIS for additional info.

Hope it helps. If anyone feels like improving my crappy JS, go ahead but please send me the improved version.
Here's my stab at it:

Code: Select all

	<script type="text/javascript">
	var focusedEle = null;
	window.addEvent('domready', function()
	{
		$$('input, textarea').each(function(ele)
		{ 
			ele.addEvent('focus', function(evt){ focusedEle = evt.target; });
		});
	});

	function keyPress(charCode, keyCode, ctrl, alt, shift)
	{
		var evt = document.createEvent("KeyboardEvent");
		evt.initKeyEvent("keypress", true, true, null, ctrl, alt, shift, false, keyCode, charCode);
		
		if($defined(focusedEle))
			focusedEle.dispatchEvent(evt);
	}
	</script>
See: http://developer.mozilla.org/en/docs/DO ... itKeyEvent

I'm still getting permission exceptions with the above code when invoking left and right arrows, everything else seems OK.

Besides any of that, the current LLMozLib code dump has support for unicode char injection. I'll see what I can do to migrate Navi over to it.
RedEagle
Gnoblar
Posts: 22
Joined: Thu Jan 04, 2007 9:39 pm

Post by RedEagle »

Sorry for bothering again!

Is it possible to write on a text box on a NaviMaterial just as on a Navi? Besides not being able to accomplish this I can't scroll a page left-clicking and draging the mouse on a naviMaterial. Thanks again


PS - I´ve finally been able to mouse pick a NaviMaterial on a plane correctly thanks to browserplane demo!
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Post by Zeal »

Hooray for navi! Ive been away for awhile, just wanted to check and see if there is flash support yet? (I skimmed but didnt see any mention of it)
Ayrik
Gnoblar
Posts: 12
Joined: Tue Jan 23, 2007 11:59 pm

Post by Ayrik »

If you really want Flash support you should look into Ogreswf (http://www.ogre3d.org/phpBB2/viewtopic.php?t=22196).

By the way, I just wanted to say that Navi is awesome. I'm working on an online type game and all the GUI is taken from the website and it works pretty amazingly. Unfortunately I can't show any screenshots.

I was just curious as to how any progress is going on the background:transparent stuff, and just like to say that I would be very interested in it.

Keep up the good work!
User avatar
Ygolonac
Halfling
Posts: 70
Joined: Sat Oct 01, 2005 8:15 pm
Location: Helsinki, Finland
Contact:

Post by Ygolonac »

It took me a while to realize the sweet potential of this library. It's definitely my tool of choice for now on. In just 4 short hours, starting from scratch, I had myself an Ogre app running a variety of Navis, most interestingly a console Navi in which you can write Lua script... and having exposed the evaluateJS function to Lua, things get so flexible it's stupid! Huge kudos.

My issues so far are few... namely:
  • I'm not getting that vertical line cursor in text input fields... but looking at others' results, it seems that they are. Must investigate... maybe they're forcing updates?
  • Click'n'dragging over text will highlight it, which is ugly, and probably almost never useful in a Navi. Could this be made optional? Yes, I know the workarounds involving transparent layers with greater z-indices... but they're quirky without fail.
  • Either I'm missing something, or the Navis aren't movable programmatically. Not something I would need at the moment, but just thought it seemed strange.
  • The Navis aren't resizable. This could definitely be handy - to make implementation simpler, you could have the user define a maximum size for the Navi, create the rendertexture that size, and upon drawing clip to the resized size. Yeah, this could be circumvented by animating a mask, but that would suck. :wink:
  • And then the things that cannot be fixed due to being limitations of Gecko... that is, no scrollbar customizing (must use a javascript scrollbar everywhere to avoid teh ugly), and no font embedding. Oh well, can't have it all... :cry:
Ooh, it just occurred to me that it would be wicked if you supported the cursor CSS property. Like so:

(CSS)
.myElement { cursor: crosshair; }
.myOtherElement { cursor: default; }

(C++)
NaviMouse *mouse = ...
mouse->createCursor("default", 0, 0)->addFrame(0, "defaultCursor.png");
mouse->createCursor("crosshair", 0, 0)->addFrame(0, "crosshairCursor.png");

No idea how difficult the implementation would be though. Just a thought! :)
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

RedEagle wrote:Sorry for bothering again!

Is it possible to write on a text box on a NaviMaterial just as on a Navi? Besides not being able to accomplish this I can't scroll a page left-clicking and draging the mouse on a naviMaterial. Thanks again


PS - I´ve finally been able to mouse pick a NaviMaterial on a plane correctly thanks to browserplane demo!
If you have mouse picking and mouse injection all working, you totally should be able to do all the normal activities that you would normally enjoy with a basic Navi (textbox selection/input, scrolling via scrollbar, etc.).

Hmmm, I want you to try something for me, in NaviManager.cpp, line 576, I want you to change the contents of NaviManager::injectNaviMaterialMouseDown to:

Code: Select all

void NaviManager::injectNaviMaterialMouseDown(const std::string &naviName, int buttonID, int xPos, int yPos)
{
	iter = activeNavis.find(naviName);
	if(iter != activeNavis.end())
		if(iter->second->isMaterialOnly)
		{
			deFocusAllNavis();
			LLMozLib::getInstance()->focusBrowser(iter->second->windowID, true);
			LLMozLib::getInstance()->mouseDown(iter->second->windowID, xPos, yPos);
		}
}
Zeal wrote:Hooray for navi! Ive been away for awhile, just wanted to check and see if there is flash support yet? (I skimmed but didnt see any mention of it)
Nope not yet :(
Ayrik wrote: By the way, I just wanted to say that Navi is awesome. I'm working on an online type game and all the GUI is taken from the website and it works pretty amazingly. Unfortunately I can't show any screenshots.

I was just curious as to how any progress is going on the background:transparent stuff, and just like to say that I would be very interested in it.

Keep up the good work!
Weee, I'm excited over the native transparency as well.

Native RGBA (true transparency) surface rendering in Gecko is currently only in their trunk. The Mozilla people have guesstimated that a solid release is still a couple of months away (Christmas). And then LLMozLib would have to port to it as well.. so I can't really give you a solid timeframe when this ability will be available.

@Ygolonac: I'll reply a little bit later, I gotta run to class right now. xD
Ayrik
Gnoblar
Posts: 12
Joined: Tue Jan 23, 2007 11:59 pm

Post by Ayrik »

Native RGBA (true transparency) surface rendering in Gecko is currently only in their trunk. The Mozilla people have guesstimated that a solid release is still a couple of months away (Christmas). And then LLMozLib would have to port to it as well.. so I can't really give you a solid timeframe when this ability will be available.
That makes sense, I wasn't aware it was Mozilla limited. I guess we have to wait. Coincidently I have to wait before I can officially start on that project anyway, but I'm sure you'll be hearing more of me by that time!
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Ygolonac wrote: My issues so far are few... namely:
  • I'm not getting that vertical line cursor in text input fields... but looking at others' results, it seems that they are. Must investigate... maybe they're forcing updates?
As far as I know, the caret is rendered by LLMozLib when a page is grabbed (rendered by Gecko). If only the caret is moving (and not the actual page) then I suppose the only way to see it is via force-updates.
  • Click'n'dragging over text will highlight it, which is ugly, and probably almost never useful in a Navi. Could this be made optional? Yes, I know the workarounds involving transparent layers with greater z-indices... but they're quirky without fail.
It may be possible to disable/enable this behavior via some interface in Gecko. This is really another issue that would have to be handled in LLMozLib.
  • Either I'm missing something, or the Navis aren't movable programmatically. Not something I would need at the moment, but just thought it seemed strange.
The current SVN has this ability. ;)

  • The Navis aren't resizable. This could definitely be handy - to make implementation simpler, you could have the user define a maximum size for the Navi, create the rendertexture that size, and upon drawing clip to the resized size. Yeah, this could be circumvented by animating a mask, but that would suck. :wink:
I suppose that's fairly achievable, I'll add it to the wishlist.

  • And then the things that cannot be fixed due to being limitations of Gecko... that is, no scrollbar customizing (must use a javascript scrollbar everywhere to avoid teh ugly), and no font embedding. Oh well, can't have it all... :cry:
Two ways around that one: the default XUL chrome theme for the scrollbars is actually customizable via css/images. I haven't actually done it yet but I'm aware that it can be done.

Another way might be to implement a scrollbar widget via MooTools, similar to what I recently did for comboboxes.
Ooh, it just occurred to me that it would be wicked if you supported the cursor CSS property. Like so:

(CSS)
.myElement { cursor: crosshair; }
.myOtherElement { cursor: default; }

(C++)
NaviMouse *mouse = ...
mouse->createCursor("default", 0, 0)->addFrame(0, "defaultCursor.png");
mouse->createCursor("crosshair", 0, 0)->addFrame(0, "crosshairCursor.png");

No idea how difficult the implementation would be though. Just a thought! :)
I've attempted to do it before via a Windows-specific method (capturing the internal system cursor changes initiated by Gecko) but it caused some unworkable flicker. A better way would be to capture these events directly within LLMozLib and fire them at registered listeners.


@all:

I apologize for the apparent slowdown in development, I'm now busy with sophomore year at my college + new part-time job. Nevertheless, I intend to roll-out NaviLibrary v1.4 rather soon. Yay. :D
Chaster
OGRE Expert User
OGRE Expert User
Posts: 557
Joined: Wed May 05, 2004 3:19 pm
Location: Portland, OR, USA
Contact:

Post by Chaster »

Perhaps this is a dumb question - but it *seems* that the tutorials on the Navi Wiki are already way out of date - is that correct? At least, the tutorials don't work as shown...

I guess I'm asking because I'm having trouble just getting a simple string value from a text box... (color me stupid - I know barely any HTML so I could be doing a million things wrong).

*EDIT* Gah, finally got things to work (after a lot of trial and error). My ONE request: PLEASE UPDATE THE DOCUMENTATION FOR THE NAVI API!!!

Mucho mucho thanks otherwise for a great lib.

Chaster
User avatar
ajs15822
OGRE Expert User
OGRE Expert User
Posts: 570
Joined: Mon Jan 02, 2006 2:05 am
Location: Texas
x 2
Contact:

Post by ajs15822 »

Chaster wrote:Perhaps this is a dumb question - but it *seems* that the tutorials on the Navi Wiki are already way out of date - is that correct? At least, the tutorials don't work as shown...

I guess I'm asking because I'm having trouble just getting a simple string value from a text box... (color me stupid - I know barely any HTML so I could be doing a million things wrong).

*EDIT* Gah, finally got things to work (after a lot of trial and error). My ONE request: PLEASE UPDATE THE DOCUMENTATION FOR THE NAVI API!!!

Mucho mucho thanks otherwise for a great lib.

Chaster
If you're using SVN Navi, the Navi Wiki/tutorials are definitely out of date. The actual headers are fairly verbose and so you should go by them for the time being.

The wiki/tutorials are updated for every release, so just wait a little while longer. ;)
User avatar
Ygolonac
Halfling
Posts: 70
Joined: Sat Oct 01, 2005 8:15 pm
Location: Helsinki, Finland
Contact:

Post by Ygolonac »

Ugh, had to start over due to a "msvcr80.dll not found" error I just couldn't figure out... something to do with manifest files... meh. Anyway, now I'm trying to get NaviMaterial interactive on a plane. First I make my plane 1x1 in size, then scale and translate its scenenode. Then, upon mouse events, I do a RaySceneQuery to find out the world position of the mouse cursor on the plane, then multiply that by myPlaneEntity._getParentNodeFullTransform().inverse() and scale the result to the Navi's pixel size... so far so good, right? It even worked, right until I actually rotated the plane and everything blew up. Now I realized that wretched RaySceneQuery might actually collide against the plane's AABB, which would explain things not working. So now I'm thinking the solution is to either make the plane part of world geometry (gotta investigate to see how that'd be done), or to use some other ray query tool... agh, can this really be this difficult. :cry:
User avatar
Ygolonac
Halfling
Posts: 70
Joined: Sat Oct 01, 2005 8:15 pm
Location: Helsinki, Finland
Contact:

Post by Ygolonac »

Luckily I realized messing around with RaySceneQuery was idiotic. Here's the obvious solution for getting mouse coords on the 3D plane I texture with NaviMaterial (Doom 3 style GUIs on 3D objects, here I come).

Code: Select all

	Ray ray(sceneMgr->getCamera("MainCam")->getCameraToViewportRay(getCameraToViewportRay(arg.state.X.abs / (float)arg.state.width, arg.state.Y.abs / (float)arg.state.height)); // arg is the OIS::MouseEvent
	Node *node = sceneMgr->getEntity("myEntity")->getParentNode(); // done here only for this one plane entity, in reality iterate through all wanted planes here
	Matrix4 mat;
	node->getWorldTransforms(&mat);
	Vector3 p1(-0.5, 0.5, 0), p2(0.5, 0.5, 0), p3(-0.5, -0.5, 0), p4(0.5, -0.5, 0); // the plane is created in (0, 0, 0), oriented -Z, size (1, 1), so here are its corners
	p1 = mat * p1;
	p2 = mat * p2;
	p3 = mat * p3;
	std::pair<bool, Real> intersection = Ogre::Math::intersects(ray, p1, p2, p3, true, false);
	if (!intersection.first)
	{
		p4 = mat * p4;
		intersection = Ogre::Math::intersects(ray, p2, p4, p3, true, false);
	}
	if (intersection.first)
	{
		isHit = true;
		Vector3 point = mat.inverse() * ray.getPoint(intersection.second);
		point = -point + 0.5; // no idea. works for me!
		mousePosOnPlane = Vector2(point.x, point.y);
	}
...and that gets me the coords on scale from 0 to 1. I do that per mouse event, injecting like so:

Code: Select all

if (isHit) NaviManager::Get().injectNaviMaterialMouseMove(naviName, mousePosOnPlane.x * naviMaterialResolution.x, mousePosOnPlane.y * naviMaterialResolution.y);
Yay!

...but all is not well. I'm also making a scene where there's a computer panel displaying some other portion of the world (using a rendertexture). Now I'd like to display some Navis on the main window (stats, debug console, etc.) but I'd also like to display some OTHER Navis on the rendertexture (controls for operating that computer panel). Currently this doesn't seem to be possible. Also, it seems the Navis are rendered in both my main window and in my rendertexture rather than just in the RenderWindow I actually passed to NaviManager. So... would it be possible to add a RenderTarget parameter to createNavi, and have the Navi only show up on that target? For backwards compatibility default it to whatever is passed in NaviManager::Startup.

Now that would make my day. 8)
com44ai
Gnoblar
Posts: 3
Joined: Fri Aug 31, 2007 8:07 pm

CEGUI mouse over Navi?

Post by com44ai »

Hi, first of all, thanks for the nice library.

Currently, we are using CEGUI mouse as our mouse cursor.
If I create mouse cursor using Navi library, it's drawn over the cegui mouse.

Anyway...
Problem is, if I don't call 'StartupMouse' and just use CEGUI mouse,
CEGUI mouse disappears when it's inside of the Navi window.
But technically it doesn't seem to be disappearing, but just is under the navi window.

Is navi window always drawn at the top z-order?

Both CEGUI/navi are using Ogre overlay i think. Does anybody know what to do? (Please don't say just use Navi's mouse cursor, because it's not an option in our program)

Thanks in advance.
kcbanner
Goblin
Posts: 208
Joined: Sat May 05, 2007 4:49 pm

Post by kcbanner »

Whats the linux support status for this? I know there was some talk of it before.
com44ai
Gnoblar
Posts: 3
Joined: Fri Aug 31, 2007 8:07 pm

Re: CEGUI mouse over Navi?

Post by com44ai »

com44ai wrote:Hi, first of all, thanks for the nice library.

Currently, we are using CEGUI mouse as our mouse cursor.
If I create mouse cursor using Navi library, it's drawn over the cegui mouse.

Anyway...
Problem is, if I don't call 'StartupMouse' and just use CEGUI mouse,
CEGUI mouse disappears when it's inside of the Navi window.
But technically it doesn't seem to be disappearing, but just is under the navi window.

Is navi window always drawn at the top z-order?

Both CEGUI/navi are using Ogre overlay i think. Does anybody know what to do? (Please don't say just use Navi's mouse cursor, because it's not an option in our program)

Thanks in advance.
I've figured it out.
http://www.ogre3d.org/phpBB2/viewtopic. ... 6f4e2718c6
User avatar
Caius
Halfling
Posts: 52
Joined: Fri Oct 06, 2006 9:00 pm

Post by Caius »

this is a very nice lib =)
I have a question, about licensing issues.
Navi is LGPL and Firefox is GPL.
Is it possible to make a closed source project that uses Navi, and that show webpages using firefox sdk?
Post Reply