Page 5 of 8

Posted: Fri May 07, 2004 7:27 am
by AssiDragon
Good to hear it works. :)

Posted: Mon May 31, 2004 5:37 pm
by smartwhiz
I figured out a way to get a view similar to that in tomb raider.....
just a couple of changes to the code submitted here.
I too had the linker errors as everyone here had so i wrote all the code splitted
into diff: files into one single file.
the changes applied

1->Box size of the crosshair into 0.0f so that the mouse point is only
in one single point on the screen.
2->Crosshair eluminated frm rendering as this is for a RPG view
3->The model didn't rotate as the camera used to ..... it has been corrected as
now the model rotates with respect to the camera

to get the view .... please add sydney.bmp, sydney.md2 and map-20kdm2 in the
project directory
pls give the comment on it so i can try to improve


//3rdPersonCamera.cpp : Defines the entry point for the application.
//
#pragma once

#include "stdafx.h"
// Standard includy stuff
#include <irrlicht.h>

// IrrLicht lib
#pragma comment(lib, "Irrlicht.lib")


#define EPSILON 0.001f

enum EPLAYER_ACTION
{
EPA_MOVE_FORWARD,
EPA_MOVE_BACKWARD,
EPA_MOVE_LEFT,
EPA_MOVE_RIGHT,

EPA_COUNT
};

//! Defines player states
enum EPLAYER_STATE
{
EPS_RUNNING,
EPS_STANDING
};



// Global Irrlicht variables
irr::IrrlichtDevice *irrBase=0;

class CSceneNodeAnimator3PCamera :
public irr::scene::ISceneNodeAnimator,
public irr::IEventReceiver
{

public:

//! Constructor
//! player: The object to follow
//! initDist: The initial distance from the player
//! initAngleY: The initial horizontal rotatation
//! initAngleZ: The initial vertical rotation
//! targetOffset: The offset from the object's center at which the camera looks
//! minDist/maxDist: Distance bounding
//! minAngle/maxAngle: Rotation bounding. -89 ==> looking up at player, 89 ==> looking down
//! boxSize: The size of the box in which mouse movements do not result in camera movements
//! rotationSpeed/zoomSpeed: Speed of movement, in terms of units/millisecond
CSceneNodeAnimator3PCamera(
irr::scene::ISceneManager *manager,irr::gui::ICursorControl *cursor,irr::scene::ISceneNode *player,
irr::f32 initDist = 50.0f,
irr::f32 initAngleY = 180.0f,
irr::f32 initAngleZ = 10.0f,
irr::core::vector3df &targetOffset = irr::core::vector3df(0,0,0),
irr::f32 minDist = 20.0f,
irr::f32 maxDist = 200.0f,
irr::f32 minAngle = -45.0f,
irr::f32 maxAngle = 89.0f,
irr::f32 boxSize = 0.0f,
irr::f32 rotationSpeed = 60.0f,
irr::f32 zoomSpeed = 2.0f);

//! Destructor
virtual ~CSceneNodeAnimator3PCamera(void);

//! animates the scene node
virtual void animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs);

//! Process an input event
virtual bool OnEvent(irr::SEvent event);

//! Get/set active status
bool isActive();
void setActive(bool status);

//! Get/set box size
irr::f32 getBoxSize();
void setBoxSize(irr::f32 newSize);

//! Map zoom in/zoom out buttons
void mapZoomIn(irr::EKEY_CODE newCode);
void mapZoomOut(irr::EKEY_CODE newCode);

//! Access the camera's current orientation
irr::f32 getOrientation();


private:

bool Active;

// current states
irr::f32 Dist;
irr::f32 AngleY;
irr::f32 AngleZ;

// boundaries
irr::core::vector3df TargetOffset;
irr::f32 MinDist;
irr::f32 MaxDist;
irr::f32 MinAngle;
irr::f32 MaxAngle;
irr::f32 BoxSize;

// Motion
irr::f32 RotationSpeed;
irr::f32 ZoomSpeed;

// Zooming keys
irr::EKEY_CODE ZoomInKey;
irr::EKEY_CODE ZoomOutKey;

bool ZoomIn;
bool ZoomOut;

//! Node to follow
irr::scene::ISceneNode *Player;

irr::scene::ISceneManager *Manager;
irr::gui::ICursorControl *Cursor;

//! Puts the cursor back in the box
void updateCursorPosition();
};


CSceneNodeAnimator3PCamera::CSceneNodeAnimator3PCamera(
irr::scene::ISceneManager *manager,irr::gui::ICursorControl *cursor,irr::scene::ISceneNode *player,
irr::f32 initDist,irr::f32 initAngleY,irr::f32 initAngleZ,
irr::core::vector3df &targetOffset,
irr::f32 minDist,irr::f32 maxDist,irr::f32 minAngle,irr::f32 maxAngle,
irr::f32 boxSize,irr::f32 rotationSpeed,irr::f32 zoomSpeed)
: Active(true), Manager(manager), Cursor(cursor), Player(player),
Dist(initDist),AngleY(initAngleY),AngleZ(initAngleZ),
TargetOffset(targetOffset),
MinDist(minDist), MaxDist(maxDist), MinAngle(-maxAngle), MaxAngle(-minAngle),
BoxSize(boxSize), RotationSpeed(rotationSpeed), ZoomSpeed(zoomSpeed)
{
ZoomIn = false;
ZoomOut = false;

ZoomInKey = irr::KEY_ADD;
ZoomOutKey = irr::KEY_SUBTRACT;

Cursor->setPosition(0.5f,0.5f);

// Ensure Distance is bounded correctly
if(Dist < MinDist) Dist = MinDist;
else if(Dist > MaxDist) Dist = MaxDist;

// Bound MinAngle/MaxAngle to avoid problematic areas
if(MinAngle < -89.0f) MinAngle = -89.0f;
if(MinAngle > 89.0f) MinAngle = 89.0f;
if(MaxAngle < -89.0f) MaxAngle = -89.0f;
if(MaxAngle > 89.0f) MaxAngle = 89.0f;
if(minAngle > maxAngle) MaxAngle = MinAngle+1.0f;

// Ensure Vertical Rotation Angle is bounded correctly
if(AngleZ < MinAngle) AngleZ = MinAngle;
else if(AngleZ > MaxAngle) AngleZ = MaxAngle;
}

