nolver
26-02-2006 13:26:33
There's a way to create 2D overlays, as the Rectangle2D seems to be not available?
Thanks!
Thanks!
nolver
26-02-2006 13:26:33
rastaman
27-02-2006 03:01:08
nolver
06-03-2006 10:39:18
rastaman
06-03-2006 13:48:04
%{
#include "OgreRectangle2D.h"
%}
%include "OgreRectangle2D.h"
%{
#include "OgreRectangle.h"
%}
%include "OgreRectangle.h"
nolver
22-03-2006 20:00:10
rastaman
22-03-2006 23:58:14
using System;
using System.Collections;
using System.Xml;
using System.Drawing;
using Math3D;
using OgreDotNet;
namespace DemoRectangle2D
{
class cDemoRectangle2D : ExampleApplication
{
protected Rectangle2D mRect2d;
protected override void CreateScene()
{
//a ground plane to have something to look at
Entity e;
SceneNode n;
Plane plane = new Plane();
plane.Normal.x=0.0f;
plane.Normal.y=1.0f;
plane.Normal.z=0.0f;
plane.D = 0.0f;
MeshManager.GetSingleton().CreatePlane( "Myplane01", "General" , plane,
500.0f,500.0f, 10,10,true,1, 5.0f,5.0f, Vector3.UnitZ );
e = mSceneManager.CreateEntity( "plane01", "Myplane01" );
e.SetMaterialName("Examples/GrassFloor");
e.SetCastShadows(false);
n = mSceneManager.GetRootSceneNode().CreateChildSceneNode();
n.AttachObject(e);
// Create background material
ResourcePtr rcmaterial = MaterialManager.Instance.create("Background", "General");
MaterialPtr material = new MaterialPtr( ResourcePtr.getCPtr(rcmaterial).Handle , false );
material.GetTechnique(0).getPass(0).createTextureUnitState("rockwall.tga");
material.GetTechnique(0).getPass(0).setDepthCheckEnabled(false);
material.GetTechnique(0).getPass(0).setDepthWriteEnabled(false);
// Disable lighting on the background (it will show as fully lit)
material.GetTechnique(0).getPass(0).setLightingEnabled(false);
// Create background rectangle
mRect2d = new Rectangle2D(true);
// Cover the whole screen
mRect2d.setCorners(-1.0f, 1.0f, 1.0f, -1.0f);
// Hacky, but we need to set the bounding box to something big
mRect2d.setBoundingBox( new AxisAlignedBox(-100000.0f*Math3D.Vector3.UnitScale, 100000.0f*Math3D.Vector3.UnitScale));
mRect2d.setMaterial("Background");
// Render the background before everything else
mRect2d.SetRenderQueueGroup(RenderQueueGroupID.RENDER_QUEUE_BACKGROUND);
// Attach background to the scene
n = mSceneManager.GetRootSceneNode().CreateChildSceneNode("Background");
n.AttachObject(mRect2d);
// Example of background scrolling
material.GetTechnique(0).getPass(0).getTextureUnitState(0).setScrollAnimation(-0.25f, 0.0f);
mCamera.Move( new Vector3(0, 300, 600) );
mCamera.LookAt = new Vector3( 0, 0, 0 );
}
public override void Dispose()
{
mRect2d.Dispose();
mRect2d=null;
base.Dispose();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
cDemoRectangle2D app = new cDemoRectangle2D();
try
{
app.Start();
}
catch ( Exception ex)
{
Console.WriteLine( "### Exception {0}\n{1}\n{2}", ex.Message ,ex.Source , ex.StackTrace );
}
finally
{
try
{
app.Dispose();
}
catch ( Exception ex)
{
Console.WriteLine( "#### Exception {0}\n{1}\n{2}", ex.Message ,ex.Source , ex.StackTrace );
}
}
}
}
}