Do you like bass?

Wednesday, October 25, 2006

Plugin Template for Visual C#

Now it's ready!

It't time to write a mini-tutorial :-). In order to develop a plugin for Schranz Visuals Tool, you first will need to download the assembly project. It's the file called SVTPlugin.zip.

Once you build it, you will have the assembly ready to start to develop plugins. Now, it's time to start a new project. Before you start coding, you should use the plugin template. Download it here, It's the file called SchrazVTPlugin.zip. Just copy the zip file (yes, the zip file, you don't have to uncompress it) to your Visual Studio item template folder. It's usually located at "My Documents\Visual Studio 2005\Templates\Item templates".

Now, you're ready. Start a new blank library project. Add a reference to SVTPlugin.dll, Microsoft.DirectX, Microsoft.DirectX.Direct3D, System.Drawing and System.Windows.Forms. Add a new SchranzVT Plugin item (search into "user templates") and call it as you like. You should get something like this:


using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.Windows.Forms;
using System.Drawing;
using SVTPlugin;

namespace SchranzVT
{
public class myPlugin : SchranzVTPlugin
{
// Local variables go here
private string svtpName;
private string svtpAuthor;
private string svtpVersion;
private Device device;

// Constructor
public myPlugin()
{
// Assigns name, author and version
// This is used just for information
svtpName = "myPlugin";
svtpAuthor = "lazyUser";
svtpVersion = "6.9";

// Initializes directx device
device = null;

// Inits the plugin
this.init();
}

// Name
public string Name
{
get { return svtpName; }
set { svtpName = value; }
}

// Author
public string Author
{
get { return svtpAuthor; }
set { svtpAuthor = value; }
}

// Version
public string Version
{
get { return svtpVersion; }
set { svtpVersion = value; }
}

// Device
public Device dev
{
get { return device; }
set { device = value; }
}

// Makes some plugin initialization
public void init()
{
// Let's set name, author and version of this plugin
Name = svtpName;
Author = svtpAuthor;
Version = svtpVersion;

// Here goes your initialization code
}

// Go!
public void run()
{
// Let's make this plugin work!
device.BeginScene();

// Let's paint something

// Ends our scene
device.EndScene();
}
}
}


And now, you can code your directx effect. Forget about directX initialization, it will be done by the main program, you just need to paint :-). The run function is the main loop of the plugin.

I think I don't forget anything. Feel free to ask if you have any problem

0 Comments:

Post a Comment

<< Home