I am not entirely sure the DarkGDK game engine supports bloom. As far as creating additional cameras you can use the
following command to create a camera.
void dbMakeCamera ( int iCamera )
There is a lot more documentation that was included with the installation of DarkGDK (in DarkGDKDocumentation to be specific) that can tell you a whole lot more about pretty much every single command in DarkGDK, it has been extremely helpful for me.
As far as giving a camera collision detection, that is much harder. The method I am working on for camera collisions with the environment is to actually create a a small sphere that follows my main character around. Using the WASD keys I control the movement of my character, me "camera collision sphere" trails behind my character and I position my camera where ever my collision sphere is. The idea is that because you can set up collision between the game world and the collision sphere it should be possible to prevent the camera from clipping through the world.
I have been working on getting this right for two days now, my engine for moving my character around has gone through many revisions. My advice to you would honestly be to try and keep your game first person unless you have to have a zoom out function. It is just so much easier not having to deal with having a third person camera.
EDIT: To give you an example of my code:
It requires Sparkys Collisions. Object number 1 is your game world, object 2 is your avatar, object 3 is the camera collision sphere. So if you want to run this code you will have to set it up with that in mind, you will also have to get a hold of Sparkys Collisions 2.05b (search the forums for it).
CharacterControl.h
#pragma once
// Character control
extern float moveSpeed; // Initiated the variable
extern float walkSpeed; // Default walk speed
extern float runSpeed; // Default run speed
extern float hasteSpeed; // Increases movement speed
extern float snareSpeed; // Decreases movement speed
void mouseWASD(void);
CharacterControl.cpp (note, this is maybe half done)
// You should only change the values of variables that are marked unless you know what you are doing.
// Camera control variables
float cameraXRotate1 = 0.0f; // Rotating camera only
float cameraXRotate2 = 0.0f; // Rotating camera only
float mouseY1; // Used to apply camera rotation
float mouseX1; // Used to apply camera rotation
float mouseY2; // Used to apply camera rotation
float mouseX2; // Used to apply camera rotation
float cameraScroll = -25; // Default zoom value, more negative means further away from the player object *** Safe to modify ***
bool rClicked = false; // For correctly controlling mouse look
bool lClicked = false; // For correctly controlling mouse look
bool bClicked = false; // For correctly controlling mouse look
// Character control
float moveSpeed; // Total movement speed
float walkSpeed = 1.0f; // Default walk speed *** Safe to modify ***
float runSpeed = 2.0f; // Default run speed *** Safe to modify ***
float hasteSpeed = 0.0f; // Increases movement speed *** Safe to modify ***
float snareSpeed = 0.0f; // Decreases movement speed *** Safe to modify ***
float gravity = -0.0981f; // How fast you accelerate due to gravity *** Safe to modify ***
float slope = 0.65f; // Increasing this value means decreases how steep an incline you can traverse *** Safe to modify ***
int ground = 1; // Used internally to determine when the player is airborne
int jumpTimer = 0; // Default of zero
int jumpDelay = 8; // The delay between when you land and when you can jump again. *** Safe to modify ***
float playerHeight = 20.0f; // How tall the player is, really just increases the height of the camera *** Safe to modify ***
float radius = 0.2f; // The collision radius of the default player sphere *** Safe to modify ***
//player movement vectors
float moveVectorX = 0; // For calculating player position
float moveVectorY = 0; // For calculating player position
float moveVectorZ = 0; // For calculating player position
float lastVectorX = 0; // For calculating player position
float lastVectorZ = 0; // For calculating player position
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Control the character with WASD and mouse look
void mouseWASD() {
// Calculates move speed, press the SHIFT key to run
if (dbShiftKey() == 1 && ground == 1) { moveSpeed = runSpeed + hasteSpeed - snareSpeed; } else if (ground == 1) { moveSpeed = walkSpeed + hasteSpeed - snareSpeed; }
if (moveSpeed < 0) { moveSpeed = 0; }
// Enter mouse control when right mouse button is pressed
if (dbMouseClick() == 2 || dbMouseClick() == 3) {
if (rClicked == false) { mouseX2 = dbMouseX(); mouseY2 = dbMouseY(); rClicked = true; }
/*
fCameraAngleX = dbWrapValue(fCameraAngleX + 180.0f) + (mouseY1 * 0.4f);
if (fCameraAngleX < 70.0f) { fCameraAngleX = 70.0f; }
if (fCameraAngleX > 250.0f) { fCameraAngleX = 240.0f; }
fCameraAngleX = dbWrapValue(fCameraAngleX - 180.0f);
*/
dbHideMouse();
//cameraXRotate1 = dbObjectAngleX(2) + (dbMouseY() - mouseY2);
//cameraXRotate2 += cameraXRotate1;
//dbXRotateObject(3, cameraXRotate2);
dbYRotateObject(2, dbObjectAngleY(2) + (dbMouseX() - mouseX2));
//dbYRotateObject(3, dbObjectAngleY(3) + (dbMouseX() - mouseX2));
dbPositionMouse(mouseX2, mouseY2);
} else { dbShowMouse(); rClicked = false; }
float oldX = dbObjectPositionX(2);
float oldY = dbObjectPositionY(2);
float oldZ = dbObjectPositionZ(2);
// Applies gravity
float angleY = dbObjectAngleY(2);
moveVectorX = moveVectorZ = 0;
// Normal gravity when jumping or falling, otherwise keeps the player on the ground
if (moveVectorY == 0) { moveVectorY += 10 * gravity; } else { moveVectorY += gravity; }
// Forward, reverse, straffing movement
// W = 17, A = 30, S = 31, D = 32
if (ground == 1) {
lastVectorX = lastVectorZ = 0;
if (dbKeyState(30) == 1) { lastVectorX = moveVectorX = moveVectorX + dbCos(angleY) * moveSpeed; lastVectorZ = moveVectorZ = moveVectorZ - dbSin(angleY) * moveSpeed; }
if (dbKeyState(32) == 1) { lastVectorX = moveVectorX = moveVectorX - dbCos(angleY) * moveSpeed; lastVectorZ = moveVectorZ = moveVectorZ + dbSin(angleY) * moveSpeed; }
if (dbKeyState(17) == 1) { lastVectorX = moveVectorX = moveVectorX - dbSin(angleY) * moveSpeed; lastVectorZ = moveVectorZ = moveVectorZ - dbCos(angleY) * moveSpeed; }
if (dbKeyState(31) == 1) { lastVectorX = moveVectorX = moveVectorX + dbSin(angleY) * moveSpeed; lastVectorZ = moveVectorZ = moveVectorZ + dbCos(angleY) * moveSpeed; }
}
// Can't change movement path once airborne
if (ground == 0) { moveVectorX += lastVectorX; moveVectorZ += lastVectorZ; }
// Only jump if on the ground
if (ground == 1) {
if (dbSpaceKey() == 1 && jumpTimer == 0) { moveVectorY = moveVectorY + 3.0f; jumpTimer = jumpDelay; }
}
// Player's final position without collision
float playerPositionX = oldX + moveVectorX;
float playerPositionY = oldY + moveVectorY;
float playerPositionZ = oldZ + moveVectorZ;
int collide = SC_SphereCastGroup(1, oldX, oldY, oldZ, oldX, oldY + moveVectorY, oldZ, radius, 0);
// Start if
if (collide > 0) {
float newY = SC_GetCollisionNormalY();
if (dbAbs(newY) > slope) {
//FLAT, stick
oldY = SC_GetStaticCollisionY();
//STEEP, slide
} else {
playerPositionX -= oldX; playerPositionZ -= oldZ; oldX = SC_GetCollisionSlideX();
oldY = SC_GetCollisionSlideY(); oldZ = SC_GetCollisionSlideZ();
playerPositionX += oldX; playerPositionZ += oldZ;
}
if ( newY > slope ) {
// Only on ground if standing on flat ground
ground = 1;
moveVectorY = 0;
//if player has hit a flat ceiling then stop vy# movement
} else { ground = 0; if ( newY < -slope ) { moveVectorY = gravity; } }
//nothing below player, not on ground, add vertical speed to player
} else { oldY += moveVectorY; ground = 0; }
if (ground == 1 && jumpTimer > 0 ) { jumpTimer--; }
//handle horizontal movement as sliding
//player only collides with group 1 (level) objs and moves freely through others
collide = SC_SphereSlideGroup(1, oldX, oldY, oldZ, playerPositionX, oldY, playerPositionZ, radius, 0);
if (collide > 0) {
//if hit, reposition player, halt movement vector
playerPositionX = SC_GetCollisionSlideX();
oldY = SC_GetCollisionSlideY();
playerPositionZ = SC_GetCollisionSlideZ();
moveVectorX = 0;
moveVectorZ = 0;
}
// Position the player and check to make sure he is above the ground
if (oldY < dbGetTerrainGroundHeight(1, playerPositionX, playerPositionZ) - 10) { oldY = dbGetTerrainGroundHeight(1, playerPositionX, playerPositionZ) + 15; }
// Updates the players position
dbPositionObject(2, playerPositionX, oldY, playerPositionZ);
SC_UpdateObject(2);
// Position the player camera sphere
dbPositionObject(3, dbObjectPositionX(2) - dbSin(dbObjectAngleY(2)) * cameraScroll, dbObjectPositionY(2) + playerHeight, dbObjectPositionZ(2) - dbCos(dbObjectAngleY(2)) * cameraScroll);
SC_UpdateObject(3);
// Position the camera
dbPositionCamera(dbObjectPositionX(3), dbObjectPositionY(3), dbObjectPositionZ(3));
dbPointCamera(playerPositionX, oldY + playerHeight, playerPositionZ);
// Controls camera zooming
//cameraScroll += dbMouseMoveZ() / 15.0f;
//if (cameraScroll >= 0) { cameraScroll = 0; }
//if (cameraScroll <= -200) { cameraScroll = -200; }
//dbMoveCamera(cameraScroll);
//dbMoveCameraRight(0, 3.5f);
}
------------------------------------
Currently developing an "over-the-shoulder", action based, RPG with combat based on rag-doll physics.