water help

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
darkfox404
Posts: 26
Joined: Thu Mar 02, 2006 3:49 am

water help

Post by darkfox404 »

i was just adding water and i got theses errors...

Code: Select all

------ Build started: Project: samurai, Configuration: Debug Win32 ------
Compiling...
main.cpp
.\main.cpp(84) : error C2065: 'mesh' : undeclared identifier
.\main.cpp(90) : error C2065: 'node' : undeclared identifier
.\main.cpp(90) : error C2227: left of '->getMesh' must point to class/struct/union/generic type
        type is ''unknown-type''
.\main.cpp(91) : error C2227: left of '->setPosition' must point to class/struct/union/generic type
        type is ''unknown-type''
.\main.cpp(93) : error C2227: left of '->setMaterialTexture' must point to class/struct/union/generic type
        type is ''unknown-type''
.\main.cpp(110) : error C2065: 'terrain' : undeclared identifier
Build log was saved at "file://c:\Documents and Settings\Tim\My Documents\samurai\samurai\samurai\Debug\BuildLog.htm"
samurai - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Guest

Post by Guest »

We need code, but make sure node, mesh, and terrain are all valid variables.
darkfox404
Posts: 26
Joined: Thu Mar 02, 2006 3:49 am

Post by darkfox404 »

so i fixed the first part and heres my code

i added this:

Code: Select all

scene::ISceneNode* node = 0;

	node = smgr->addAnimatedMeshSceneNode(mesh);
	node->setMaterialTexture(
   0, driver->getTexture("../../media/wall.jpg"));
	node->getMaterial(0).EmissiveColor.set(0,0,0,0);
into this and now im having trouble with mesh

Code: Select all

	mesh = smgr->addHillPlaneMesh("myHill",
		core::dimension2d<f32>(20,20),
		core::dimension2d<s32>(40,40), 0, 0,
		core::dimension2d<f32>(0,0),
		core::dimension2d<f32>(10,10));

	node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
	node->setPosition(core::vector3df(0,7,0));

	node->setMaterialTexture(0,	driver->getTexture("../../media/water.jpg"));
compile error:

Code: Select all

------ Build started: Project: samurai, Configuration: Debug Win32 ------
Compiling...
main.cpp
.\main.cpp(86) : error C2065: 'mesh' : undeclared identifier
.\main.cpp(97) : error C2227: left of '->getMesh' must point to class/struct/union/generic type
        type is ''unknown-type''
Build log was saved at "file://c:\Documents and Settings\Tim\My Documents\samurai\samurai\samurai\Debug\BuildLog.htm"
samurai - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
and the first time mesh comes up in my whole code is here:

Code: Select all

node = smgr->addAnimatedMeshSceneNode(mesh); 
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

the variable 'mesh' is not declared.

http://www.cplusplus.com/doc/tutorial/variables.html
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
darkfox404
Posts: 26
Joined: Thu Mar 02, 2006 3:49 am

Post by darkfox404 »

wtf i can't figure this out can someone please fix this for me
all i did was copy the code from the special effects tutorial

Code: Select all

///////////////////////////////
//Purpose: loads header files//
///////////////////////////////
#include <irrlicht.h>
#include <windows.h>
////////////////////////////////////////////////////////////////////
//Purpose: prevents from having to add video::blahblah every time //
////////////////////////////////////////////////////////////////////
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//////////////////////
//Purpose: loads DLL//
//////////////////////
#pragma comment(lib, "Irrlicht.lib")
/////////////////////////////
//Purpose: Main entry point//
/////////////////////////////
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)	{
	///////////////////////////////////
	//Purpose: makes driver DirectX 9//
	///////////////////////////////////
    video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;
 	IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(800, 600));

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment* env = device->getGUIEnvironment();

    driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

	//add camera
    smgr->addCameraSceneNodeFPS();

	//disables mouse cursor
    device->getCursorControl()->setVisible(false);

	//add .aoz (aura-online zip) archive to the file system
    device->getFileSystem()->addZipFileArchive("media.aoz");

	scene::ISceneNode* node = 0;

	node = smgr->addAnimatedMeshSceneNode(mesh);

	node->setMaterialTexture(
   0, driver->getTexture("../../media/wall.jpg"));
	node->getMaterial(0).EmissiveColor.set(0,0,0,0);

	mesh = smgr->addHillPlaneMesh("myHill",
		core::dimension2d<f32>(20,20),
		core::dimension2d<s32>(40,40), 0, 0,
		core::dimension2d<f32>(0,0),
		core::dimension2d<f32>(10,10));

	node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
	node->setPosition(core::vector3df(0,7,0));

	node->setMaterialTexture(0,	driver->getTexture("../../media/water.jpg"));
	//node->setMaterialTexture(1,	driver->getTexture("../../media/stones.jpg"));

	//node->setMaterialType(video::EMT_REFLECTION_2_LAYER);

	//add sky box
	driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); //turn mipmaps off

	smgr->addSkyBoxSceneNode(
	driver->getTexture("pos_y.bmp"), //up
	driver->getTexture("neg_y.bmp"), //down
	driver->getTexture("neg_x.bmp"), //left
	driver->getTexture("pos_x.bmp"), //right
	driver->getTexture("neg_z.bmp"), //front
	driver->getTexture("pos_z.bmp")); //back

	driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true); //turn mipmaps on

	device->getCursorControl()->setVisible(false);


	int lastFPS = -1;
	while(device->run())
	{
	  driver->beginScene(true, true, video::SColor(0,200,200,200));
	  smgr->drawAll();
	  driver->endScene();

	  int fps = driver->getFPS();

	  if (lastFPS != fps)
	  {
		 core::stringw str = L"Codenamed Samurai";
		 str += " FPS:";
		 str += fps;
		 device->setWindowCaption(str.c_str());
		 lastFPS = fps;
	  }
	}
	  device->drop();
	  return 0;
	}
Guest

Post by Guest »

///////////////////////////////
//Purpose: loads header files//
///////////////////////////////
#include <irrlicht.h>
#include <windows.h>
////////////////////////////////////////////////////////////////////
//Purpose: prevents from having to add video::blahblah every time //
////////////////////////////////////////////////////////////////////
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//////////////////////
//Purpose: loads DLL//
//////////////////////
#pragma comment(lib, "Irrlicht.lib")
/////////////////////////////
//Purpose: Main entry point//
/////////////////////////////
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) {
///////////////////////////////////
//Purpose: makes driver DirectX 9//
///////////////////////////////////
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(800, 600));

video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();

driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

//add camera
smgr->addCameraSceneNodeFPS();

//disables mouse cursor
device->getCursorControl()->setVisible(false);

//add .aoz (aura-online zip) archive to the file system
device->getFileSystem()->addZipFileArchive("media.aoz");

scene::ISceneNode* node = 0;
scene::IAnimatedMesh* mesh = 0;

node = smgr->addAnimatedMeshSceneNode(mesh);

node->setMaterialTexture(
0, driver->getTexture("../../media/wall.jpg"));
node->getMaterial(0).EmissiveColor.set(0,0,0,0);

mesh = smgr->addHillPlaneMesh("myHill",
core::dimension2d<f32>(20,20),
core::dimension2d<s32>(40,40), 0, 0,
core::dimension2d<f32>(0,0),
core::dimension2d<f32>(10,10));

node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
node->setPosition(core::vector3df(0,7,0));

node->setMaterialTexture(0, driver->getTexture("../../media/water.jpg"));
//node->setMaterialTexture(1, driver->getTexture("../../media/stones.jpg"));

//node->setMaterialType(video::EMT_REFLECTION_2_LAYER);

//add sky box
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); //turn mipmaps off

smgr->addSkyBoxSceneNode(
driver->getTexture("pos_y.bmp"), //up
driver->getTexture("neg_y.bmp"), //down
driver->getTexture("neg_x.bmp"), //left
driver->getTexture("pos_x.bmp"), //right
driver->getTexture("neg_z.bmp"), //front
driver->getTexture("pos_z.bmp")); //back

driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true); //turn mipmaps on

device->getCursorControl()->setVisible(false);


int lastFPS = -1;
while(device->run())
{
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();

int fps = driver->getFPS();

if (lastFPS != fps)
{
core::stringw str = L"Codenamed Samurai";
str += " FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
darkfox404
Posts: 26
Joined: Thu Mar 02, 2006 3:49 am

Post by darkfox404 »

what did you do different im still getting the same errors

Code: Select all

.\main.cpp(46) : error C2065: 'mesh' : undeclared identifier
.\main.cpp(58) : error C2227: left of '->getMesh' must point to class/struct/union/generic type
        type is ''unknown-type''
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

i don't mean to be rude, but you really must know what an identifier (variable) is, and how to declare one before you can decipher the error message "\main.cpp(46) : error C2065: 'mesh' : undeclared identifier"

anyway, at risk of repeating myself-

www.cplusplus.com/doc/tutorial/variables.html

you really should read it
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
darkfox404
Posts: 26
Joined: Thu Mar 02, 2006 3:49 am

Post by darkfox404 »

ya i know i gues im kinda getting on your nerves and im sorry but i've read that stuff before and i added int mesh; and this came up

Code: Select all

.\main.cpp(50) : error C2664: 'irr::scene::ISceneManager::addAnimatedMeshSceneNode' : cannot convert parameter 1 from 'int' to 'irr::scene::IAnimatedMesh *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
.\main.cpp(59) : error C2440: '=' : cannot convert from 'irr::scene::IAnimatedMesh *' to 'int'
        There is no context in which this conversion is possible
.\main.cpp(61) : error C2227: left of '->getMesh' must point to class/struct/union/generic type
        type is 'int'
Unarekin
Posts: 60
Joined: Thu Apr 22, 2004 11:02 pm

Post by Unarekin »

darkfox404 wrote:ya i know i gues im kinda getting on your nerves and im sorry but i've read that stuff before and i added int mesh; and this came up

Code: Select all

.\main.cpp(50) : error C2664: 'irr::scene::ISceneManager::addAnimatedMeshSceneNode' : cannot convert parameter 1 from 'int' to 'irr::scene::IAnimatedMesh *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
.\main.cpp(59) : error C2440: '=' : cannot convert from 'irr::scene::IAnimatedMesh *' to 'int'
        There is no context in which this conversion is possible
.\main.cpp(61) : error C2227: left of '->getMesh' must point to class/struct/union/generic type
        type is 'int'
That would be because the variable has to be declared as the correct type. addAnimatedMeshSceneNode returns an IAnimatedMesh, not an int. You'll need to declare the variable 'mesh' as an IAnimatedMesh, much like this:

IAnimatedMesh* mesh;
darkfox404
Posts: 26
Joined: Thu Mar 02, 2006 3:49 am

Post by darkfox404 »

OK THX FOR ALL THE HELP!!!
i got it to work

i just had to add

Code: Select all

	scene::[b]IAnimatedMesh* mesh[/b] = smgr->getMesh(
		"../../media/room.3ds");

	smgr->getMeshManipulator()->makePlanarTextureMapping(
		mesh->getMesh(0), 0.004f);
and theres the IAnimatedMesh* right there in the code
darkfox404
Posts: 26
Joined: Thu Mar 02, 2006 3:49 am

Post by darkfox404 »

NVM
Post Reply