//! Destructor
CSceneNodeAnimator3PCamera::~CSceneNodeAnimator3PCamera(void)
{
}

//! Puts the cursor back in the box
void CSceneNodeAnimator3PCamera::updateCursorPosition()
{
irr::core::position2d<irr::f32> pos = Cursor->getRelativePosition();

if(pos.X < (0.5f-BoxSize)) pos.X = (0.5f-BoxSize);
if(pos.X > (0.5f+BoxSize)) pos.X = (0.5f+BoxSize);

if(pos.Y < (0.5f-BoxSize)) pos.Y = (0.5f-BoxSize);
if(pos.Y > (0.5f+BoxSize)) pos.Y = (0.5f+BoxSize);

Cursor->setPosition(pos);
}

//! Process an input event
bool CSceneNodeAnimator3PCamera::OnEvent(irr::SEvent event)
{
if(!Active)
{
return false;
}

if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
if(event.KeyInput.Key == ZoomInKey)
{
ZoomIn = event.KeyInput.PressedDown;
return true;
}
else if(event.KeyInput.Key == ZoomOutKey)
{
ZoomOut = event.KeyInput.PressedDown;
return true;
}
}

return false;
}

//! Get/set active status
bool CSceneNodeAnimator3PCamera::isActive()
{
return Active;
}

void CSceneNodeAnimator3PCamera::setActive(bool status)
{
// reset the cursor only if we are switching back to active from inactive
if(!Active && status)
{
updateCursorPosition();
}

Active = status;
}

//! Get/set box size
irr::f32 CSceneNodeAnimator3PCamera::getBoxSize()
{
return BoxSize;
}

void CSceneNodeAnimator3PCamera::setBoxSize(irr::f32 newSize)
{
BoxSize = newSize;
updateCursorPosition();
}

//! Map zoom in/zoom out buttons
void CSceneNodeAnimator3PCamera::mapZoomIn(irr::EKEY_CODE newCode)
{
ZoomInKey = newCode;
}

void CSceneNodeAnimator3PCamera::mapZoomOut(irr::EKEY_CODE newCode)
{
ZoomOutKey = newCode;
}

//! Access the camera's current orientation
irr::f32 CSceneNodeAnimator3PCamera::getOrientation()
{
return AngleY;
}


//! animates the scene node
void CSceneNodeAnimator3PCamera::animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs)
{
// make sure you don't go attaching this animator to anything other than a camera
irr::scene::ICameraSceneNode *camera = (irr::scene::ICameraSceneNode*)node;

if(Manager->getActiveCamera() != camera)
{
return;
}

if(Active)
{
// Camera is active, rotate as necessary
irr::core::position2d<irr::f32> pos = Cursor->getRelativePosition();

if(pos.X < 0.5f-BoxSize-EPSILON)
{
AngleY -= (pos.X-(0.5f-BoxSize))*RotationSpeed;//Decrement of this statement gives the correct movement to the mouse.... by smartwhiz
}

if(pos.X > 0.5f+BoxSize+EPSILON)
{
AngleY -= (pos.X-(0.5f+BoxSize))*RotationSpeed;//Decrement of this statement gives the correct movement to the mouse.... by smartwhiz
}

// So we don't get huge rotation numbers
if(AngleY > 360.0f)
{
AngleY += 360.0f;
}

if(AngleY < 0.0f)
{
AngleY -= 360.0f;
}

if(pos.Y < 0.5f-BoxSize-EPSILON)
{
AngleZ -= (pos.Y-(0.5f-BoxSize))*RotationSpeed;
}

if(pos.Y > 0.5f+BoxSize+EPSILON)
{
AngleZ -= (pos.Y-(0.5f+BoxSize))*RotationSpeed;
}

// Ensure Vertical Rotation Angle is bounded correctly
if(AngleZ < MinAngle) AngleZ = MinAngle;
else if(AngleZ > MaxAngle) AngleZ = MaxAngle;

//keep the player in the view angle that of the camera, this is the change made......... by smartwhiz
Player->setRotation(irr::core::vector3df(0,-(AngleY+180),0));

// Zoom only if one or other button is pressed
if((ZoomIn && !ZoomOut) || (!ZoomIn && ZoomOut))
{
int dir = (ZoomIn) ? -1 : 1;
Dist += ZoomSpeed*dir;

// Ensure Distance is bounded correctly
if(Dist < MinDist) Dist = MinDist;
else if(Dist > MaxDist) Dist = MaxDist;
}

updateCursorPosition();
}

// Create translation vector
irr::core::vector3df translation(Dist,0,0);
translation.rotateXYBy(-AngleZ,irr::core::vector3df(0,0,0));
translation.rotateXZBy(AngleY,irr::core::vector3df(0,0,0));

// Assumes the camera is *not* a child of the player node
camera->setTarget(Player->getPosition()+TargetOffset);
camera->setPosition(Player->getPosition()+translation+TargetOffset);
}


class CSceneNodeAnimator3PPlayer :
public irr::scene::ISceneNodeAnimator,
public irr::IEventReceiver
{
public:

//! Constructor
//! camera: The 3PCamera watching this object (should have a 3PC Animator attached to it)
//! cameraAnimator: The animator mentioned above
//! moveSpeed: The speed at which this player moves
CSceneNodeAnimator3PPlayer(
irr::scene::ISceneManager *manager,
irr::scene::ICameraSceneNode *camera,
CSceneNodeAnimator3PCamera *cameraAnimator,
irr::f32 moveSpeed = 0.3f);

virtual ~CSceneNodeAnimator3PPlayer(void);

//! animates the scene node
virtual void animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs);

//! Process an input event
virtual bool OnEvent(irr::SEvent event);

//! Map movement keys
void MapKey(EPLAYER_ACTION action, irr::EKEY_CODE newCode);

//! Retrieve the player's current state
EPLAYER_STATE getState();

private:

irr::f32 MoveSpeed;
irr::u32 PrevTime;

EPLAYER_STATE State;

// action keys
irr::EKEY_CODE Keys[EPA_COUNT];
bool KeyStates[EPA_COUNT];

irr::scene::ICameraSceneNode *Camera;
CSceneNodeAnimator3PCamera *CameraAnimator;

irr::scene::ISceneManager *Manager;
};

