Archive for January, 2008

cvXporter: DirectX .x File Exporter for Maya

January 31st, 2008 No comments

Chad Vernon wrote a utility that can export Maya models to .x file, which in turn can be used in Microsoft DirectX. You can download cvxporter v1.2 here.

Installation Instructions for cvxporter v1.2

Copy to your scripts directory (i.e. My Documents\\maya\\2008\\scripts\\). Then invoke your Python Window by selecting Window -> General Editors -> Script Editor from within Maya and type:

import cvxporter

If you see the error:

# Error: No module named cvxporter
# Traceback (most recent call last):
# File "“, line 1, in
# ImportError: No module named cvxporter #

It means, your PYTHONPATH isn’t set up properly. Create an environment variable name PYTHONPATH and set its value to the path to your maya scripts directory.

Categories: C#, Game Tags:

Visual C# Note: Create a Shortcut for a .NET Deployment Project

January 30th, 2008 1 comment

Shortcuts are not automatically generated when you use the Setup Wizard to create a deployment project in Visual Studio .NET. This article explains how to create shortcuts from within the Visual Studio Deployment Tool.

Steps to Create Shortcuts
You can use the following procedure to create shortcuts in your deployment project:

  1. Open the File System Editor: from the View menu, point to Editor, and then click File System.
  2. Open the application folder that contains the file that you want to create a shortcut for.
  3. Right-click the file that you want to create a shortcut to.
  4. Click Create Shortcut.
  5. A shortcut will be created in the same folder as the original file.
  6. Drag the shortcut to the desired folder. For example, if you want to create a shortcut in your Program menu, drag the shortcut to the Programs menu folder; if you want to create a shortcut on the Start menu, drag the shortcut to the Start menu folder. The folder location of the shortcut can also be changed through the folder field of the Properties Window.
  7. You can change the icon for the shortcut in the Property Window.

Categories: C# Tags:

Visual C# Note: Create an Installer in Visual Studio 2005

January 30th, 2008 No comments

How to create a Setup package

  1. Start a new project by doing one of the following:
    a). On the File menu, point to New, and then click Project.


    b). If you have an project open that you would like to create a setup package for, right-click Solution MyProject (where the name of your project is MyProject) in the Solution Explorer, point to Add, and then click New Project.

  2. In the New Project dialog box, select Setup and Deployment Projects in the Project Type pane, and then select the type of setup that you want in the Templates pane.

    The project is added to the Solution Explorer, and then the File System Editor opens.

  3. In the Properties dialog box, select the ProductName property, and then type the name of your product.

How to add files to the Setup package

  1. In the File System Editor, select the Application Folder node.
  2. Right-click the Application folder, and then on the Action menu, click Add, File. In the Add Files dialog box, browse to select any files that you need to add to your application.

    NOTE: If you already have an application project in your solution, you can add the project outputs by selecting Project Outputs instead of File.

  3. To add an existing merge module to your setup package (this is not possible for a Cab project), right-click the name of your setup package in the Solution Explorer. Click Add, and then click Merge Module. In the Add Modules dialog box, browse to select any merge modules that you need to add to your application.
Categories: C# Tags:

Visual C# Note: Use Transparant Texture in DirectX

January 26th, 2008 No comments
  • First of all, use your favorite image processing software, such as Adobe Photoshop or Paint Shop Pro, to create a texture that contains an alpha channel.
  • Secondly, use DirectX.Direct3D.TextureLoader.FromFile() method to load your texture into DirectX. When you do this, pass a color-key parameter to the method to inform DirectX which color you want DirectX to render transparantly.

    // Pass the color-key (0xffffff in this example)
    gameBoardObject.TextureGameBoard = TextureLoader.FromFile(deviceGraphics, "Texture.png", 0, 0, 0, 0, Format.Unknown, Pool.Managed, Filter.Linear, Filter.Linear, 0xffffff);
  • Lastly, enable alpha blending in your graphics device. You do it like this:

    // Enable alpha blending to use transparent texture
    deviceGraphics.RenderState.SourceBlend = Blend.SourceAlpha;
    deviceGraphics.RenderState.DestinationBlend = Blend.InvSourceAlpha;
    deviceGraphics.RenderState.AlphaBlendEnable = true;
Categories: C# Tags:

Visual C# Note: Right-Align Text on Status Bar

January 21st, 2008 No comments

Very easy. Follow these steps:

  1. Create a StatusLabel on the status bar.
  2. Set TextAlign to MiddleRight.
  3. Set Spring to True.


Categories: C# Tags:

Visual C# Note: Value Type and Reference Type

January 18th, 2008 No comments

In C#, a variable that “stores” an object, such as an array, does not actually store the object itself. Instead, such a variable stores a reference to the object (i.e., the location in the computer’s memory where the object itself is stored). The distinction between reference-type variables and value-type variables raises some subtle issues that you must understand to create secure, stable programs.

As you know, when an application passes an argument to a method, the called method receives a copy of that argument’s value. Changes to the local copy in the called method do not affect the original variable in the caller. If the argument is of a reference type, the method makes a copy of the reference, not a copy of the actual object that is referenced. The local copy of the reference also refers to the original object in memory, which means that changes to the object in the called method affect the original object in memory.

Categories: C# Tags:

Visual C# Note: Use Custom Mouse Pointer

January 17th, 2008 No comments

Although the .NET Framework does not directly support animated cursors (.ani) and colored cursors other than black and white, you can achieve this by using the interop features provided in the .NET Framework.

You can use the Windows API function, LoadCursorFromFile, to load a colored or animated cursor, and pass this loaded cursor over to the .NET Framework Cursor for use.

Here’s how to implement the animated cursor or colored cursors using this function:

using System.Runtime.InteropServices;
[DllImport("user32.dll", EntryPoint = "LoadCursorFromFileW", CharSet = CharSet.Unicode)]
public static extern IntPtr LoadCursorFromFile(String str);

Once the function is declared, you can use the LoadCursorFromFile function as if it were a .NET Framework method. It takes the file name containing a cursor as the parameter. You can then call the function and attach the cursor object to the desired control:

IntPtr hCursor = LoadCursorFromFile(filename);
this.Cursor = new Cursor(hCursor);

Categories: C# Tags:

Visual C# Note: Display Text on Status Bar

January 16th, 2008 No comments
  • In .Net Framework, StatusStrip replaces the StatusBar control. To display text on a status bar, add a StatusLabel control to the StatusStrip control. Then set the Text property of the StatusLabel in the program.

    Assume the name of the StatusLabel is toolStripStatusLabel1, the following code displays “Hello, World!” in the status bar:

    this.tooStripStatusLabel1.Text = "Hello, World!";

Categories: C# Tags:

Visual C# Note: Point.Offset(), PointToClient() and PointToScreen() Methods

January 13th, 2008 No comments
  • void Point.Offset(int x, int y) is used to offset the horizontal and vertical coordinates of a point by the amount of x and y, respectively. The following sample code offsets a point pOriginal(325, 170) by the amount of (10, 20). The new coordinates for pOriginal becomes (335, 190).

    using System.Drawing;
    Point pOriginal = new Point(325, 170);
    pOriginal.Offset(10, 20);

  • Point PointToClient(Point p) and Point PointToScreen(Point p) are used to transform the coordinates of a point between the client coordinate system and the screen coordinate system. The following sample code convert the current mouse pointer position into the client coordinate system and assign the return value to a Point variable called ptTemp.

    using System.Windows.Forms;
    Point ptTemp = PointToClient(MousePosition);
Categories: C# Tags: