The website of Lei Chen

Sunshine and rain of a developer

Ubuntu 9.10 Dual Screen Resolution Problme[Solved]

Posted by hide1713 on November 8, 2009

I just installed Ubuntu 9.10 yesterday. The only problem is that 9.10 fail to detect my dual monitors; therefore, the resolution of my two monitors were set to 1024*768 by default. I spent one day to complete solve this problem. My graphic card is a ATI one. You may skip this page if your graphic card is not ATI. Here’s how.

1. Download ATI driver from Ubuntu Hardware Driver setting. Run the following command.

sudo amdcccle

2. Set correct resolution for both screen. (1280*800 and 1600*1200 for me). It was weird at the beginning, because ATI control center only allowed me to set my second monitor to 1280*800. I solved this problem by unplugging the monitor and reboot my box(Maybe).

3. (Optional) Revert the screen location. My second monitor is on my right hand side. I tried to set the screen position in AIT control center. But the control center always crash after I apply the change. I have no option but changing xorg.conf manually.

Section “Monitor”
Identifier   “0-LCD”
Option      “VendorName” “ATI Proprietary Driver”
Option      “ModelName” “Generic Autodetecting Monitor”
Option      “DPMS” “true”
Option      “PreferredMode” “1280×800″
Option      “TargetRefresh” “60″
Option      “Position” “0 0″
Option      “Rotate” “normal”
Option      “Disable” “false”
EndSection

Section “Monitor”
Identifier   “0-CRT1″
Option      “VendorName” “ATI Proprietary Driver”
Option      “ModelName” “Generic Autodetecting Monitor”
Option      “DPMS” “true”
Option      “PreferredMode” “1600×1200″
Option      “TargetRefresh” “60″
Option      “Position” “1280 0″
Option      “Rotate” “normal”
Option      “Disable” “false”
EndSection

The position option indicates the start point of a screen.

All Done!

 

 

 

Posted in Ubuntu | Leave a Comment »

Gamebryo Frame Rendering System Reading Notes

Posted by hide1713 on October 21, 2009

Let’s look into Gamebryo frame rendering system. The documentation is located in:

Gamebryo Document->Programmer Level-> Core Runtime -> Frame Rendering System

The propose of the frame rendering system is to make rendering code portable.  Applications that use the frame rendering system do all their configuration work up front. The complex effects can be performed automatically at render time.

Render Frame(NiRenderFrame) represents an entire rendering process. It must be set up during initialization and displayed each frame. It has many render steps and iterates through the rend steps telling them to hook callback function to a frame.

Render Step(NiRenderStep) is a single rendering effect. It does the actual rendering work. It can be turned on/off to control the final effect. One Rend Step usually performs one or more rendering passes via render click objects.

Render Click(NiClickRenderStep) is a complete rendering pass. It can be easily enabled or disabled by 1) application in every frame 2) a render click validator according to some criteria. 3) pre/post callback function.

Render View(NiRenderView) objects provide a certain type of render click with an array of geometry to render. They can do this by culling a scene graph against a camera or by using some other algorithm to determine which geometry objects need to be rendered.

Render List Processor(NiRenderListProcessor) ,During rendering, the processor is passed an array of geometry objects that need to be rendered and passes back an array of objects that still need to be rendered. By controlling that output array, the render list processor can modify the geometry array, such as rendering some geometry objects immediately and deferring rendering of a sorted list for later.

Posted in GameBryo | Leave a Comment »

GameBryo Asset Service and Actionmap

Posted by hide1713 on October 15, 2009

GameBryo Asset Service provides an easy way to access game data. For all the assets( Entity models, logic scripts,images etc), the asset service assigns a unique name to each of them.  The unique id is called Uniform Resource Identifier (URI) that is prefixed by the string “urn:”, followed by one or more specifiers.

Examples:

  • urn:gamebryo-scenegraph:Precache—All assets that are tagged with both “gamebryo-scenegraph” and “Precache”, which might be used to identify every asset that should be pre-loaded during application startup.
  • urn:emergent-world:Level1—An asset that is tagged with “emergent-world” and has the name of “Level1″, which might be used to load all the entities needed in the first level of a game.
  • urn:llid:0716a14d-81ca-46f2-9e7e-7dc30ff2c561:Wii—A logical asset with the indicated unique ID and also tagged “Wii”, which might be used to load the Wii variation of an asset selected with an asset-picker in a tool.

Assets in Hello World Demo:

In the hello world example, the HelloWorldService::SetupInputActions() function uses “urn:gamebryo-actionmap:HelloWorldActionMap” to load a key-action map. It maps the “m” key to HELLOWROLD_ACTION_DROP event and “n” key to HELLOWORLD_ACTION_PICKUP event. The  actionmap file is located in \Gamebryo\Media\Samples\GameFramework\HelloWorld\HelloWroldActionMap.actionmap.

Also, in ConfigCommon.ini file, the initial world is specified by

[Game]
InitialWorld = urn:emergent-world:HelloWorld

The question is how does gamebryo map URN  to  file. This question is very important because you must understand the asset service in order to use assets.

Let’s take a close look on HelloWrold cpp project.

In Config.ini file, we have an attribute

[AssetWeb.Win32]
Path=$(SourceBaseDir)/../../../Media

This attribute specifies the root directory for Asset directory. The config manager service will load this attribute in run time. On my computer, the AssetWeb root folder is F:\Gamebryo\Media. There are three files in Media/asset-web-config directory which define the asset web.

The LogicalIdTagger.ini defines some logical tags:

; The Assets are a list of asset types (assigned by the MimeTagger) that should have logical
; asset id’s assigned to them. If the asset does not possess one of these tags, then no logical
; asset id is created for it.  Logical asset id’s are only needed for assets that will be referenced
; by other asset files, like block or model files.
[LogicalIdTagger.Assets]
=gamebryo-scenegraph
=gamebryo-animation
=gamebryo-terrain
=gamebryo-terrain-materialpkg
=physx-terrain
=gamebryo-actionmap
=wwise-sound-bank
=bmp-image

In MimeTagger.ini, for each file extension, a pair of tags is created from the associated MIME  type.  For example, “py=script/python-behavior” will result in every file
with the “.py” extension having two tag values – “script” and “python- behavior”.

xblock=x-world/emergent-world

kf=application/gamebryo-sequence-file
actionmap=application/gamebryo-actionmap
bnk=audio/wwise-sound-bank

Therefore, HelloWorldActionMap.actionmap file is named as “urn:gamebryo-actionmap:HelloWorldActionMap” and the HelloWrold.xblock is named as “urn:emergent-world:HelloWorld”.  The path of those files are irrlevent to urn.  The asset service searches all the sub directories under AssetWeb root and classifies files accordingly.

Key Actionmap

The Hello World example demonstrates two ways of handling key event.

1. Register a key handler function and switch the logic according to key code.


EE_HANDLER(HelloWorldService, HandleKeyDownMessage, KeyDownMessage); // Register handler