CSceneNodeAnimator3PPlayer::CSceneNodeAnimator3PPlayer(
irr::scene::ISceneManager *manager,
irr::scene::ICameraSceneNode *camera,
CSceneNodeAnimator3PCamera *cameraAnimator,
irr::f32 moveSpeed)
: Manager(manager), Camera(camera), CameraAnimator(cameraAnimator), MoveSpeed(moveSpeed)
{
PrevTime = -1;

// Set initial key map
Keys[EPA_MOVE_FORWARD] = irr::KEY_UP;
Keys[EPA_MOVE_BACKWARD] = irr::KEY_DOWN;
Keys[EPA_MOVE_LEFT] = irr::KEY_LEFT;
Keys[EPA_MOVE_RIGHT] = irr::KEY_RIGHT;

// Init states
for(int i=0;i<EPA_COUNT;i++)
{
KeyStates = false;
}

State = EPS_STANDING;
}

CSceneNodeAnimator3PPlayer::~CSceneNodeAnimator3PPlayer(void)
{
}

//! Map movement keys
void CSceneNodeAnimator3PPlayer::MapKey(EPLAYER_ACTION action, irr::EKEY_CODE newCode)
{
Keys[action] = newCode;
}

//! Retrieve the player's current state
EPLAYER_STATE CSceneNodeAnimator3PPlayer::getState()
{
return State;
}

//! Process an input event
bool CSceneNodeAnimator3PPlayer::OnEvent(irr::SEvent event)
{
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
for(int i=0;i<EPA_COUNT;i++)
{
if(event.KeyInput.Key == Keys)
{
KeyStates = event.KeyInput.PressedDown;
return true;
}
}
}

return false;
}

//! animates the scene node
void CSceneNodeAnimator3PPlayer::animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs)
{
// This would have to be modified for an unanimated node
irr::scene::IAnimatedMeshSceneNode *amNode = (irr::scene::IAnimatedMeshSceneNode*)node;

// first loop
if(PrevTime == -1)
{
PrevTime = timeMs;
}

// Timer operations
irr::f32 timeMsFloat = (irr::f32)(timeMs-PrevTime);
PrevTime = timeMs;


// check if moving this round
if(((KeyStates[EPA_MOVE_FORWARD] && !KeyStates[EPA_MOVE_BACKWARD]) || (!KeyStates[EPA_MOVE_FORWARD] && KeyStates[EPA_MOVE_BACKWARD])) ||
((KeyStates[EPA_MOVE_LEFT] && !KeyStates[EPA_MOVE_RIGHT]) || (!KeyStates[EPA_MOVE_LEFT] && KeyStates[EPA_MOVE_RIGHT])))
{
if(State != EPS_RUNNING)
{
State = EPS_RUNNING;
amNode->setMD2Animation(irr::scene::EMAT_RUN);
}
}
else
{
if(State != EPS_STANDING)
{
State = EPS_STANDING;
amNode->setMD2Animation(irr::scene::EMAT_STAND);
}

return; // no movement
}

// Create movement directions based on camera orientation
irr::core::vector3df forward = Camera->getTarget()-Camera->getPosition();
forward.Y = 0;
irr::core::vector3df left = forward.crossProduct(Camera->getUpVector());

forward = forward.normalize();
left = left.normalize();

// Rotation must be set differently for all 8 possible movement directions.
if(KeyStates[EPA_MOVE_FORWARD] && KeyStates[EPA_MOVE_LEFT])
{
irr::core::vector3df movementVector = forward+left;
movementVector = movementVector.normalize();

amNode->setPosition(amNode->getPosition()+movementVector*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,135.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_FORWARD] && KeyStates[EPA_MOVE_RIGHT])
{
irr::core::vector3df movementVector = forward-left;
movementVector = movementVector.normalize();

amNode->setPosition(amNode->getPosition()+movementVector*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,225.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_BACKWARD] && KeyStates[EPA_MOVE_LEFT])
{
irr::core::vector3df movementVector = left-forward;
movementVector = movementVector.normalize();

amNode->setPosition(amNode->getPosition()+movementVector*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,45.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_BACKWARD] && KeyStates[EPA_MOVE_RIGHT])
{
irr::core::vector3df movementVector = (forward*-1)-left;
movementVector = movementVector.normalize();

amNode->setPosition(amNode->getPosition()+movementVector*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,315.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_FORWARD])
{
amNode->setPosition(amNode->getPosition()+forward*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,180.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_BACKWARD])
{
amNode->setPosition(amNode->getPosition()-forward*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_LEFT])
{
amNode->setPosition(amNode->getPosition()+left*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,90.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_RIGHT])
{
amNode->setPosition(amNode->getPosition()-left*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,270.0f-CameraAnimator->getOrientation(),0));
}
}


// Objects used in the Event Receiver
CSceneNodeAnimator3PCamera *camAnim;
CSceneNodeAnimator3PPlayer *sydneyAnim;

// IrrLicht input reciever class..
class MyEventReceiver : public irr::IEventReceiver
{
public:
virtual bool OnEvent(irr::SEvent event)
{
if(event.EventType == irr::EET_LOG_TEXT_EVENT)
{
OutputDebugString(event.LogEvent.Text);
OutputDebugString("\n");

return true;
}

if(camAnim->OnEvent(event)) return true;
if(sydneyAnim->OnEvent(event)) return true;

return false;
}
};

