Wow Camera
Wow Camera
Hello here is the source for the wow camera i promised
video of what it does
http://video.google.com/videoplay?docid ... 72&q=chieh
I will post the source code when i'm done cleaning up
video of what it does
http://video.google.com/videoplay?docid ... 72&q=chieh
I will post the source code when i'm done cleaning up
Last edited by juliusctw on Sat Jun 10, 2006 5:36 pm, edited 1 time in total.
hello
hello
I am in the process of writing it exactly like fps in irrlicht, so you'll just instantiate the class with the scene that it follows, i'll update you when it comes out.
I am in the process of writing it exactly like fps in irrlicht, so you'll just instantiate the class with the scene that it follows, i'll update you when it comes out.
irrlicht game character project
http://picasaweb.google.com/juliusctw/FinishedArt
http://picasaweb.google.com/juliusctw/FinishedArt
i took it out
I took it out cus i'm working on a much better one
irrlicht game character project
http://picasaweb.google.com/juliusctw/FinishedArt
http://picasaweb.google.com/juliusctw/FinishedArt
Hello
The wow camera i had before was really sloppy, i have since then cleaned it us into one camera class. Basically, all you need to do is instantiate it, and it would just work.
So this is a third person camera that you attach a sceneNode to, once it is attached you can press s d f e to move it , w and r to rotate it, the camera would follow, you can also zoom in and out by scrolling the wheel, the right mouse button would rotate the sceneNode and the left would move the camera in a spherical fashion around the sceneNode,
the camera is called IamarCamera since I am building it for my newly found company Iamar , there are no animation bindings so the object doesn't animate it only translates, this is mainly because we have so many different mesh formats , in the future I will write one for MD2 format. You can find it now on my personal website
http://www.freewebs.com/juliusctw/
This is done in linux, so you might have to tweek it a little for window users, the following is how the main.cpp would look like using IamarCamera
//*******************************
#include <irrlicht.h>
#include "IamarCamera.h"
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
class MyEventReceiver : public IEventReceiver
{
public:
MyEventReceiver(scene::ISceneNode* terrain)
{
}
bool OnEvent(SEvent event)
{
return false;
}
private:
scene::ISceneNode* Terrain;
};
//* you don't really need the receiver, the camer would work with out it
int main()
{
// create device
IrrlichtDevice* device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(1024, 768));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
// add Iamar logo
env->addImage(driver->getTexture("logo.png"),
core::position2d<s32>(-40,-40));
// add some help text
gui::IGUIStaticText* text = env->addStaticText(
L"Press 's d f e w r' for movement",
core::rect<s32>(10,453,200,475), true, true, 0, -1, true);
scene::IAnimatedMeshSceneNode* anms = smgr->addAnimatedMeshSceneNode(
smgr->getMesh("../../media/sydney.md2"));
if (anms)
{
anms->setMaterialFlag(video::EMF_LIGHTING, false);
anms->setMD2Animation(scene::EMAT_RUN);
anms->setFrameLoop(320, 367);
anms->setAnimationSpeed(80);
anms->setPosition(core::vector3df(1900*2,255*2,3700*2));
anms->setRotation(core::vector3df(0,180.0f,0));
anms->setMaterialTexture(0, driver->getTexture("../../media/sydney.bmp"));
}
// add camera
// This is the only part required to use this camera
// besides the headers.
// important ::::::::::::::::::::::::::::::::::::::::::::::
//
//
//
scene::IamarCamera* Icamera;
Icamera = new scene::IamarCamera((scene::ISceneNode*)anms, smgr, -1);
smgr->setActiveCamera(Icamera);
// important ::::::::::::::::::::::::::::::::::::::::::::::
// add terrain scene node
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"../../media/terrain-heightmap.bmp");
terrain->setScale(core::vector3df(40, 4.4f, 40));
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("../../media/terrain-texture.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("../../media/detailmap3.jpg"));
terrain->setMaterialType(video::EMT_DETAIL_MAP);
terrain->scaleTexture(10.0f, 20.0f);
// create triangle selector for the terrain
scene::ITriangleSelector* selector
= smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
selector->drop();
// create event receiver
MyEventReceiver receiver(terrain);
device->setEventReceiver(&receiver);
// create skybox
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
/*
That's it, draw everything. Now you know how to use terrain in Irrlicht.
*/
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
// display frames per second in window title
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Terrain Renderer - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
The wow camera i had before was really sloppy, i have since then cleaned it us into one camera class. Basically, all you need to do is instantiate it, and it would just work.
So this is a third person camera that you attach a sceneNode to, once it is attached you can press s d f e to move it , w and r to rotate it, the camera would follow, you can also zoom in and out by scrolling the wheel, the right mouse button would rotate the sceneNode and the left would move the camera in a spherical fashion around the sceneNode,
the camera is called IamarCamera since I am building it for my newly found company Iamar , there are no animation bindings so the object doesn't animate it only translates, this is mainly because we have so many different mesh formats , in the future I will write one for MD2 format. You can find it now on my personal website
http://www.freewebs.com/juliusctw/
This is done in linux, so you might have to tweek it a little for window users, the following is how the main.cpp would look like using IamarCamera
//*******************************
#include <irrlicht.h>
#include "IamarCamera.h"
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
class MyEventReceiver : public IEventReceiver
{
public:
MyEventReceiver(scene::ISceneNode* terrain)
{
}
bool OnEvent(SEvent event)
{
return false;
}
private:
scene::ISceneNode* Terrain;
};
//* you don't really need the receiver, the camer would work with out it
int main()
{
// create device
IrrlichtDevice* device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(1024, 768));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
// add Iamar logo
env->addImage(driver->getTexture("logo.png"),
core::position2d<s32>(-40,-40));
// add some help text
gui::IGUIStaticText* text = env->addStaticText(
L"Press 's d f e w r' for movement",
core::rect<s32>(10,453,200,475), true, true, 0, -1, true);
scene::IAnimatedMeshSceneNode* anms = smgr->addAnimatedMeshSceneNode(
smgr->getMesh("../../media/sydney.md2"));
if (anms)
{
anms->setMaterialFlag(video::EMF_LIGHTING, false);
anms->setMD2Animation(scene::EMAT_RUN);
anms->setFrameLoop(320, 367);
anms->setAnimationSpeed(80);
anms->setPosition(core::vector3df(1900*2,255*2,3700*2));
anms->setRotation(core::vector3df(0,180.0f,0));
anms->setMaterialTexture(0, driver->getTexture("../../media/sydney.bmp"));
}
// add camera
// This is the only part required to use this camera
// besides the headers.
// important ::::::::::::::::::::::::::::::::::::::::::::::
//
//
//
scene::IamarCamera* Icamera;
Icamera = new scene::IamarCamera((scene::ISceneNode*)anms, smgr, -1);
smgr->setActiveCamera(Icamera);
// important ::::::::::::::::::::::::::::::::::::::::::::::
// add terrain scene node
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"../../media/terrain-heightmap.bmp");
terrain->setScale(core::vector3df(40, 4.4f, 40));
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("../../media/terrain-texture.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("../../media/detailmap3.jpg"));
terrain->setMaterialType(video::EMT_DETAIL_MAP);
terrain->scaleTexture(10.0f, 20.0f);
// create triangle selector for the terrain
scene::ITriangleSelector* selector
= smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
selector->drop();
// create event receiver
MyEventReceiver receiver(terrain);
device->setEventReceiver(&receiver);
// create skybox
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
/*
That's it, draw everything. Now you know how to use terrain in Irrlicht.
*/
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
// display frames per second in window title
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Terrain Renderer - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
irrlicht game character project
http://picasaweb.google.com/juliusctw/FinishedArt
http://picasaweb.google.com/juliusctw/FinishedArt
If you want quite smooth, Gothic-like camera from my old project - Blood Giver { http://members.lycos.nl/nadro/download/irrdemo.zip }, you can find the source in following file:
It's quite old and it was written for me only, so it's ugly... { i've run it on irr 0.12 }
Code: Select all
#ifndef _GAM_IRRCAMERA_H_
#define _GAM_IRRCAMERA_H_
class IrrTPPCameraSceneNode
{
public:
ICameraSceneNode *camera;
float xrot;
float zrot;
float deltax;
float deltay;
IAnimatedMeshSceneNode *tnode;
vector3df pos;
void doCameraDoing();
};
////////////////////////////////////////////////////////////////////
void IrrTPPCameraSceneNode::doCameraDoing()
{
core::position2d<f32> cursorPos = irrDevice->getCursorControl()->getRelativePosition();
scene::ICameraSceneNode* camera = irrDevice->getSceneManager()->getActiveCamera();
core::vector3df cameraPos = camera->getAbsolutePosition();
float the__faktor=25/(theFps*5);
// if (the__faktor>1) the__faktor=1;
if (deltax>0)
deltax-=deltax*the__faktor;
if (deltax<0)
deltax-=deltax*the__faktor;
if (deltay>0)
deltay-=deltay*the__faktor;
if (deltay<0)
deltay-=deltay*the__faktor;
float deltamx=( cursorPos.X - 0.5f )*12;
float deltamy=( cursorPos.Y - 0.5f )*12;
deltax += deltamx;
deltay += deltamy;
float limit=((70/theFps)*2.8f);
if (deltax>limit) deltax=limit;
if (deltay>limit) deltay=limit;
if (deltax<-limit) deltax=-limit;
if (deltay<-limit) deltay=-limit;
xrot += deltax;
zrot -= deltay;
if( zrot <-69 )
zrot = -69;
else
if( zrot > 69 )
zrot = 69;
irrDevice->getCursorControl()->setPosition( 0.5f, 0.5f );
core::vector3df playerPos = tnode->getPosition();
// float xf = playerPos.X - cos( direction * PI / 180.0f ) * 3.4f;
float yf = playerPos.Y - sin( zrot * PI / 180.0f ) * 30;
// float zf = playerPos.Z + sin( direction * PI / 180.0f ) * 3.4f;
float xf = playerPos.X - cos( zrot * irr::core::PI / 180.0f ) * cos( (xrot) * irr::core::PI / 180.0f ) * 1;
float zf = playerPos.Z + cos( zrot * irr::core::PI / 180.0f ) * sin( (xrot )* irr::core::PI / 180.0f ) * 1;
vector3df Result;
vector3df Shorty=vector3df(xf, yf, zf);
vector3df shortyNorm=Shorty;
shortyNorm=Shorty-playerPos;
triangle3df Triangle;
line3d<f32> Ray;
playerPos.Y+=8;
Ray.start=playerPos;
bool falling=false;
Ray.end=Shorty;
irrSceneMgr->getSceneCollisionManager()->getCollisionPoint(Ray, map_triangleselector, Result, Triangle);
if (Result==vector3df(0,0,0)) Result=Shorty;
Result= irrSceneMgr->getSceneCollisionManager()->getCollisionResultPosition(
map_triangleselector,
playerPos,
vector3df(2,2,2),
Result-playerPos,
Triangle,
falling,
0.02f,
vector3df(0,0,0));
camera->setPosition( Result );
// glowa kolesia
camera->setTarget( core::vector3df( playerPos.X, playerPos.Y, playerPos.Z ) );
tnode->setRotation( core::vector3df( 0, xrot+90, 0 ) );
if (gracz.moving)
{
tnode->setRotation( core::vector3df( 0, xrot+90+(deltax*9), 0 ) );
}
}
IrrTPPCameraSceneNode zenon;
#endif
i run on linux
hello
i run on linux, i can't open up the exe
i run on linux, i can't open up the exe
irrlicht game character project
http://picasaweb.google.com/juliusctw/FinishedArt
http://picasaweb.google.com/juliusctw/FinishedArt
thanks, i just got wine working
thanks hybrid, i just got wine working, its pretty good
herion:
i ran your program, but it doesn't seem to let me enter when i click on the top option, it just goes to a blue screen with some sound, the second option shows me some instruction, and the last one exits , unless wine is not working, i'm not sure what's going on there
herion:
i ran your program, but it doesn't seem to let me enter when i click on the top option, it just goes to a blue screen with some sound, the second option shows me some instruction, and the last one exits , unless wine is not working, i'm not sure what's going on there
irrlicht game character project
http://picasaweb.google.com/juliusctw/FinishedArt
http://picasaweb.google.com/juliusctw/FinishedArt
that's obviously not going to work
i guess that's the problem
i'm using wine on linux, i don't have directx9 , thanx
do you mind if i play around with some of your mesh? I 'm getting really bored with sydney and faerie
i'm using wine on linux, i don't have directx9 , thanx
do you mind if i play around with some of your mesh? I 'm getting really bored with sydney and faerie
irrlicht game character project
http://picasaweb.google.com/juliusctw/FinishedArt
http://picasaweb.google.com/juliusctw/FinishedArt