How to make a 3d rpg camera in 10 steps
error =S
I'm Using the file you provided for download and it compiles with
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class irr::IrrlichtDevice * __cdecl irr::createDevice(enum irr::video::E_DRIVER_TYPE,class irr::core::dimension2d<int> const &,unsigned int,bool,bool,bool,class irr::IEventReceiver *,char const *)" (__imp_?createDevice@irr@@YAPAVIrrlichtDevice@1@W4E_DRIVER_TYPE@video@1@ABV?$dimension2d@H@core@1@I_N22PAVIEventReceiver@1@PBD@Z) referenced in function _main
Debug/3drpg camera.exe : fatal error LNK1120: 1 unresolved externals
I'm using version 1.3.1
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class irr::IrrlichtDevice * __cdecl irr::createDevice(enum irr::video::E_DRIVER_TYPE,class irr::core::dimension2d<int> const &,unsigned int,bool,bool,bool,class irr::IEventReceiver *,char const *)" (__imp_?createDevice@irr@@YAPAVIrrlichtDevice@1@W4E_DRIVER_TYPE@video@1@ABV?$dimension2d@H@core@1@I_N22PAVIEventReceiver@1@PBD@Z) referenced in function _main
Debug/3drpg camera.exe : fatal error LNK1120: 1 unresolved externals
I'm using version 1.3.1
Geo877
just add
somwhere before main ();
just add
Code: Select all
#pragma comment(lib,"irrlicht.lib")
using Visual Studio 2003 , I use 3D Max 7, I love irrlicht its a really good and easy engine
-
- Posts: 616
- Joined: Wed Nov 01, 2006 6:26 pm
- Location: Cairo,Egypt
- Contact:
-
- Posts: 17
- Joined: Mon Oct 30, 2006 12:39 pm
Hey, I tried this resource with my code...It compiles fine, but when I press any of the buttons when running, nothing happens - the camera points at the object just fine. It looks like I've done everything the same as you have, but something must be wrong somewhere. I did get 12 warnings though.
I've looked it over, but my C++ and Irrlicht knowledge is quite up to scratch so I didn't see anything wrong with it, if anyone could quickly check over and see what's stopping me from using the input I would be most grateful (Running VC++ 2005 Exp, Irrlicht 1.3)
(Using the media that comes with irrlicht)
Cheers.
I've looked it over, but my C++ and Irrlicht knowledge is quite up to scratch so I didn't see anything wrong with it, if anyone could quickly check over and see what's stopping me from using the input I would be most grateful (Running VC++ 2005 Exp, Irrlicht 1.3)
(Using the media that comes with irrlicht)
Code: Select all
/*
This Tutorial shows how to set up the IDE for using the
Irrlicht Engine and how to write a simple HelloWorld
program with it. The program will show how to use the
basics of the VideoDriver, the GUIEnvironment and the
SceneManager.
Microsoft Visual C++ 6.0 and .NET is used as
example IDE, but you will also be able to understand everything
if you are using a different one or even another operating
system than windows.
To use the engine, we will have to include the header file
irrlicht.h, which can be found in the Irrlicht Engine SDK
directory \include.
To let the compiler find this header file, the directory where
it is located should be specified somewhere. This is different
for every IDE and compiler you use. I explain shortly how to
do this in Microsift Visual Studio C++ 6.0 and .NET:
- If you use Version 6.0, select the Menu Extras -> Options.
Select the directories tab, and select the 'Include' Item in the combo box.
Add the \include directory of the irrlicht engine folder to the list of directories.
Now the compiler will find the Irrlicht.h header file. We also
need the irrlicht.lib to be found, so stay
in that dialog, select 'Libraries' in the combo box and add the
\lib\VisualStudio directory.
- If your IDE is Visual Studio .NET, select Tools -> Options.
Select the projects entry and then select VC++ directories.
Select 'show directories for include files' in the combo box, and
add the \include directory of the irrlicht engine folder to the list of directories.
Now the compiler will find the Irrlicht.h header file. We also
need the irrlicht.lib to be found, so stay
in that dialog, select 'show directories for Library files' and add the
\lib\VisualStudio directory.
That's it, with your IDE set up like this, you will now be able to
develop applications with the Irrlicht Engine.
*/
#include <irrlicht.h>
#include <iostream>
/*
In the Irrlicht Engine, everything can be found in the namespace
'irr'. So if you want to use a class of the engine, you have to
write an irr:: before the name of the class. For example to use
the IrrlichtDevice write: irr::IrrlichtDevice. To get rid of the
irr:: in front of the name of every class, we tell the compiler
that we use that namespace from now on, and we will not have to
write that 'irr::'.
*/
using namespace irr;
/*
There are 5 sub namespaces in the Irrlicht Engine. Take a look
at them, you can read a detailed description of them in the
documentation by clicking on the top menu item 'Namespace List'
or using this link: http://irrlicht.sourceforge.net/docu/namespaces.html.
Like the irr Namespace, we do not want these 5 sub namespaces now,
to keep this example simple. Hence we tell the compiler again
that we do not want always to write their names:
*/
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
/*
To be able to use the Irrlicht.DLL file, we need to link with the
Irrlicht.lib. We could set this option in the project settings, but
to make it easy, we use a pragma comment lib:
*/
//Set up booleans
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
bool up = false;
bool down = false;
bool right = false;
bool left = false;
int speed =5;
//Make an event Class
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
up = event.KeyInput.PressedDown;
break;
case KEY_KEY_S:
down = event.KeyInput.PressedDown;
break;
case KEY_KEY_A:
left = event.KeyInput.PressedDown;
break;
case KEY_KEY_D:
right = event.KeyInput.PressedDown;
break;
}
//return true;
}
return false;
}
};
/*
This is the main method. We can use int main() on every platform.
On Windows platforms, we could also use the WinMain method
if we would want to get rid of the console window, which pops up when
starting a program with main(), but to keep this example simple,
we use main().
*/
int main(int argc, char** argv)
{
//=====================================\\
//
//==========SETUP======================\\
//
//=====================================\\
//Event Class
MyEventReceiver receiver;
//Setup the Irrlicht display device
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<s32>(1024, 768), 32,
false, false, false, 0);
//This sets the Window Caption
//device->setWindowCaption(L"RPG Engine By Seppuku Arts");
//Setup Devices
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
//=====================================\\
//
//==========LOAD SCENE======================\\
//
//=====================================\\
//setup Fog
driver->setFog(video::SColor(0,138,125,81), true, 250, 1000, 0, true);
// set a nicer font
//ADD TEXT
guienv->addStaticText(L"Stuff...",
rect<int>(10,10,260,62), true);
//==========MAP=========\\
device->getFileSystem()->addZipFileArchive("media/map-20kdm2.pk3");
scene::IAnimatedMesh* Level_Mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* Level_Node = 0;
if (Level_Mesh)
Level_Node = smgr->addOctTreeSceneNode (Level_Mesh->getMesh(0));
if (Level_Node)
Level_Node->setPosition(core::vector3df(-1300,-144,-1249));
//========DWARF MODEL=======\\
//Load the object to a node
IAnimatedMesh* dwarfMesh= smgr->getMesh("media/dwarf.x");
IAnimatedMeshSceneNode* dwarf = smgr->addAnimatedMeshSceneNode( dwarfMesh );
//scene::ISceneNode* node = 0;
//Apply settings to this node - animation, lighting and texture
if (dwarf)
{
//smgr->getMeshManipulator()->makePlanarTextureMapping(
// mesh->getMesh(0), 0.003f);
// video::ITexture* colorMap = driver->getTexture("media/dwarf.jpg");
// video::ITexture* normalMap = driver->getTexture("media/dwarf bump.jpg");
// scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(
// mesh->getMesh(0));
// node= smgr->addMeshSceneNode(tangentMesh);
// node->setMaterialTexture(0, colorMap);
// node->setMaterialTexture(1, normalMap);
// node->getMaterial(0).EmissiveColor.set(0,0,0,0);
// node->setMaterialFlag(video::EMF_FOG_ENABLE, true);
// node->setMaterialType(video::EMT_PARALLAX_MAP_SOLID);
// node->getMaterial(0).MaterialTypeParam = 0.02f; //Adjust height for effect
//drop mesh because we create it was a create call
// tangentMesh->drop();
dwarf->setMaterialFlag(EMF_LIGHTING, false);
dwarf->setMD2Animation ( scene::EMAT_STAND );
dwarf->setMaterialTexture( 0, driver->getTexture("media/dwarf.jpg") );
}
/*
To look at the mesh, we place a camera into 3d space at the position
(0, 30, -40). The camera looks from there to (0,5,0).
*/
//smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
//Setting up a user controlled camera:
//smgr->addCameraSceneNodeFPS();
ICameraSceneNode* camera = smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
//Lets hide the mouse Cursor
device->getCursorControl()->setVisible(false);
/*
Ok, now we have set up the scene, lets draw everything:
We run the device in a while() loop, until the device does not
want to run any more. This would be when the user closed the window
or pressed ALT+F4 in windows.
*/
//An Integer for the the frame rate:
int lastFPS = -1;
while(device->run())
{
/*
Anything can be drawn between a beginScene() and an endScene()
call. The beginScene clears the screen with a color and also the
depth buffer if wanted. Then we let the Scene Manager and the
GUI Environment draw their content. With the endScene() call
everything is presented on the screen.
*/
core::vector3df pos = dwarf->getPosition();
core::vector3df rot = dwarf->getRotation();
float diry = ((rot.Y+90)*3.14)/180;
if (up)
{
pos.X += speed * cos((rot.Y) * 3.14/ 180);
pos.Z -= speed * sin((rot.Y) * 3.14/180);
}
if (down)
{
pos.X -= speed * cos((rot.Y) * 3.14/180);
pos.Z += speed * sin((rot.Y) * 3.14/180);
}
if (left)
{
rot.Y -= 0.1;
}
if (right)
{
rot.Y += 0.1;
}
dwarf->setRotation(rot);
int xf = (pos.X-sin(diry)*125);
int yf = (pos.Z-cos(diry)*125);
int zf = 100;
dwarf->setPosition(pos);
camera->setTarget(pos);
pos.Y += 200.f;
pos.Z -= 150.f;
camera->setPosition(vector3df(xf,zf,yf));
//RENDER
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
//Grab frame rate
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Test Demo|";
str += driver->getName();
str += "|Frame Rate = ";
str += fps;
device->setWindowCaption (str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
Running into walls is not a good idea...Trust me
Hi, the only thing you need to do is change this:
to this:
Regards,
ShUr1k3n
Code: Select all
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<s32>(1024, 768), 32,
false, false, false, 0);
Code: Select all
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<s32>(1024, 768), 32,
false, false, false, &receiver);
ShUr1k3n
Thank you so much!
This was extremely helpful in developing my RPG 3rd person camera.
Now I have to figure out a way to turn the model and have the camera follow behind in a World of Warcraft / Guildwars / KalOnline way. My favorite camera style being World of Warcraft, because of the optional mouse movement.
Thanks again.
// Link
This was extremely helpful in developing my RPG 3rd person camera.
Now I have to figure out a way to turn the model and have the camera follow behind in a World of Warcraft / Guildwars / KalOnline way. My favorite camera style being World of Warcraft, because of the optional mouse movement.
Thanks again.
// Link
-
- Posts: 7
- Joined: Wed Sep 19, 2007 3:58 pm
OMg Thats so strange a month a go i couldn't read the code but I can now and I understand it wow. Question Where did you get the formulas from?
Programming Blog: http://www.uberwolf.com
1 little problem maybe no one noticed but if u run forward its all fine but if u rotate at anytime then when u run forward u get this shaky look from the camera... i was trying to see why but cant see it, i know it is as soon as d.Y changes value the camera kind of shakes a little... if u dont know what i mean create a skybox then run to it rotate then start running and ull see the effect i mean... any help with this?
congratsdejai wrote:OMg Thats so strange a month a go i couldn't read the code but I can now and I understand it wow.
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
Re: How to make a 3d rpg camera in 10 steps
Excellent tuto... but the link doesn´t work anymore...omar shaaban wrote:Well hi guys i saw many peaple asking how to make a 3d rpg camera, i know there are many out there but i will post mine so we can have many choices in choosing the code u prefer
...
and this is all in easy 10 steps any qustion just drop it here
well here is the main.cpp :
http://www.sharebigfile.com/file/195814/main-cpp.html
I copied the code and when I compile it I keep getting this error:
Code: Select all
Error 1 error C2259: 'MyEventReceiver' : cannot instantiate abstract class c:\c++ projects\park demo\park demo\main.cpp 52