Rei

OSGrid in Rei

Posted by Zaki on December 21, 2009
OpenSim / 3 Comments

Textures

Before Rei was released at the end of September, it was called 3Di OpenViewer. As it stands, that viewer didn’t need to download textures through the region server, rather, it would download assets (textures, meshes, avatars) directly from an asset server. For this reason, when someone logged in to an upstream OpenSim grid with 3Di OpenViewer, textures and avatars would not appear.

But that changed when we released Rei as an open-source viewer at the end of September. At that time, textures were already being fetched from OpenSim. You can go ahead and grab the installer from github and it will display textures. What it won’t do with textures is correctly apply UV coordinates in some (fortunately very rare) twisted-hollow-prim cases (but it was more about PrimMesher than Rei). Since September, we have done many improvements to PrimMesher – and Rei too, so now even those rare cases appear correctly (big thanks to the bug reporters). Texture downloads are slow unfortunately, but more on that later.

Avatars

Now this is a very delicate issue. The heart of the issue is that currently there is no non-LL viewer that supports SecondLife(tm) avatars. Let me say that again: there are no viewers that support SL(tm) avatars. Naali has a built-in mesh (the same as the old viewer), IdealistViewer has a built-in mesh, LookingGlass doesn’t yet have avatars (correct me if it does), Xenki doesn’t have an avatar yet as far as I know either.

The closest a viewer gets to SL avatar support is the PandaViewer by dahlia (http://vimeo.com/6812213) , which supports avatar shapes and actually looks really nice. Unfortunately it’s not open source (yet?), nor is it available in any form.

The thing with avatar support is that it’s pretty difficult to do right. No, not only technically, but there’s the issue of using or not using Linden Labs(tm)’s original mesh. You can find downloadable meshes, but there is a nice warning hidden neatly inside an obj file:

# This model is released for use by residents of Second Life.
# It may be imported into external 3D modeling, texturing, and animation applications to aid in the creation of character animations and textures for Second Life, as well as for any non-commercial purpose.
# Use or modification of this model for any other commercial purpose is prohibited without the express written consent of Linden Lab.

With all this said, we are looking at SL(tm) avatar support. It definitely won’t happen before the end of this year, the target is early next year.

OpenSim support

Of course Rei still has issues with upstream OpenSim support. This is partially due to the very very bad way textures are downloaded (through a single server, in UDP). The truth is, even SL(tm) viewer chokes on those: in heavy regions it would download the low resolution image, but the full image is never actually downloaded. My personal opinion is that the sooner we can break free from that way of transferring assets to clients, the better (guess how 3Di OpenViewer delivers content). Hopefully OpenSim will not remain an SL(tm) clone and there will be lots of innovations in the virtual world space coming from OpenSim. Rei is supposed to show what is possible when we can control both the viewer and the server side without the fear of not being able to work on one or the other for six months.

The current state

Below are two videos of Rei logging in to OSGrid’s Lbsa Plaza and Wright Plaza.

So, what do you think of the viewer so far? What sort of improvements do you think would be nice? What do you think is missing, other than the avatar support?

In general, what are the things you absolutely expect from a virtual world viewer?

Let me know in the comments.

Tags: , , , ,

Wii Controller Plugin for 3Di Viewer “Rei”

Posted by Zaki on November 20, 2009
OpenSim / 1 Comment

 

Wii Controller Plugin

3Di Viewer “Rei” provides a great flexibility when it comes to adding custom functionality to the core viewer by making it possible to create binary plugins. Just drop these binaries into the Rei folder and let the viewer find and load it automatically the next time it starts. While these plugins are still in their early phase – we can do a lot more to ease the process of deploying plugins and resolving their dependencies – you can get a glimpse at their power already.

The WiiControllerPlugin is a fun project, a proof-of-concept, rather than a commercial solution, so before you dive in, be warned, that it is sometimes rough around the edges. With that out of the way, if you have Rei, head over to http://github.com/zaki/ReiWiiControllerPlugin and grab the binary from the Download section. Just copy the contents into the Rei installation folder (usually C:\Program Files\3Di\Rei). And… that’s basically it.

How to connect the controller?

To use a Wiimote, you will need a Wiimote, a nunchuck and a bluetooth adapter. I’ve heard that Toshiba adapters works best, but I have used Broadcomm’s chips successfully as well. It is said that the Microsoft stack doesn’t work most of the time with the Wiimote.

Before you start the viewer, connect/pair the Wiimote via bluetooth. If you find it difficult to connect, I found that keeping (1) and (2) pressed simultaneously while connecting helps a lot.

Once the Wiimote is connected, start Rei and if everything goes well, the primary Wiimote will have its first LED turned on. You are now ready.

How to use the Wiimote?

The WiiControllerPlugin allows you to use the Wiimote and the nunchuck to control your avatar and the camera. The nunchuck’s joystick, or the directional controller on the wiimote can be used to make you avatar walk. Up will always make your avatar walk forward, regardless of the position of the camera.

The camera is controlled with a combination of the wiimote and the nunchuck. Zoom in and out by holding down (Z) and tilting the nunchuck forward and backward. Hold the wiimote straight up; while you press (B), you can tilt the wiimote in four directions to rotate the camera around your avatar. Remember, you don’t have to look away from the screen to change the camera angle.

If you get lost with the camera, you can always press (C) to go back to behind your avatar. Pressing (C) also switches to “follow” mode, so your camera will “stick” to  your avatar and will follow it from behind if you move. Pressing (C) another time will switch back to the free camera mode.

If you get tired of moving with the wiimote and want to switch back to using the keyboard or mouse, you can disable avatar movements by pressing (-). Your wiimote’s will light the third LED when it’s disabled. Press (-) again to enable moving by the wii controller.

About the demo

The video above contains a very dull maze, in which there are colored balls that hurt or heal you when you touch them (I’ve never said I was a great contents designer, have I :) ) The demo shows how easy it is to integrate custom features with an unmodified OpenSim grid. All that was used is simple LSL script that detects collisions and gives commands via llSay. These commands can be intercepted by javascript and further dispatched to all plugins, that can act accordingly. In this case a simple health bar is adjusted.

