Wednesday, July 18, 2007

Portuguese Characters

In the last thread I mencioned that we introduced MovableText. The text was fine, but it didn't suport special portuguese characters like L'ç' L'é' or L'À' . Here's somethings I learn today:

In C++ normal char's take 8 bit's while wide chars take 16 bits.

char:

char c = 'a';

wide char:

wchar_t wc = L'ç';

you have to put an L before the char literal to say that it is a wide char.
Theres also std::wstring for strings of wide chars.

In the MovableText class they use the Ogre::Font class. This class loads a true type font into the ogre system. It supports all types of UTF formats, but by default, it only loads to the memory the characters with unicode between 33 and 166. That's all fine if you're writing English, but if you're writing a language with accents like I am the first 166 characteres are just not enough.

I changed the range to [33, 255] before the Font's loading.

I added this code to MovableText in the setFontName function:
...
mpFont->addCodePointRange( Font::CodePointRange( 33, 255 ));
mpFont->load();
...

and there it is "ÇçáàéèíÍ..."

Tuesday, July 17, 2007

Mesh Exporting, Billboards, Movable Text

After importing my model with the help of an exporter, I started to animate the scene.
The wheels roll nicely and the car bounces a little bit.


fig.1 - Lexi Exporter


There are two more innovations in this scene.
I introduced the billboards which are textures that are always facing the camera.

BillboardSet* bbset = mSceneMgr->createBillboardSet("BBSet",1); bbset->setMaterialName("Examples/Flare"); Billboard* bb = bbset->createBillboard( Vector3( 0,0,0 ) ); FloatRect coords( 0.0, 0.0, 1.0, 1.0 ); bb->setTexcoordRect(coords); billboardNode->attachObject( bbset );

In fig.2 we can see a flare made with a billboard.

fig.2- Animated Car Scene with Flare and Label

We also added the MovableText class to put text on top of objects.