void HelloWorldService::HandleKeyUpMessage(const KeyUpMessage *pMessage,
 efd::Category targetChannel)
{
 Entity* pAvatar = GetAvatar();
 if (pAvatar)
 {
 switch (pMessage->GetKey()) // Switch key code
 {
 case NiInputKeyboard::KEY_UP:
 pAvatar->SetPropertyValue("IsMoving", false);
 break;

 case NiInputKeyboard::KEY_LEFT:
 pAvatar->SetPropertyValue("IsTurningLeft", false);
 break;

...

2. Use a data-driven actionmap to bind keys to events. Currently, there’s no tool to help you generate actionmap  file; therefore, you need to edit the file by hand. Please read the The ecrInput Library documentation for detail.


HelloWorldActionMap.actionmap
...
 <Event EventName="HELLOWORLD_ACTION_DROP" EventCategory="0xC000000007765433" EventFlags="RETURN_MAGNITUDE">
 <ActionsList>
 <!--Flags - InputService.h ActionFlags enum - use individual string values or combined bitmask as an int-->
 <!--DeviceID - a way to define action for specific controllers-->
 <!--Modifiers - NiInputKeyboard Modifiers enum-->
 <!--ActionClsID - (ACTION/DPAD/STICK)-->
 <!--Semantic - NiAction.h Semantic enum for gpad string values GP_BUTTON_LUP or NiInputKeyboard.h for key value strings KEY_M, etc-->
 <Action Flags="ON_ACTIVATE" DeviceID="0" Modifiers="0" ActionClsID="ACTION" Semantic="KEY_M"MinRange="-1.000000" MaxRange="1.000000" />
 <Action Flags="ON_ACTIVATE" DeviceID="0" Modifiers="0" ActionClsID="ACTION" Semantic="GP_BUTTON_RDOWN" MinRange="-1.000000" MaxRange="1.000000" />
 </ActionsList>
 </Event>
 <!--0xC000000007765432-->
 <!--13835058055407359026-->
 <Event EventName="HELLOWORLD_ACTION_PICKUP" EventCategory="0xC000000007765432" EventFlags="RETURN_MAGNITUDE">
 <ActionsList>
 <Action Flags="ON_ACTIVATE" DeviceID="0" Modifiers="0" ActionClsID="ACTION" Semantic="KEY_N" MinRange="-1.000000" MaxRange="1.000000" />
 <Action Flags="ON_ACTIVATE" DeviceID="0" Modifiers="0" ActionClsID="ACTION" Semantic="GP_BUTTON_RRIGHT" MinRange="-1.000000" MaxRange="1.000000" />

After you create the actionmap, you can create an action message handler.


// Define the message categories for the actions
static const efd::Category kCAT_STANDALONE_ACTION_PICKUP =
 Category( efd::UniversalID::ECU_Any, 0, 0x07765432 );

static const efd::Category kCAT_STANDALONE_ACTION_DROP =
 Category( efd::UniversalID::ECU_Any, 0, 0x07765433 );

...

void HelloWorldService::HandleActionMessage(const InputActionMessage* pMsg,
 efd::Category targetChannel)
{
 Entity* pAvatar = GetAvatar();

 switch(pMsg->GetClassID())
 {
 case efd::kMSGID_CoreInputAction:
 if (pAvatar)
 {
 if(targetChannel == kCAT_STANDALONE_ACTION_PICKUP)
 {
 pAvatar->SendEvent(pAvatar->GetEntityID(), "Jack", "PickupEntity");
 }
 else if(targetChannel == kCAT_STANDALONE_ACTION_DROP)
 {
 pAvatar->SendEvent(pAvatar->GetEntityID(), "Jack", "DropEntity");
 }
 }
 break;
 }

}

Reference:

Gamebryo Documentation: Programmer Level->Foundation->Asset Runtime Service

Gamebryo Documentation: The ecrInput Library

HelloWorld example project

Posted in GameBryo | Leave a Comment »

Gamebryo weekly notes 2

Posted by hide1713 on October 5, 2009

Weekly Goals Oct 4to Oct 11 .

1. Read the CEGUI intergration source code to find out how to create/add/remove UI item

2. Create my GUI according to the tutorial and load the gui into integration demo

3. Fix the bugs in message service.

4. Complete read the current Londontown source along with relative Gamebryo documentation. Especially for 3d engine part

Posted in GameBryo | Leave a Comment »

Gamebryo weekly notes 1

Posted by hide1713 on September 24, 2009

Weekly Goals Sept 24 to Oct 1 .

1. Write a class to represent/display dynamic string in GameBryo.

Relevant class: Ni2DString, NiString, NiFont etc.

Nots: Ni2DString::Draw()  Draw the string. This call must appear between a call to NiRenderer::BeginUsingRenderTargetGroup and a subsequent call to NiRenderer::EndUsingRenderTargetGroup.

Possible Solution: Edit InputDemo and replace the dynamic string funtions in InputDemo.

2. Add game state in MOUT demo

Right now, the MOUT demo doesn’t support state change. After I finish the dynamic string. I need to add it to MOUT. When player hits ENTER, the game changes to INPUT_STATE and player could type. When the player hits ESC key, the game return to CONTROL_STATE and player could control the movment of soldier.

Questions

1. Gamebryo doesn’t not support UNICODE for the engine.

Furthermore, builds of Gamebryo with UNICODE or _UNICODE defined are not supported.

Check my VS2008 solution setting.

Posted in GameBryo | Leave a Comment »

Lightspeed Debuging 101

Posted by hide1713 on September 20, 2009

First of all, you need to read the Product Tour – Editing Behaviors tutorial. I followed the tutorial step by step. I set the break point and I started a new game. Unfortunately, the game didn’t stop in the breakpoint. After little bit research, I realize the tutorial jumped out the whole section for setting up debugger. I went back and read the Establishing a connection between Toolbench and your game in the chapter Script Debugger: Introduction.

Basically, you need to establish a connection between the game and the Toolbench thought Asset Controller.

1. Add the following code  in your Gamebryo\Samples\GameDemos\MangledMetal\Win32\VC80\Release\Config.ini file. This this the configuration file for your game.

[ChannelManager]
ListenPort=13215
ListenIP=127.0.0.1

This code tells the game to connect to Asset Controller in your system tray though 127.0.0.1(loopback network) and 13215 prot.

2. After that( It’s very important to do this step after your game connets to Asset Controller), you want to toggle the debugger. Follow the instruction of  Product Tour – Editing Behaviors. Open the EseVictim.lua and set a breakpoint in it.  Press Debug->Toggle Scripting Debugging. You will see a new debugging panel. This time, the debugger will stop after enemy hits you. ( If  the game didn’t stop. toggle it off and on once more).

debugger

Posted in LightSpeed | Leave a Comment »

DirectX 10 DrawText Disable Depth Buffer. Here’s how to fix it.

Posted by hide1713 on July 6, 2009

DrawText() is a bitch. It changes device state silently.  You have to use a spirit to save the states before you draw it and reset depth buffer after you draw the text.


void cGraphicsLayer::DrawTextString(int x, int y,
 D3DXCOLOR color, const TCHAR* strOutput)
{
 m_pFontSprite->Begin(D3DX10_SPRITE_SAVE_STATE);
 RECT rect = {x, y, m_rcScreenRect.right, m_rcScreenRect.bottom};

 m_pFont->DrawText(m_pFontSprite, strOutput, -1, &rect, DT_LEFT|DT_NOCLIP , color);
 m_pFontSprite->End();
}

Here’s how to recover the depth buffer. You need to keep your DepthStencilState and set it with OMSetDepthStencilState


void cGraphicsLayer::ResetDepthBuffer()
{
 m_pDevice->OMSetDepthStencilState(m_pDepthStencilState, 1);
}

Good luck

Posted in Uncategorized | Leave a Comment »

System 6 Forever

Posted by hide1713 on June 28, 2009

sys6_1sys6_2

System 6 (also referred to as System Software 6) is a graphical user interface-based operating system for Macintosh computers. It was released in 1988 by Apple Computer and was part of the Mac OS line of operating systems. System 6 was shipped with various Macintosh computers until it was succeeded by System 7 in 1991. The boxed version of System 6 cost 49 USD when introduced.[1] System 6 is classed as a monolithic operating system. It featured an improved MultiFinder, which allowed for co-operative multitasking. The last version of System 6 was released in 1991.

Why system 6?

Macintosh Operating System 6 is probably the nicest operating system ever made. Nowadays it’s considered ancient (development stopped somewhere in 1991) but it’s far from backward and with the use of the proper vintage software you can be just as productive on a System 6 machine as you’d be on a modern Mac. System 6 runs on most older Macintosh computers with 68000, 68020 and 68030 processors. Some of these Machines are also able to run later versions of the Mac OS up to 7.55 and 7.61, but the lower-end models, most notably the so called Compact Macs, the Mac Plus, the SE and the Classic, and the lowend 68020’s, the Mac II and the LC, are better off running System 6. They will be a lot faster with System 6 than with System 7. The reason behind this is the fact that System 6 is not only a lot more compact (it has less features and therefore less code to crunch), but also because System 6 was written in assembly code instead of the high level language C. Assembly code is a bit lower level and because of that a bit closer to the hardware of the machine, making it a lot more responsive.

Read some more system 6 advocacy here

Link System 6 Heven

Posted in Uncategorized | Leave a Comment »

Travelling Salesman Problem

Posted by hide1713 on June 23, 2009

Posted in C | Leave a Comment »

Virtual Studio Smart Operator ‘=’. Add Spaces Around Every ‘=’.

Posted by hide1713 on June 22, 2009

I find it’s really hard to extend the environemnt under VS 2008. Anyway, I have to learn some VB.

I really like the SmartOperator.el in Emacs. When I press ‘=’ key, it automatically insert two spaces around ‘=’.  The following code can do the same thing. You need to create a new macro in VS and put the code in the new macro and bind ‘=’ key to this function.  I hope the code could inspire someone.


Sub space_around_eq()
 Dim s As TextSelection = DTE.ActiveDocument.Selection
 s.CharLeft(True, 2)
 Dim selection = s.Text
 If selection.StartsWith("=") Then
 DTE.ActiveDocument.Selection.Text = "== "
 ElseIf selection.EndsWith("-") Or selection.EndsWith("+") Or selection.EndsWith("*") Or selection.EndsWith("=") Or selection.EndsWith(" ") Then
 DTE.ActiveDocument.Selection.Text = selection.ToString() + "= "
 Else
 DTE.ActiveDocument.Selection.Text = selection.ToString() + " = "
 End If
 End Sub

Posted in C, CPP | Leave a Comment »