As my LSL was sending plaintext commands like “heal,20″, the necessary javascript looks really simple:

function DispatchCommand(message)
{
	var strList = new Array();
	strList = message.split(",");

	if (strList.length == 2)
	{
		ctrl.Callback(strList[0], strList[1]);
	}
}

If you have a question, or have a good idea about plugins, or the WiiControllerPlugin, please share it in the comments.

 

 


Please note: WiiControllerPlugin is not endorsed by Nintendo. WiiControllerPlugin depends on  WiiMoteLib, which is release under the license MS-PL. For more details, see http://wiimotelib.codeplex.com/

Tags: , , , ,

Plugins for Rei

Posted by Zaki on November 11, 2009
OpenSim / No Comments

Plugins

In “Rei”, there is a curious little green “health” bar above the avatar’s head. That bar is not something that is built in to the viewer, rather, a simple plugin provides the functions that are necessary to have a very rudimentary health bar. Of course this TestPlugin is only to show what sort of things are possible with “Rei”.

What do plugins do?

Plugins are intended for two main purposes. First, to communicate – through javascript – with the 2D web, and second, to interact with objects within the 3d scene. Of course a plugin is a .NET assembly, so it can pretty much do anything, but the main functions it is intended for are the above two. For instance TestPlugin provides two javascript functions: one to inflict damage and one to heal, basically allowing a regular 2d web application, for instance an SNS site or an online game, to change the health meter of the avatar within the 3d world according its own rules. Responding to these javascript functions then, the plugin interacts with the 3d world by rendering its own little health bar above the user’s head.

How to write plugins?

To make things as simple as possible, “Rei” uses the same method for developing plugins as OpenSim. Essentially one writes an addin for the /OpenViewer/Managers extension by implementing the IManagerPlugin interface and then creating and embedding a plugin manifest to the assembly.

IManagerPlugin

All plugins need to implement IManagerPlugin, which means implementing a few methods:

void Initialise(Viewer viewer);

- Initialise is the method that will be called right after constructing the plugin class. This will be only called once for the life of the plugin and is used to create objects that will persist through the entire lifetime such as static resources (textures, models), configurations.

void Initialize();

- Initialize (note the z in the name) will be called when “Rei” is getting ready to enter a region. This happens on the first startup as well as after logout or before entering a new region after a teleport. This is to make sure that unnecessary scene objects do not make it over to a new environment, therefore Initialize would create objects that persist only through the lifetime of one region, such as dynamic resources (textures, meshes) or dynamic information (region data, prim data)

void Update(uint frame);

- Update is called every frame. This is the place to calculate the next state of the plugin, including objects in the 3d scene. This is the only place where it is allowed to change properties of any object that is within the scenegraph. By using the frame parameter, it is possible to count or skip frames.

void Draw();

- Draw is also called every frame and it is where drawing directly to the 3d canvas is possible. Generally it is recommended to use proper scenenodes that draw automatically, instead of drawing directly.

void Cleanup();

- Just like Initialize is called before “Rei” is ready to log in to a new region, Cleanup is called every time a region is no longer needed, such as when logging out or when leaving a region by teleport. Cleanup is responsible of releasing resources that were allocated by Initialize (but not Initialise!)

RefController Reference { get; set; }

- This property is the entry point to “Rei”s core. Through this object it is possible to call into the public api of the viewer or to access javascript. Reference must always be initialized from the viewer parameter passed in to Initialise()

Communication with Javascript

Plugin to Javascript: Dispatch

A plugin can call Reference.Viewer.Adapter.Dispatch(string action, string message) when it wants to send a message to javascript. If a handler was added to the javascript library for the particular action, this dispatch will be processed by passing the message to the handler function. For future compatibility it is recommended although not required that the message be passed in json format.