MovableText * msg = new MovableText("fireCarLabel", "Carro dos
bombeiros","Console",12,ColourValue(0.5f,1.0,0.5,1.0f));

Saturday, July 14, 2007

Crash Dummy Car

This is the new model of fire fighting car that will be available throughout the world in the next semester :P


fig.1- Piece of art

So, we need to simulate were all the civil protection car units will go. This will be our test car.

Friday, July 13, 2007

Ogre Visual Studio 2005 port from 2003

In the weekend I felt that my computer was a complete mess. Nothing worked! I want a Mac! sniff Haaaaa! After 2 months of experiments I decided that a Windows reinstall was in order!
To all linux fans ( and I know lot's off them) I only use windows because after 4 days of configurations, I gave up installing Hardware 3D acceleration for OpenGL in my Notebook
(Ati Radeon 9700 Mobile with some weird taiwan tweeks). So...hell... I will be using Windows XP.

I started using Ogre with Visual Studio 2003 (7.1), this time I installed VS 2005 (8.0).
In the beginning nothing worked. To use Ogre3D and VS2005 it is very important for you to install service pack 1 of VS2005.

To make an Ogre Project download the SDK in website here. Download also the AppWizard for Visual Studio 8 here, this will allow you to easily create projects on VS. Finally follow the instruction of the wiki for install SDK and setting up. If you use the wizard you don't have to do most of the things.
fig.1 - Ogre Application Wizard

In this project I usually change some things in the project properties. In the debugging section I change the command and working Directory to the project's bin/Debug directory. The wizard usualy uses the SDK's bin directory.
In the linker Input section I usually add the ws2_32.lib because I need winsockets and winthreads.

Very important, don't forget to copy all the dll's and cfg's in the SDK bin directory to your project bin directory.

First Post: Visualization Component

Hi, after a weird first post months ago(deleted), I decided to follow the steps of André and start writing here on the forum.

I'm Rui Nóbrega and I am the person responsable for the visualization component of the project LifeSaver.

For that means I will be using an open source library called Ogre3D, this is a 3D engine used mainly in computer games. For now the objective is to render a 3D terrain of Guadiana river valley, and present some information on it.

To display the terrain we will be using an Ogre plugin, the Paging Landscape Scene Manager 2 or PLSM2 for short. Theres no official site, but this is a good starting point.

fig.1 - PLSM2 example with Guadiana river valley

For debug purposes I adapted Ogre Console, made some changes for it to work on Ogre 1.4 and to load C++ style class function instead of C function pointers.

There is also a Network component wich will connect to the simulation component made in Repast. This is still in open discussion. The main problem is that the simulation is being done in Java and I'm doing the visualization in C++. For now we are using TCP/IP socket's and threads.
Andre's using the java sockets I'm using winsocket's in C++.

I finally finished reading the Pro Ogre 3D Programming book. It's a nice book, I would recommend for you to learn Ogre from the wiki, feel confortable with it and then read the book to consolidate your knowledge.

Meanwhile the last days were spent learning Adobe Flash CS3 and explaining the portuguese culture to our american teacher Geoff Marslett who came from the University of Texas at Austin.

From now on I will try to make smaller posts.

Tuesday, July 10, 2007

Repast: Organization 2

Repast suggests an architecture to be used while designing a simulation. Basically every simulation is divided, in it's simpler form into a Model Object and an Agent Object.

While this shows how Repast is organized in it's basic structure, does little in aiding the design of a robust architecture.

The way we're organizing our simulations is as follows:
Model Object
ModelBuilder Object
Space Object
Agent Object

The Model must define the parameters of the simulation and works a central point in all the process. So this connects the Agents with the Space and both with the parameters defined by the user. It also specifies the schedules for the different actions of the Agents.

The ModelBuilder encapsulates a set of operations within the Model. The point of this separation is that the set and get of parameters is a quite extensive block of code. We reserve the Model Object to this operations.

The get and set operations works as the Java standard get and set operation. If we have a integer variable named fooBar, it should have the corresponding get and set operations:
public int getFooBar()
public void setFooBar(int i)

Note the capitalized F in the name of the function and uncapitalized f in the name of the variable.

So the model has, besides the get and set operations:
- a setup() function, defining what should be performed (independently of the user set parameters) in order to allow the construction (build) of the Model.
- a begin() function, defining what should be built (dependably of the user set parameters).

These two functions are required by the platform and are attached to the buttons on the interface. This is why one must setup and then initialize every time the simulation is started.

fig.1 - Repast bar

The 8th button is the setup button. It's attached to the setup() function.

The 5th button is the initialize button. It's attached to the begin() function.

Actually, the first time a simulation is played it only needs to be initialized. This gives another perspective of the setup() function. It's supposed to tear down the model. This means it should destroy every instance that is going to be set in the begin() function later on.

We actually make every instance null, after an eventual dispose() operation and call the System.gc(). This forces the garbage collector to clean up and free memory. After this we create the required new instances. Note that the space is not usually destroyed/created here. Here we manage the Agents data structure, the Schedule and the eventual displays. The space has it's own set of operations.

So the begin() function is pretty complex. It involves building all the main components of the model. These are the Space, the Agents, the Schedule and the Displays. This requires four different operations, namely:
buildSpace()
buildAgents()
buildSchedule()
buildDisplay()

The ModelBuilder was thought specifically because of these operations. The begin function looks as something like this:

public void begin() {
builder.buildSpace();
builder.buildAgents();
builder.buildSchedule();
builder.buildDisplays();
}

The everything is set on the builder. This is only for organization purposes. Good practice anyway.

More to follow!

Monday, July 9, 2007

Repast: Organization

Repast is a Agent Based Simulation Platform (Recursive Porous Agent Simulation Toolkit). It was first developed by the University of Chicago. More history and related links can reached starting from it's wikipedia article.

Repast is the Simulation platform we're using to simulate the emergency plan. As far as we're concerned we need something that's well documented and, obviously, significantly tested. Repast fits the description.

It's basic structure is a set of two objects, the Model and the Agent.

The Model holds the simulation itself. It's required by the platform to actually perform any operation.

The Agent represents the simulation agent. As a Agent based environment, this one must be present.

After some weeks studying the platform we came to to conclusion that it is counterproductive to see the simulation in such simple terms.

In the next post we'll present a more robust and useful way to think while working with this (and probably other) platform.

Sunday, July 8, 2007

Multiple Ring Buffer 2

A more realistic MRB was generated with gaps of 250 meters, starting from 500m to 3000m.

fig.1 - MRB for the Auto Rescue Area.

The top purple area is the artificial lake of the Alqueva dam. The red area is the first impact area. The houses and evacuation points can be seen over the green layer. That layer represents the road layer with MRB. In order to know what path to take from one point to another, the MRB layer can be interrogated to find out the buffer where the target point is.

Multiple Ring Buffer

We're using ArcGis to manage our GIS content.

One of our layers is the roads layer. We must be able to ask that layer if some object is near to a target then others, and what should be the best path from it's position to the target's.

To do so we can create a new roads shapefile based on the original one, but with a ring of buffers surrounding each line of the polygon.

The buffers can be created with an arbitrary distance from the main polygon. As an example, a multiple ring buffer was created with 5, 10, 15 and 20 meters from the original polygon.

fig.1 - Original Polygon

fig.2 - Multiple Ring Buffer

In a more realistic situation, the rings may have to be defined with a larger distance from the road. Say between 100 and 1000 meters...

(ArcGis 9.2) To use the Multiple Ring Buffer: Toolbox -> Analysis Tools -> Multiple Ring Buffer