int main()
{
// Start the renderer
MyEventReceiver receiver;
irrBase = irr::createDevice(irr::video::EDT_DIRECTX8,irr::core::dimension2d<irr::s32>(1024,768),32,false,false,&receiver);

// Create reference vars
irr::video::IVideoDriver* driver = irrBase->getVideoDriver();
irr::scene::ISceneManager* smgr = irrBase->getSceneManager();
irr::gui::IGUIEnvironment* guienv = irrBase->getGUIEnvironment();
irr::gui::ICursorControl* cursor = irrBase->getCursorControl();

irr::scene::ICameraSceneNode *camera = smgr->addCameraSceneNode();

// Create a Sydney
irr::scene::IAnimatedMesh *sydneyMesh = smgr->getMesh("sydney.md2");
irr::scene::IAnimatedMeshSceneNode *sydneyNode = smgr->addAnimatedMeshSceneNode(sydneyMesh);
sydneyNode->setMD2Animation(irr::scene::EMAT_STAND);
sydneyNode->setMaterialFlag(irr::video::EMF_LIGHTING,false);
sydneyNode->setMaterialTexture(0,driver->getTexture("sydney.bmp"));


// Create and position map (copied from quake map example)
irrBase->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
irr::scene::IAnimatedMesh* levelMesh = smgr->getMesh("20kdm2.bsp");
irr::scene::ISceneNode* levelNode = smgr->addOctTreeSceneNode(levelMesh->getMesh(0));
levelNode->setPosition(irr::core::vector3df(-1300,-144,-1249));

// Create triangle selector for world (copied from collision example)
irr::scene::ITriangleSelector *selector = smgr->createOctTreeTriangleSelector(levelMesh->getMesh(0), levelNode, 128);
levelNode->setTriangleSelector(selector);
selector->drop();

// Create the camera animator
camAnim = new CSceneNodeAnimator3PCamera(smgr,irrBase->getCursorControl(),sydneyNode,50,180,10,irr::core::vector3df(0,20,0));
camera->addAnimator(camAnim);
camAnim->drop();

// Add collision response to camera (second, because order is important!)
irr::scene::ISceneNodeAnimator *cameraCollision = smgr->createCollisionResponseAnimator(
selector,camera,irr::core::vector3df(3,5,3),
irr::core::vector3df(0,0,0), 0.0f,
irr::core::vector3df(0,5,0));
camera->addAnimator(cameraCollision);
cameraCollision->drop();

// Create the player animator
sydneyAnim = new CSceneNodeAnimator3PPlayer(smgr,camera,camAnim);
sydneyNode->addAnimator(sydneyAnim);
sydneyAnim->drop();

// Add collision response to sydney (copied from collision example)
irr::core::vector3df sydneyDimensions = sydneyMesh->getBoundingBox().MaxEdge - sydneyMesh->getBoundingBox().MinEdge;
irr::scene::ISceneNodeAnimator *sydneyCollision = smgr->createCollisionResponseAnimator(selector,sydneyNode,sydneyDimensions/2.0f);
sydneyNode->addAnimator(sydneyCollision);
sydneyCollision->drop();



// Crosshair code
cursor->setVisible(false);
//irr::video::ITexture *crosshairTexture = driver->getTexture("media/crappycrosshair.jpg");
//driver->makeColorKeyTexture(crosshairTexture,irr::core::position2d<irr::s32>(0,0));

// render loop
while(irrBase->run())
{
//irr - Now we draw it all, if the window is active
if(irrBase->isWindowActive())
{
driver->beginScene(true, true, irr::video::SColor(0,100,100,100));

smgr->drawAll();
guienv->drawAll(); // not that we have GUI stuff

// position the crosshair
//irr::core::position2d<irr::s32> crosshairLocation = cursor->getPosition();
//crosshairLocation.X -= 12;
//crosshairLocation.Y -= 12;

// draw the crosshair
//driver->draw2DImage(crosshairTexture,crosshairLocation,
// irr::core::rect<irr::s32>(0,0,25,25),0,
// irr::video::SColor(255,255,255,255),true);

driver->endScene();
}
}

// Kill renderer
if(irrBase)
{
irrBase->drop();
irrBase = NULL;
}

return 0;
}

pls don't forget to comment

Posted: Mon May 31, 2004 5:37 pm
by smartwhiz
I figured out a way to get a view similar to that in tomb raider.....
just a couple of changes to the code submitted here.
I too had the linker errors as everyone here had so i wrote all the code splitted
into diff: files into one single file.
the changes applied

1->Box size of the crosshair into 0.0f so that the mouse point is only
in one single point on the screen.
2->Crosshair eluminated frm rendering as this is for a RPG view
3->The model didn't rotate as the camera used to ..... it has been corrected as
now the model rotates with respect to the camera

to get the view .... please add sydney.bmp, sydney.md2 and map-20kdm2 in the
project directory
pls give the comment on it so i can try to improve


//3rdPersonCamera.cpp : Defines the entry point for the application.
//
#pragma once

#include "stdafx.h"
// Standard includy stuff
#include <irrlicht.h>

// IrrLicht lib
#pragma comment(lib, "Irrlicht.lib")


#define EPSILON 0.001f

enum EPLAYER_ACTION
{
EPA_MOVE_FORWARD,
EPA_MOVE_BACKWARD,
EPA_MOVE_LEFT,
EPA_MOVE_RIGHT,

EPA_COUNT
};

//! Defines player states
enum EPLAYER_STATE
{
EPS_RUNNING,
EPS_STANDING
};



// Global Irrlicht variables
irr::IrrlichtDevice *irrBase=0;

class CSceneNodeAnimator3PCamera :
public irr::scene::ISceneNodeAnimator,
public irr::IEventReceiver
{

public:

//! Constructor
//! player: The object to follow
//! initDist: The initial distance from the player
//! initAngleY: The initial horizontal rotatation
//! initAngleZ: The initial vertical rotation
//! targetOffset: The offset from the object's center at which the camera looks
//! minDist/maxDist: Distance bounding
//! minAngle/maxAngle: Rotation bounding. -89 ==> looking up at player, 89 ==> looking down
//! boxSize: The size of the box in which mouse movements do not result in camera movements
//! rotationSpeed/zoomSpeed: Speed of movement, in terms of units/millisecond
CSceneNodeAnimator3PCamera(
irr::scene::ISceneManager *manager,irr::gui::ICursorControl *cursor,irr::scene::ISceneNode *player,
irr::f32 initDist = 50.0f,
irr::f32 initAngleY = 180.0f,
irr::f32 initAngleZ = 10.0f,
irr::core::vector3df &targetOffset = irr::core::vector3df(0,0,0),
irr::f32 minDist = 20.0f,
irr::f32 maxDist = 200.0f,
irr::f32 minAngle = -45.0f,
irr::f32 maxAngle = 89.0f,
irr::f32 boxSize = 0.0f,
irr::f32 rotationSpeed = 60.0f,
irr::f32 zoomSpeed = 2.0f);

//! Destructor
virtual ~CSceneNodeAnimator3PCamera(void);

//! animates the scene node
virtual void animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs);

//! Process an input event
virtual bool OnEvent(irr::SEvent event);

//! Get/set active status
bool isActive();
void setActive(bool status);

//! Get/set box size
irr::f32 getBoxSize();
void setBoxSize(irr::f32 newSize);

//! Map zoom in/zoom out buttons
void mapZoomIn(irr::EKEY_CODE newCode);
void mapZoomOut(irr::EKEY_CODE newCode);

//! Access the camera's current orientation
irr::f32 getOrientation();


private:

bool Active;

// current states
irr::f32 Dist;
irr::f32 AngleY;
irr::f32 AngleZ;

// boundaries
irr::core::vector3df TargetOffset;
irr::f32 MinDist;
irr::f32 MaxDist;
irr::f32 MinAngle;
irr::f32 MaxAngle;
irr::f32 BoxSize;

// Motion
irr::f32 RotationSpeed;
irr::f32 ZoomSpeed;

// Zooming keys
irr::EKEY_CODE ZoomInKey;
irr::EKEY_CODE ZoomOutKey;

bool ZoomIn;
bool ZoomOut;

//! Node to follow
irr::scene::ISceneNode *Player;

irr::scene::ISceneManager *Manager;
irr::gui::ICursorControl *Cursor;

//! Puts the cursor back in the box
void updateCursorPosition();
};


CSceneNodeAnimator3PCamera::CSceneNodeAnimator3PCamera(
irr::scene::ISceneManager *manager,irr::gui::ICursorControl *cursor,irr::scene::ISceneNode *player,
irr::f32 initDist,irr::f32 initAngleY,irr::f32 initAngleZ,
irr::core::vector3df &targetOffset,
irr::f32 minDist,irr::f32 maxDist,irr::f32 minAngle,irr::f32 maxAngle,
irr::f32 boxSize,irr::f32 rotationSpeed,irr::f32 zoomSpeed)
: Active(true), Manager(manager), Cursor(cursor), Player(player),
Dist(initDist),AngleY(initAngleY),AngleZ(initAngleZ),
TargetOffset(targetOffset),
MinDist(minDist), MaxDist(maxDist), MinAngle(-maxAngle), MaxAngle(-minAngle),
BoxSize(boxSize), RotationSpeed(rotationSpeed), ZoomSpeed(zoomSpeed)
{
ZoomIn = false;
ZoomOut = false;

ZoomInKey = irr::KEY_ADD;
ZoomOutKey = irr::KEY_SUBTRACT;

Cursor->setPosition(0.5f,0.5f);

// Ensure Distance is bounded correctly
if(Dist < MinDist) Dist = MinDist;
else if(Dist > MaxDist) Dist = MaxDist;

// Bound MinAngle/MaxAngle to avoid problematic areas
if(MinAngle < -89.0f) MinAngle = -89.0f;
if(MinAngle > 89.0f) MinAngle = 89.0f;
if(MaxAngle < -89.0f) MaxAngle = -89.0f;
if(MaxAngle > 89.0f) MaxAngle = 89.0f;
if(minAngle > maxAngle) MaxAngle = MinAngle+1.0f;

// Ensure Vertical Rotation Angle is bounded correctly
if(AngleZ < MinAngle) AngleZ = MinAngle;
else if(AngleZ > MaxAngle) AngleZ = MaxAngle;
}

//! Destructor
CSceneNodeAnimator3PCamera::~CSceneNodeAnimator3PCamera(void)
{
}

//! Puts the cursor back in the box
void CSceneNodeAnimator3PCamera::updateCursorPosition()
{
irr::core::position2d<irr::f32> pos = Cursor->getRelativePosition();

if(pos.X < (0.5f-BoxSize)) pos.X = (0.5f-BoxSize);
if(pos.X > (0.5f+BoxSize)) pos.X = (0.5f+BoxSize);

if(pos.Y < (0.5f-BoxSize)) pos.Y = (0.5f-BoxSize);
if(pos.Y > (0.5f+BoxSize)) pos.Y = (0.5f+BoxSize);

Cursor->setPosition(pos);
}

//! Process an input event
bool CSceneNodeAnimator3PCamera::OnEvent(irr::SEvent event)
{
if(!Active)
{
return false;
}

if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
if(event.KeyInput.Key == ZoomInKey)
{
ZoomIn = event.KeyInput.PressedDown;
return true;
}
else if(event.KeyInput.Key == ZoomOutKey)
{
ZoomOut = event.KeyInput.PressedDown;
return true;
}
}

return false;
}

//! Get/set active status
bool CSceneNodeAnimator3PCamera::isActive()
{
return Active;
}

void CSceneNodeAnimator3PCamera::setActive(bool status)
{
// reset the cursor only if we are switching back to active from inactive
if(!Active && status)
{
updateCursorPosition();
}

Active = status;
}

//! Get/set box size
irr::f32 CSceneNodeAnimator3PCamera::getBoxSize()
{
return BoxSize;
}

void CSceneNodeAnimator3PCamera::setBoxSize(irr::f32 newSize)
{
BoxSize = newSize;
updateCursorPosition();
}

//! Map zoom in/zoom out buttons
void CSceneNodeAnimator3PCamera::mapZoomIn(irr::EKEY_CODE newCode)
{
ZoomInKey = newCode;
}

void CSceneNodeAnimator3PCamera::mapZoomOut(irr::EKEY_CODE newCode)
{
ZoomOutKey = newCode;
}

//! Access the camera's current orientation
irr::f32 CSceneNodeAnimator3PCamera::getOrientation()
{
return AngleY;
}


