Problem : PLSM2 with MFC

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
phoenix928
Gnoblar
Posts: 10
Joined: Tue Mar 29, 2005 2:32 am

Problem : PLSM2 with MFC

Post by phoenix928 »

i make a application use PLSM2 with MFC , but i can`t get the terrain :x

like this:

///// OgreView.cpp

#include "stdafx.h"
#include "mfctest.h"

#include "OgreView.h"

#include <Ogre.h>

using namespace Ogre;

//#ifdef _DEBUG
//#define new DEBUG_NEW
//#endif


// COgreView

IMPLEMENT_DYNCREATE(COgreView, CView)

BEGIN_MESSAGE_MAP(COgreView, CView)
ON_WM_CREATE()
ON_WM_SIZING()
END_MESSAGE_MAP()

// COgreView 构造/析构

COgreView::COgreView()
{

}

COgreView::~COgreView()
{

}

BOOL COgreView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式

return CView::PreCreateWindow(cs);
}

// COgreView 绘制

void COgreView::OnDraw(CDC* pDC)
{
static bool once = true;

static Root* mRoot;
static RenderWindow* mWindow;
static SceneManager* mSceneMgr;
static Camera* mCamera;
if(once)
{
mRoot = new Root();
setupResources();

RenderSystemList* rl = Root::getSingleton().getAvailableRenderers();

RenderSystem * rsys = NULL;

RenderSystemList::iterator it = rl->begin();

while( it != rl->end() )
{
if( -1 != ( *it )->getName().find( "3D9" ) )
{
rsys = (RenderSystem*)( *it );
break;
}
it++;
}

rsys->setConfigOption( "Anti aliasing", "None" );
rsys->setConfigOption( "Floating-point mode", "Fastest" );
rsys->setConfigOption( "Full Screen", "No" );
rsys->setConfigOption( "VSync", "No" );
rsys->setConfigOption( "Video Mode", "640 x 480 @ 32-bit colour" );

mRoot->setRenderSystem( rsys );
mRoot->initialise( false );

NameValuePairList miscParams;
unsigned int h = (unsigned int)this->GetSafeHwnd();
miscParams["externalWindowHandle"] = StringConverter::toString(h);
mWindow = NULL;
mWindow = mRoot->createRenderWindow( "View", 640, 480, false, &miscParams );
once = false;


//mSceneMgr = mRoot->getSceneManager(ST_GENERIC);

mSceneMgr = mRoot->getSceneManager( ST_EXTERIOR_REAL_FAR );
mSceneMgr->setWorldGeometry("paginglandscape2.cfg");

// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(3085, 38700, 3085));
mCamera->lookAt(Vector3(0,0,0));

float tmp;
mSceneMgr->getOption( "VisibleDistance", &tmp);
mCamera->setNearClipDistance( 1 );
// Infinite far plane?
if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE))
{
mCamera->setFarClipDistance(0);
}
else
{
mCamera->setFarClipDistance( tmp );
}

// 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()));

ResourceGroupManager::getSingleton().initialiseAllResourceGroups();


//createScene();
// Set ambient light
mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

// Create a skydome
mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);

// Create a light
Light* l = mSceneMgr->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->setPosition(20,80,50);

Entity *ent;

// Define a floor plane mesh
Plane p;
p.normal = Vector3::UNIT_Y;
p.d = 200;
MeshManager::getSingleton().createPlane("FloorPlane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
p,2000,2000,1,1,true,1,5,5,Vector3::UNIT_Z);

// Create an entity (the floor)
ent = mSceneMgr->createEntity("floor", "FloorPlane");
ent->setMaterialName("Examples/RustySteel");

mSceneMgr->getRootSceneNode()->attachObject(ent);

ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
// Attach to child of root node, better for culling (otherwise bounds are the combination of the 2)
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);

mWindow->update();
}
else
{
mWindow->update();
}
}

#ifdef _DEBUG
void COgreView::AssertValid() const
{
CView::AssertValid();
}

void COgreView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}

#endif //_DEBUG


void COgreView::setupResources(void)
{
// Load resource paths from config file
ConfigFile cf;
cf.load("resources.cfg");

// Go through all sections & settings in the file
ConfigFile::SectionIterator seci = cf.getSectionIterator();

String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
}

int COgreView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;

return 0;
}

void COgreView::OnSizing(UINT fwSide, LPRECT pRect)
{

}
phoenix928
Gnoblar
Posts: 10
Joined: Tue Mar 29, 2005 2:32 am

Post by phoenix928 »

Please help!


thx
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

Do you see something with other scenemanagers ?

plsm2 uses a framlistener, you sure to send the framestaterd and frameended event at each frame ?

Soes ogre.log tells if pages have been loaded ?

(if yes, you should see your terrain texture pages loaded)
phoenix928
Gnoblar
Posts: 10
Joined: Tue Mar 29, 2005 2:32 am

Post by phoenix928 »

thx


let me see
phoenix928
Gnoblar
Posts: 10
Joined: Tue Mar 29, 2005 2:32 am

Post by phoenix928 »

if not use splatting technique , i can see the terrain no height;

Image

http://img62.photo.163.com/snoopren/807 ... 076513.jpg

otherwise, i see nothing besides skybox.

this is my ogre.log
...
16:24:22: Parsing script Splatting6.material
16:24:22: Parsing script Splatting7.material
16:24:22: Parsing script alpha_splat.material
16:24:22: Parsing script shadersplat.material
16:24:22: Parsing script PagingLandScape.overlay
16:24:22: Parsing script PagingLandScape2.overlay
16:24:22: Finished parsing scripts for resource group PLSM2
16:24:22: Texture: cloudy_noon_fr.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
16:24:22: Texture: cloudy_noon_bk.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
16:24:22: Texture: cloudy_noon_lf.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
16:24:22: Texture: cloudy_noon_rt.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
16:24:22: Texture: cloudy_noon_up.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
16:24:23: Texture: cloudy_noon_dn.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
16:24:23: Texture: spot_shadow_fade.png: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
16:24:23: Texture: ps_texture_1k.Small.png: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
16:24:23: Texture: ps_texture_1k.2.2.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:23: Texture: detail3.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
16:24:24: Texture: ps_texture_1k.2.1.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:24: Texture: ps_texture_1k.1.2.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:24: Texture: ps_texture_1k.1.1.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:24: Texture: ps_texture_1k.3.2.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:24: Texture: ps_texture_1k.2.3.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:25: Texture: ps_texture_1k.3.1.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:25: Texture: ps_texture_1k.1.3.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:25: Texture: ps_texture_1k.2.0.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:25: Texture: ps_texture_1k.0.2.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:26: Texture: ps_texture_1k.0.1.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:26: Texture: ps_texture_1k.1.0.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:27: Texture: ps_texture_1k.3.3.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:27: Texture: ps_texture_1k.3.0.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:28: Texture: ps_texture_1k.0.3.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:24:28: Texture: ps_texture_1k.0.0.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.

....
Last edited by phoenix928 on Tue Apr 26, 2005 2:32 am, edited 1 time in total.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

image link is wrong.
It would help understand the cryptic :

"if close all splatting technique , i can see the terrain no height;"

Log at least proves that it loads pages.
User avatar
neocryptek
Gnome
Posts: 335
Joined: Sat Mar 01, 2003 11:21 pm
Location: Idaho, USA
Contact:

Post by neocryptek »

tuan kuranes wrote:image link is wrong.
Just doesnt hotlink, copy and paste into browser works.

-N30
phoenix928
Gnoblar
Posts: 10
Joined: Tue Mar 29, 2005 2:32 am

Post by phoenix928 »

Sorry for my badly English! :oops:

http://img62.photo.163.com/snoopren/807 ... 076513.jpg

i means there no any height data when the application show terrain.

just like a plane.
phoenix928
Gnoblar
Posts: 10
Joined: Tue Mar 29, 2005 2:32 am

Post by phoenix928 »

phoenix928
Gnoblar
Posts: 10
Joined: Tue Mar 29, 2005 2:32 am

Post by phoenix928 »

fixed!


:D

//m_pMainWnd->SendMessage( WM_COMMAND, ID_OGRE_RENDERVIEW );

if(!OgreFramework::getSingletonPtr()->getOgreRoot()->renderOneFrame())
return false;
Post Reply