I shall create project on base Wiki Basic Tutorial 2 (Cameras, Lights, and Shadows) Here is code
--------------------------------------------------------------
Code: Select all
#include "ExampleApplication.h"
class TutorialApplication : public ExampleApplication
{
protected:
public:
TutorialApplication()
{
}
~TutorialApplication()
{
}
protected:
virtual void createCamera(void)
{
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(0,10,500));
mCamera->lookAt(Vector3(0,0,0));
mCamera->setNearClipDistance(5);
}
virtual void createViewports(void)
{
// Create one viewport, entire window
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));
// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
void createScene(void)
{
Entity *ent;
Light *light;
mSceneMgr->setAmbientLight( ColourValue( 0, 0, 0 ) );
mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_ADDITIVE );
ent = mSceneMgr->createEntity( "Ninja", "ninja.mesh" );
ent->setCastShadows( true );
mSceneMgr->getRootSceneNode()->createChildSceneNode( )->attachObject( ent );
Plane plane( Vector3::UNIT_Y, 0 );
MeshManager::getSingleton().createPlane("ground",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);
ent = mSceneMgr->createEntity( "GroundEntity", "ground" );
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
ent->setMaterialName("Examples/Rockwall");
ent->setCastShadows(false);
light = mSceneMgr->createLight( "Light1" );
light->setType( Light::LT_POINT );
light->setPosition( Vector3(0, 150, 250) );
light->setDiffuseColour( 1.0, 0.0, 0.0 );
light->setSpecularColour( 1.0, 0.0, 0.0 );
light = mSceneMgr->createLight( "Light3" );
light->setType( Light::LT_DIRECTIONAL );
light->setDiffuseColour( ColourValue( .25, .25, 0 ) );
light->setSpecularColour( ColourValue( .25, .25, 0 ) );
light->setDirection( Vector3( 0, -1, 1 ) );
light = mSceneMgr->createLight( "Light2" );
light->setType( Light::LT_SPOTLIGHT );
light->setDiffuseColour( 0, 0, 1.0 );
light->setSpecularColour( 0, 0, 1.0 );
light->setDirection( -1, -1, 0 );
light->setPosition( Vector3( 300, 300, 0 ) );
light->setSpotlightRange( Degree(35), Degree(50) );
}
};
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
// Create application object
TutorialApplication app;
try {
app.go();
} catch( Exception& e ) {
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occured: %s\n",
e.getFullDescription().c_str());
#endif
}
return 0;
}
Beside me video card GeForce 4 440 MX 64DDR
When I start this project with use DirectX 9 beside me much are bad drawn shade, more exactly shade are drawn, but object "ninja" when on he directs the camera (when he only falls into frame) why-that he is not drawn orderly, immediately appear distortion as soon as camera from he conducts all become orderly.
When I start this example on OpenGL all are displayed much well.
Prompt in than surrender can be a reason?
P.S.
Excuse me for my english.