//! animates the scene node
void CSceneNodeAnimator3PCamera::animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs)
{
// make sure you don't go attaching this animator to anything other than a camera
irr::scene::ICameraSceneNode *camera = (irr::scene::ICameraSceneNode*)node;

if(Manager->getActiveCamera() != camera)
{
return;
}

if(Active)
{
// Camera is active, rotate as necessary
irr::core::position2d<irr::f32> pos = Cursor->getRelativePosition();

if(pos.X < 0.5f-BoxSize-EPSILON)
{
AngleY -= (pos.X-(0.5f-BoxSize))*RotationSpeed;//Decrement of this statement gives the correct movement to the mouse.... by smartwhiz
}

if(pos.X > 0.5f+BoxSize+EPSILON)
{
AngleY -= (pos.X-(0.5f+BoxSize))*RotationSpeed;//Decrement of this statement gives the correct movement to the mouse.... by smartwhiz
}

// So we don't get huge rotation numbers
if(AngleY > 360.0f)
{
AngleY += 360.0f;
}

if(AngleY < 0.0f)
{
AngleY -= 360.0f;
}

if(pos.Y < 0.5f-BoxSize-EPSILON)
{
AngleZ -= (pos.Y-(0.5f-BoxSize))*RotationSpeed;
}

if(pos.Y > 0.5f+BoxSize+EPSILON)
{
AngleZ -= (pos.Y-(0.5f+BoxSize))*RotationSpeed;
}

// Ensure Vertical Rotation Angle is bounded correctly
if(AngleZ < MinAngle) AngleZ = MinAngle;
else if(AngleZ > MaxAngle) AngleZ = MaxAngle;

//keep the player in the view angle that of the camera, this is the change made......... by smartwhiz
Player->setRotation(irr::core::vector3df(0,-(AngleY+180),0));

// Zoom only if one or other button is pressed
if((ZoomIn && !ZoomOut) || (!ZoomIn && ZoomOut))
{
int dir = (ZoomIn) ? -1 : 1;
Dist += ZoomSpeed*dir;

// Ensure Distance is bounded correctly
if(Dist < MinDist) Dist = MinDist;
else if(Dist > MaxDist) Dist = MaxDist;
}

updateCursorPosition();
}

// Create translation vector
irr::core::vector3df translation(Dist,0,0);
translation.rotateXYBy(-AngleZ,irr::core::vector3df(0,0,0));
translation.rotateXZBy(AngleY,irr::core::vector3df(0,0,0));

// Assumes the camera is *not* a child of the player node
camera->setTarget(Player->getPosition()+TargetOffset);
camera->setPosition(Player->getPosition()+translation+TargetOffset);
}


class CSceneNodeAnimator3PPlayer :
public irr::scene::ISceneNodeAnimator,
public irr::IEventReceiver
{
public:

//! Constructor
//! camera: The 3PCamera watching this object (should have a 3PC Animator attached to it)
//! cameraAnimator: The animator mentioned above
//! moveSpeed: The speed at which this player moves
CSceneNodeAnimator3PPlayer(
irr::scene::ISceneManager *manager,
irr::scene::ICameraSceneNode *camera,
CSceneNodeAnimator3PCamera *cameraAnimator,
irr::f32 moveSpeed = 0.3f);

virtual ~CSceneNodeAnimator3PPlayer(void);

//! animates the scene node
virtual void animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs);

//! Process an input event
virtual bool OnEvent(irr::SEvent event);

//! Map movement keys
void MapKey(EPLAYER_ACTION action, irr::EKEY_CODE newCode);

//! Retrieve the player's current state
EPLAYER_STATE getState();

private:

irr::f32 MoveSpeed;
irr::u32 PrevTime;

EPLAYER_STATE State;

// action keys
irr::EKEY_CODE Keys[EPA_COUNT];
bool KeyStates[EPA_COUNT];

irr::scene::ICameraSceneNode *Camera;
CSceneNodeAnimator3PCamera *CameraAnimator;

irr::scene::ISceneManager *Manager;
};

CSceneNodeAnimator3PPlayer::CSceneNodeAnimator3PPlayer(
irr::scene::ISceneManager *manager,
irr::scene::ICameraSceneNode *camera,
CSceneNodeAnimator3PCamera *cameraAnimator,
irr::f32 moveSpeed)
: Manager(manager), Camera(camera), CameraAnimator(cameraAnimator), MoveSpeed(moveSpeed)
{
PrevTime = -1;

// Set initial key map
Keys[EPA_MOVE_FORWARD] = irr::KEY_UP;
Keys[EPA_MOVE_BACKWARD] = irr::KEY_DOWN;
Keys[EPA_MOVE_LEFT] = irr::KEY_LEFT;
Keys[EPA_MOVE_RIGHT] = irr::KEY_RIGHT;

// Init states
for(int i=0;i<EPA_COUNT;i++)
{
KeyStates = false;
}

State = EPS_STANDING;
}

CSceneNodeAnimator3PPlayer::~CSceneNodeAnimator3PPlayer(void)
{
}

//! Map movement keys
void CSceneNodeAnimator3PPlayer::MapKey(EPLAYER_ACTION action, irr::EKEY_CODE newCode)
{
Keys[action] = newCode;
}

//! Retrieve the player's current state
EPLAYER_STATE CSceneNodeAnimator3PPlayer::getState()
{
return State;
}

//! Process an input event
bool CSceneNodeAnimator3PPlayer::OnEvent(irr::SEvent event)
{
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
for(int i=0;i<EPA_COUNT;i++)
{
if(event.KeyInput.Key == Keys)
{
KeyStates = event.KeyInput.PressedDown;
return true;
}
}
}

return false;
}

