Ported TextureFx Demo

grizzley90

26-01-2007 00:26:32

I found the time to port another demo, this is the TextureFx demo. It works perfectly with the latest mogre sdk.

TextureFXApp.cs:
using System;
using System.Collections.Generic;
using System.Text;
using Mogre;

namespace TextureFX
{
class TextureFXApp : Mogre.Demo.ExampleApplication.Example
{
void createScalingPlane()
{
// Set up a material for the plane

// Create a prefab plane
Entity planeEnt = sceneMgr.CreateEntity("Plane", SceneManager.PrefabType.PT_PLANE);
// Give the plane a texture
planeEnt.SetMaterialName("Examples/TextureEffect1");

SceneNode node =
sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(-250,-40,-100));

node.AttachObject(planeEnt);
}

void createScrollingKnot()
{
Entity ent = sceneMgr.CreateEntity("knot", "knot.mesh");


ent.SetMaterialName("Examples/TextureEffect2");
// Add entity to the root scene node
SceneNode node =
sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(200, 50, 150));

node.AttachObject(ent);

}

void createWateryPlane()
{
// Create a prefab plane
Entity planeEnt = sceneMgr.CreateEntity("WaterPlane", SceneManager.PrefabType.PT_PLANE);
// Give the plane a texture
planeEnt.SetMaterialName("Examples/TextureEffect3");

sceneMgr.RootSceneNode.AttachObject(planeEnt);
}
// Just override the mandatory create scene method
public override void CreateScene()
{
// Set ambient light
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);

// Create a point light
Light l = sceneMgr.CreateLight("MainLight");
// Accept default settings: point light, white diffuse, just set position
// NB I could attach the light to a SceneNode if I wanted it to move automatically with
// other objects, but I don't
l.Position = new Vector3(20,80,50);

createScalingPlane();
createScrollingKnot();
createWateryPlane();

// Set up a material for the skydome
MaterialPtr skyMat = MaterialManager.Singleton.Create("SkyMat",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
// Perform no dynamic lighting on the sky
skyMat.SetLightingEnabled(false);
// Use a cloudy sky
TextureUnitState t = skyMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("clouds.jpg");
// Scroll the clouds
t.SetScrollAnimation(0.15f, 0f);

// System will automatically set no depth write

// Create a skydome
sceneMgr.SetSkyDome(true, "SkyMat", -5, 2);
}
}
}


Program.cs:
using System;
using System.Collections.Generic;
using System.Text;

namespace CelShading
{
class Program
{
static void Main(string[] args)
{
try
{
CelShading app = new CelShading();
app.Go();
}
catch
{
// Check if it's an Ogre Exception
if (Mogre.OgreException.IsThrown)
Mogre.Demo.ExampleApplication.Example.ShowOgreException();
else
throw;
}
}
}
}

CK_MACK

26-01-2007 02:14:18

Thanks very much for doing these... I am sure they will go along way to helping others (as well as myself!)

BTW, could you list which refereces your demos require please?


Thanks,

Marc.

grizzley90

26-01-2007 03:14:46

Same references as all the other demos. Mogre obviously and Mogre.Demo.ExampleApplication, its in the mogre samples in the mogre sdk... you just gotta compile it, it should compile right away as it is distributed with the mogre sdk. Enjoy!

Bekas

27-01-2007 14:27:56

grizzley, thanks a lot! :) These will go to SVN soon..

Bekas

29-01-2007 12:12:58

grizzley, would you be willing to add the ported demos to SVN trunk yourself ?

I'd only suggest that you follow the conventions of the other demos, in particular:

-using a "Mogre.Demo.XXX" namespace
-The assembly produced should be a "Mogre.Demo.XXX.exe" file
-There should be this post-build event:
copy "$(TargetPath)" "$(SolutionDir)ogrenew\Samples\Common\bin\$(ConfigurationName)"
-Add it to Mogre.sln solution file and add a note to ChangeLog.txt

grizzley90

03-02-2007 15:29:48

Added the last three demos i ported.

Bekas

04-02-2007 10:50:14

Thanks a lot! :)