Javascript to Plugin: Callback

The Adapter supplies a Callback delegate and a registry to handle calls from Javascript. A plugin can register a callback method that it is interested in receiving by calling

Reference.Viewer.Adapter.RegisterCallback

. It must pass the name of the method it wants to listen to and the method to call when the event arrives. The way a Callback works is very much like delegates work in the .NET framework.

From the javascript side, one can use

ctrl.Callback("method", parameters)

and all plugins that are listening to “method” will receive a callback to their registered functions. For an example of Callbacks, you can see the DoDamage and DoHeal from test.js and TestPlugin.cs

Plugin to Plugin: Message

It is also possible to send messages from one plugin to another, even without being aware of the other plugin. The mechanism is very similar to Callbacks: a plugin registers a message handler by calling

Reference.Viewer.Adapter.RegisterMessage

. The first parameter must be the name of the message to listen to and the second one is a message handler delegate.

A plugin can then raise a Message by calling

Rerence.Viewer.Adapter.SendMessage("message", parameters)

and all plugins that subscribed to the message being sent will receive it.


A draft of this post also appears on the github wiki for 3Di Viewer “Rei”. For more up-to-date information, refer to this page.

Tags: , , ,

Irrlicht.NETCP and 3Di Rei on Linux

Posted by Zaki on November 05, 2009
OpenSim / No Comments

Irrlicht.NETCP

I’ve spent the last couple of weeks working towards rebasing the now abandoned Irrlicht.NETCP to use the latest Irrlicht released: 1.6. There are multiple reasons to do so, probably the most straightforward is to get the bugfixes or some of the new features, like the new light manager. However the less direct reason to do the rebase is that it includes Mac support out of the box – and now that I have a macbook sitting on my desk at work (albeit, temporarily), that is something of very high interest for me. In my dreamland, OpenGL ES support (for the iPhone) would work without much work too – hey, I can dream, can’t I.

So, for this rebase, I’ve started a new repo on github, that I hope will soon become the official repository for 3Di Viewer “Rei”, and maybe even for users of Irrlicht.NETCP (if any are still left, but who knows, maybe this can spark some new interest). The repository starts with a clean Irrlicht 1.6 SDK and gradually adds the fixes and features that are necessary for Rei (but of course those are fixes and features that would probably come up in other development as well).

On top of the improvements to Irrlicht, there is one huge patch, that makes the IrrlichtW wrapper compatible with 1.6. This mostly consists of type changes in the method interfaces and other minor details, but the patch itself is pretty monstrous, as many things changed at the same time. It is only after this collective patch, that the .NETCP library is usable again (it won’t even compile before this fix, so be careful with the history).

Later, IrrlichtML fixes were added. ML stands for multilingual and these changes are required even though things finally started  moving away from c8* to proper strings and io::paths in the core, stuff like IME support was not included and the unicode support is still horrible to say the least.

Getting Irrlicht.NETCP

If you want to give the new Irrlicht.NETCP libraries a try, head to github: http://github.com/zaki/irrlicht.netcp and check out the sources (either using git, or click on download in github). For the impatient, I’ve also uploaded binary files for 32-bit windows (Release mode).

To compile the libraries yourself, you will have to compile three components: Irrlicht SDK, IrrlichtW and Irrlicht.NET, in basically this order. To compile Irrlicht SDK, go to Irrlicht SDK\source\Irrlicht and open Irrlicht9.0.sln in Visual Studio 2008 and build. IrrlichtW’s solution is found in IrrlichtW, named IrrlichtW.sln

Irrlicht.NET uses Prebuild to create its solution files, so before you can compile, the file runprebuild2008.bat needs to be run. That creates the solution file Irrlicht.NET.sln, that can be opened and built in VS.

Rei and Irrlicht.NETCP

To use the new binaries with “Rei”, some minor changes need to be made to Rei’s source. I committed these changes to my github repository: http://github.com/zaki/3di-viewer-rei, however the changes are not in the master branch, which I try to keep as a clean integration copy (therefore there is a little time delay). Get the Irrlicht 1.6 supporting sources from the ‘linux’ branch.

One more thing…

Ahem… did I just say ‘linux’ branch? Well, that’s probably because I’ve also started working on Rei linux support and so far things look quite bright (as opposed to the MacOSX support, but maybe later about that). I managed to make Rei run on my Ubuntu machine in standalone mode using Irrlicht.NETCP and mono. There are still a ton of things that need fixing, but it’s only a matter of time before a consistent framerate is achieved – I had driver issues and occasional performance problems, probably not unrelated. There are some problems with JPEG2000 support that I didn’t have time to look at yet and haven’t written shaders (OpenGL seems to hate HLSL shaders for some reason :) , but everything in its own time.

So if you feel particularly adventurous, go ahead and grab the sources from the ‘linux’ branch – Irrlicht.NETCP’s master branch now includes linux support -, compile them on your linux machine and do let me know how it works for you.

Tags: , , , , ,