//! animates the scene node
void CSceneNodeAnimator3PPlayer::animateNode(irr::scene::ISceneNode *node, irr::u32 timeMs)
{
// This would have to be modified for an unanimated node
irr::scene::IAnimatedMeshSceneNode *amNode = (irr::scene::IAnimatedMeshSceneNode*)node;

// first loop
if(PrevTime == -1)
{
PrevTime = timeMs;
}

// Timer operations
irr::f32 timeMsFloat = (irr::f32)(timeMs-PrevTime);
PrevTime = timeMs;


// check if moving this round
if(((KeyStates[EPA_MOVE_FORWARD] && !KeyStates[EPA_MOVE_BACKWARD]) || (!KeyStates[EPA_MOVE_FORWARD] && KeyStates[EPA_MOVE_BACKWARD])) ||
((KeyStates[EPA_MOVE_LEFT] && !KeyStates[EPA_MOVE_RIGHT]) || (!KeyStates[EPA_MOVE_LEFT] && KeyStates[EPA_MOVE_RIGHT])))
{
if(State != EPS_RUNNING)
{
State = EPS_RUNNING;
amNode->setMD2Animation(irr::scene::EMAT_RUN);
}
}
else
{
if(State != EPS_STANDING)
{
State = EPS_STANDING;
amNode->setMD2Animation(irr::scene::EMAT_STAND);
}

return; // no movement
}

// Create movement directions based on camera orientation
irr::core::vector3df forward = Camera->getTarget()-Camera->getPosition();
forward.Y = 0;
irr::core::vector3df left = forward.crossProduct(Camera->getUpVector());

forward = forward.normalize();
left = left.normalize();

// Rotation must be set differently for all 8 possible movement directions.
if(KeyStates[EPA_MOVE_FORWARD] && KeyStates[EPA_MOVE_LEFT])
{
irr::core::vector3df movementVector = forward+left;
movementVector = movementVector.normalize();

amNode->setPosition(amNode->getPosition()+movementVector*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,135.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_FORWARD] && KeyStates[EPA_MOVE_RIGHT])
{
irr::core::vector3df movementVector = forward-left;
movementVector = movementVector.normalize();

amNode->setPosition(amNode->getPosition()+movementVector*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,225.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_BACKWARD] && KeyStates[EPA_MOVE_LEFT])
{
irr::core::vector3df movementVector = left-forward;
movementVector = movementVector.normalize();

amNode->setPosition(amNode->getPosition()+movementVector*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,45.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_BACKWARD] && KeyStates[EPA_MOVE_RIGHT])
{
irr::core::vector3df movementVector = (forward*-1)-left;
movementVector = movementVector.normalize();

amNode->setPosition(amNode->getPosition()+movementVector*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,315.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_FORWARD])
{
amNode->setPosition(amNode->getPosition()+forward*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,180.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_BACKWARD])
{
amNode->setPosition(amNode->getPosition()-forward*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_LEFT])
{
amNode->setPosition(amNode->getPosition()+left*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,90.0f-CameraAnimator->getOrientation(),0));
}
else if(KeyStates[EPA_MOVE_RIGHT])
{
amNode->setPosition(amNode->getPosition()-left*MoveSpeed*timeMsFloat);
amNode->setRotation(irr::core::vector3df(0,270.0f-CameraAnimator->getOrientation(),0));
}
}


// Objects used in the Event Receiver
CSceneNodeAnimator3PCamera *camAnim;
CSceneNodeAnimator3PPlayer *sydneyAnim;

// IrrLicht input reciever class..
class MyEventReceiver : public irr::IEventReceiver
{
public:
virtual bool OnEvent(irr::SEvent event)
{
if(event.EventType == irr::EET_LOG_TEXT_EVENT)
{
OutputDebugString(event.LogEvent.Text);
OutputDebugString("\n");

return true;
}

if(camAnim->OnEvent(event)) return true;
if(sydneyAnim->OnEvent(event)) return true;

return false;
}
};

int main()
{
// Start the renderer
MyEventReceiver receiver;
irrBase = irr::createDevice(irr::video::EDT_DIRECTX8,irr::core::dimension2d<irr::s32>(1024,768),32,false,false,&receiver);

// Create reference vars
irr::video::IVideoDriver* driver = irrBase->getVideoDriver();
irr::scene::ISceneManager* smgr = irrBase->getSceneManager();
irr::gui::IGUIEnvironment* guienv = irrBase->getGUIEnvironment();
irr::gui::ICursorControl* cursor = irrBase->getCursorControl();

irr::scene::ICameraSceneNode *camera = smgr->addCameraSceneNode();

// Create a Sydney
irr::scene::IAnimatedMesh *sydneyMesh = smgr->getMesh("sydney.md2");
irr::scene::IAnimatedMeshSceneNode *sydneyNode = smgr->addAnimatedMeshSceneNode(sydneyMesh);
sydneyNode->setMD2Animation(irr::scene::EMAT_STAND);
sydneyNode->setMaterialFlag(irr::video::EMF_LIGHTING,false);
sydneyNode->setMaterialTexture(0,driver->getTexture("sydney.bmp"));


// Create and position map (copied from quake map example)
irrBase->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
irr::scene::IAnimatedMesh* levelMesh = smgr->getMesh("20kdm2.bsp");
irr::scene::ISceneNode* levelNode = smgr->addOctTreeSceneNode(levelMesh->getMesh(0));
levelNode->setPosition(irr::core::vector3df(-1300,-144,-1249));

// Create triangle selector for world (copied from collision example)
irr::scene::ITriangleSelector *selector = smgr->createOctTreeTriangleSelector(levelMesh->getMesh(0), levelNode, 128);
levelNode->setTriangleSelector(selector);
selector->drop();

// Create the camera animator
camAnim = new CSceneNodeAnimator3PCamera(smgr,irrBase->getCursorControl(),sydneyNode,50,180,10,irr::core::vector3df(0,20,0));
camera->addAnimator(camAnim);
camAnim->drop();

// Add collision response to camera (second, because order is important!)
irr::scene::ISceneNodeAnimator *cameraCollision = smgr->createCollisionResponseAnimator(
selector,camera,irr::core::vector3df(3,5,3),
irr::core::vector3df(0,0,0), 0.0f,
irr::core::vector3df(0,5,0));
camera->addAnimator(cameraCollision);
cameraCollision->drop();

// Create the player animator
sydneyAnim = new CSceneNodeAnimator3PPlayer(smgr,camera,camAnim);
sydneyNode->addAnimator(sydneyAnim);
sydneyAnim->drop();

// Add collision response to sydney (copied from collision example)
irr::core::vector3df sydneyDimensions = sydneyMesh->getBoundingBox().MaxEdge - sydneyMesh->getBoundingBox().MinEdge;
irr::scene::ISceneNodeAnimator *sydneyCollision = smgr->createCollisionResponseAnimator(selector,sydneyNode,sydneyDimensions/2.0f);
sydneyNode->addAnimator(sydneyCollision);
sydneyCollision->drop();



// Crosshair code
cursor->setVisible(false);
//irr::video::ITexture *crosshairTexture = driver->getTexture("media/crappycrosshair.jpg");
//driver->makeColorKeyTexture(crosshairTexture,irr::core::position2d<irr::s32>(0,0));

// render loop
while(irrBase->run())
{
//irr - Now we draw it all, if the window is active
if(irrBase->isWindowActive())
{
driver->beginScene(true, true, irr::video::SColor(0,100,100,100));

smgr->drawAll();
guienv->drawAll(); // not that we have GUI stuff

// position the crosshair
//irr::core::position2d<irr::s32> crosshairLocation = cursor->getPosition();
//crosshairLocation.X -= 12;
//crosshairLocation.Y -= 12;

// draw the crosshair
//driver->draw2DImage(crosshairTexture,crosshairLocation,
// irr::core::rect<irr::s32>(0,0,25,25),0,
// irr::video::SColor(255,255,255,255),true);

driver->endScene();
}
}

// Kill renderer
if(irrBase)
{
irrBase->drop();
irrBase = NULL;
}

return 0;
}

