Operating System: :Windows 64:
Render System: :DirectX 11:
Hi guys,
I'm starting to use Ogre 1.13.0.0 with c#. I downloaded the code, compiled following the tips of https://hellholegames.wordpress.com/blog/ and opened the sample project.
I'm trying to put shadow but the compiler doesn't let you run the line: scnMgr.setShadowCameraSetup(org.ogre.ShadowCameraSetupPtr(pssmSetup));
Another thing, the only floor and simbad project when terminating generates "System.AccessViolationException" error in "MeshPtr.Dispose". Is there something wrong with the swig project?
follows the whole code
Code: Select all
using org.ogre;
public class KeyListener : InputListener
{
ApplicationContext ctx;
public KeyListener(ApplicationContext ctx)
{
this.ctx = ctx;
}
public override bool keyPressed(KeyboardEvent evt)
{
if (evt.keysym.sym == 27)
ctx.getRoot().queueEndRendering();
return true;
}
}
public class Example : ApplicationContext
{
InputListener listener;
public Example()
{
listener = new KeyListener(this);
}
public override void setup()
{
base.setup();
addInputListener(listener);
var root = getRoot();
var scnMgr = root.createSceneManager();
var shadergen = ShaderGenerator.getSingleton();
shadergen.addSceneManager(scnMgr); // must be done before we do anything with the scene
scnMgr.setAmbientLight(new ColourValue(.1f, .1f, .1f));
var light = scnMgr.createLight("MainLight");
var lightnode = scnMgr.getRootSceneNode().createChildSceneNode();
lightnode.setPosition(0f, 10f, 15f);
lightnode.attachObject(light);
var cam = scnMgr.createCamera("myCam");
cam.setAutoAspectRatio(true);
cam.setNearClipDistance(0.5f);
var camnode = scnMgr.getRootSceneNode().createChildSceneNode();
camnode.attachObject(cam);
var camman = new CameraMan(camnode);
camman.setStyle(CameraStyle.CS_ORBIT);
camman.setYawPitchDist(new Radian(0), new Radian(0.3f), 15f);
addInputListener(camman);
var vp = getRenderWindow().addViewport(cam);
vp.setBackgroundColour(new ColourValue(.3f, .3f, .3f));
//----------------------------
//scnMgr.setShadowTechnique(org.ogre.ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE);
scnMgr.setShadowTechnique(org.ogre.ShadowTechnique.SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
scnMgr.setShadowTextureCountPerLightType(Light.LightTypes.LT_DIRECTIONAL, 3);
scnMgr.setShadowTextureCount(3);
scnMgr.setShadowTextureSettings(1024, 3, PixelFormat.PF_FLOAT32_R);
scnMgr.setShadowTextureCasterMaterial(MaterialManager.getSingleton().getByName("PSSM/shadow_caster"));
PSSMShadowCameraSetup pssmSetup = new PSSMShadowCameraSetup();
pssmSetup.setSplitPadding(1);
pssmSetup.calculateSplitPoints(3, 0.01f, 500);
pssmSetup.setOptimalAdjustFactor(0, 2);
pssmSetup.setOptimalAdjustFactor(1, 1);
pssmSetup.setOptimalAdjustFactor(2, 0.5f);
scnMgr.setShadowCameraSetup(org.ogre.ShadowCameraSetupPtr(pssmSetup));
scnMgr.setShadowFarDistance(500);
scnMgr.setShadowCasterRenderBackFaces(false);
scnMgr.setShadowTextureSelfShadow(true);
//---------------------------------
var ent = scnMgr.createEntity("Sinbad.mesh");
ent.setCastShadows(true);
var node = scnMgr.getRootSceneNode().createChildSceneNode();
node.attachObject(ent);
node.setPosition(0, 0, 0);
//---------------------------------
Plane plane = new Plane(new Vector3(0, 1, 0), 0);
MeshManager.getSingleton().createPlane("ground", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, 15, 15, 20, 20, true, 1, 2, 2, new Vector3(0, 0, 1));
Entity entPlano = scnMgr.createEntity("chao", "ground");
SceneNode nodePlano = scnMgr.getRootSceneNode().createChildSceneNode("chaoNode");
entPlano.setMaterialName("Examples/Rockwall");
nodePlano.attachObject(entPlano);
nodePlano.setPosition(0,-5,0);
//---------------------------------
}
static void Main()
{
var app = new Example();
app.initApp();
app.getRoot().startRendering();
app.closeApp();
}
}