pls don't forget to comment

Posted: Fri Jun 04, 2004 5:30 pm
by etcaptor
I work on 3rd person camera class.
Well, I use AssiDragon's technique.
Main idea is that this class will consist all functions itself, and user will only must to create instance with player and other values as parameters.
I began to implement and MD2 animations, which class will assign to player automaticaly.
Another idea is to catch mouse wheel event and to implement in class. But for now I can't to make reversive wheel.
Maybe I so tired and so I lost whole day .. :roll: with these things.

Posted: Mon Jun 07, 2004 4:37 pm
by BRPAZ
I'm having problems compiling any of the sources here, or running any of the binaries posted. I saw something about there being compilation problems with this example, so can anyone tell me how this may be fixed?

Thanks

Posted: Mon Jun 07, 2004 9:50 pm
by BRPAZ
With luvcraft's, the command prompt gives me:

"
Could not load mesh, because file could not be opened.: 20kdm2.bsp
Press any key to continue
"

And crashes (on WinXP).

And AssiDragon's gives me a bunch of errors...

Any ideas here guys?

Thanks

Posted: Tue Jun 08, 2004 7:43 pm
by etcaptor
That is not related with luvcraft's camera - i think, that you cold not to set appropriate directory for bsp level loading- change directory.

Posted: Wed Jun 09, 2004 5:53 pm
by BRPAZ
You're right! It compiles now, but it still doesn't execute (either as stand-alone or within the compiler):
Command prompt wrote: Irrlicht Engine version 0.6
Microsoft Windows XP Personal Service Pack 1 (Build 2600)
Loaded texture: #DefaultFont
Could not load mesh, because file could not be opened.: 20kdm2.bsp
Press any key to continue
I don't have that 20kdm2.bsp file...

Posted: Wed Jun 09, 2004 11:58 pm
by etcaptor
20kdm2.bsp is comming with irrlicht. Check again your zip files :wink:

Posted: Thu Jun 10, 2004 6:18 pm
by BRPAz
Well..the only file I have close to that is map-20kdm2.PK3 (not .bsp), and it's in the media\ directory...

Is there a file called 20kdm2.bsp somewhere?

:?

Posted: Thu Jun 10, 2004 6:27 pm
by etcaptor
bsp file is in map-20kdm2.pk3 file. pk3 file is one arhive. You can open it even with winrar.
Aftet then you must use some like:
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
mesh = smgr->getMesh("../../media/maps/20kdm2.bsp");

or ../media/map-20kdm2.pk3"
or just descriebe your appropriate directory file.

Posted: Fri Jun 11, 2004 7:54 pm
by BRPAZ
OK, I got it to run (as opposed to it crashing ;)). I put the file map map-20kdm2.pk3 in the dir. However, I'm getting errors that:

Code: Select all

Could not find texture in Q3 .bsp: textures/common/caulk
Loaded texture: e7walldesign01b.jpg
Loaded texture: e7steptop2.jpg
Could not find texture in Q3 .bsp: noshader
Loaded texture: e7dimfloor.jpg
Loaded texture: e7brickfloor01.jpg
Loaded texture: e7bmtrim.jpg
Loaded texture: e7sbrickfloor.jpg
Loaded texture: e7brnmetal.jpg
Could not find texture in Q3 .bsp: textures/common/clip
Loaded texture: e7beam02_red.jpg
Loaded texture: e7swindow.jpg
Loaded texture: e7bigwall.jpg
Loaded texture: e7panelwood.jpg
Loaded texture: e7beam01.jpg
Loaded texture: xstepborder5.jpg
Could not find texture in Q3 .bsp: textures/liquids/lavahell
Loaded texture: e7steptop.jpg
Could not find texture in Q3 .bsp: textures/gothic_trim/metalblackwave01
Could not find texture in Q3 .bsp: textures/stone/pjrock1
Could not find texture in Q3 .bsp: textures/skies/tim_hell
Could not find texture in Q3 .bsp: textures/common/hint
Could not find texture in Q3 .bsp: models/mapobjects/timlamp/timlamp
Could not find texture in Q3 .bsp: textures/sfx/flame1side
Could not find texture in Q3 .bsp: textures/sfx/flame2
Could not find texture in Q3 .bsp: models/mapobjects/gratelamp/gratetorch2
Could not find texture in Q3 .bsp: models/mapobjects/gratelamp/gratetorch2b
Loaded mesh: 20kdm2.bsp
Needed 54ms to create OctTree SceneNode.(318 nodes, 7753 polys)
Needed 181ms to create OctTreeTriangleSelector.(145 nodes, 7753 polys)
Loaded mesh: sydney.md2
Loaded texture: sydney.bmp
in the case of e.g. Could not find texture in Q3 .bsp: textures/sfx/flame2, it is true, as there is no texture in the .pk3 file like that. Is your .pk3 file also like this? Because even though it runs, the level textures don't load up, and so I can't tell what's going on ^-^.

Thanks for your help

Posted: Sun Jun 20, 2004 2:45 pm
by RizzleR
anybody tried integrating this cam with techdemo?
having some probs as how te change the event system of the techdemo so it will be 3rd person cam compatible

Posted: Sun Jun 20, 2004 3:48 pm
by RizzleR
oke i just used the seperate files and got them to compile in a clean project
then i imported the source files and tried to integrate 3rdPersonCamera.cpp stuff in the Cdemo.cpp from the techdemo

i assumed i only had to add code to the case 3 as thats the interactive part

so far so good after fixing some compiling errors it now compiles
but after gui when i select start i get a black screen and nothing.

here's my cdemo.ccp: http://www.xs4all.nl/~rizzler/Cdemo.cpp ... person.zip
note that i only modified most of the cdemo code and not 3rd person cam code
any help would be appreciated
thnx in advance

Posted: Wed Jun 30, 2004 6:19 am
by Endar
Hey, don't know if people have done this yet (apart from the guy who pasted about 5 pages of code), but with the 3P camera, I've gotten rid of the box idea entirely and confined the cursor to the middle of the screen.

Let me know if you want the files. :D