Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / camera as a mirror

Author
Message
camera as a mirror
14
Years of Service
User Offline
Joined: 7th Feb 2010
Location:
Posted: 8th Feb 2010 02:24
I'm making a game or should I say tutorial..I want to know how to use a camera as a mirror in 3d.. REAR MIRROR in particular, those ones in cars.. I want to see the view behind me.. plss help me.. this is my first time posting here.. thx

pls help me on my programmng.. i want to use a camera as a mirror.. REAR MIRROR on a car.. I am programming a a game with a car.. this is my first post so plss i need your help..ths
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 8th Feb 2010 09:22
dunno, a shader maybe? well im not good at using shaders anyway



Aldur
16
Years of Service
User Offline
Joined: 8th Oct 2007
Location: Melbourne, Australia
Posted: 8th Feb 2010 10:36
Set a 2nd camera to an image, texture a plane with it, position the camera at the mirrors location and then rotate the camera so that it is pointing in the correct direction.

camera as a mirror
14
Years of Service
User Offline
Joined: 7th Feb 2010
Location:
Posted: 8th Feb 2010 14:45
Im new here so thats why my signature is like dat

always be humble..
camera as a mirror
14
Years of Service
User Offline
Joined: 7th Feb 2010
Location:
Posted: 8th Feb 2010 14:47
can you give me some codes on how to do it?? I set a 2nd camera on an object, I rotate it at the back of the car and I did it, but the problem is it's not accurate, it's running sideways..and my terrain is not working properly..

always be humble..
Aldur
16
Years of Service
User Offline
Joined: 8th Oct 2007
Location: Melbourne, Australia
Posted: 9th Feb 2010 08:00
Some code would help us solve your issues.

Please post back with some/all of your code and we will see what we can do to help you.



Your signature has been erased by a mod - Please reduce it to 600x120 maximum size
camera as a mirror
14
Years of Service
User Offline
Joined: 7th Feb 2010
Location:
Posted: 10th Feb 2010 22:13

// Dark GDK - The Game Creators - www.thegamecreators.com

// include the Dark GDK header
#include "DarkSDK.h"



void DarkGDK ( void )
{
// entry point for the application

dbHideMouse ();

// switch on sync rate and set to a maximum of 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );

dbAutoCamOff ( );

// we are going to use a skybox in this demo and it will
// be scaled up to quite a large size, this will initially
// result in it being outside of the cameras default range
// therefore it will not be drawn, to adjust this we simply
// increase the cameras range
dbSetCameraRange ( 1.0f, 9000000.0f );

// two textures are going to be used for the terrain, the first
// will be the diffuse part and the second will be used to
// create extra detail on the terrain
dbLoadImage ( "texture.jpg", 11 );
dbLoadImage ( "detail.jpg", 12 );
//dbLoadSound ( "Terrain\\atmos.wav", 700 );

// the first step in creating a terrain is to call the
// function dbSetupTerrain, this will perform some internal
// work that allows us to get started
dbSetupTerrain ( );

// now we can get started on making the terrain object
dbMakeObjectTerrain ( 1 );

// here we pass in a heightmap that will be used to create the terrain
dbSetTerrainHeightMap ( 1, "map.bmp" );

// now we set the scale, this will have the effect of making
// the terrain large on the X and Z axis but quite small on the Y
dbSetTerrainScale ( 1, 10000.0f, 0.0f, 10000.0f );

// adjust the lighting for the terrain, this function takes the ID
// number, then a direction for the light, then 3 colours for the light
// and finally the scale, by using this function we can adjust the
// overall colour of the terrain
dbSetTerrainLight ( 1, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 0.78f, 0.5f );

// in this call we're telling the terrain that its diffuse texture
// will come from image 1 and its detail texture will come from
// image 2
dbSetTerrainTexture ( 1, 11, 12 );

// once we have set all properties of the terrain we can build it,
// at this point it gets created and added into your world
dbBuildTerrain ( 1 );

// with the terrain in place we can now load a skybox
dbLoadObject ( "skybox2.x", 2 );

// we dont need it to respond to light so switch light off
dbSetObjectLight ( 2, 0 );

// make the skybox much larger
dbScaleObject ( 2, 300000.0f, 300000.0f, 300000.0f );
dbPositionObject ( 2, 15000.0f, 0.0f, 15000.0f );


// position the camera
dbPositionCamera (0, 8000, 20, 8000);
dbAutomaticCameraCollision( 0, 5.0f, 0);

dbPositionCamera (1, 8000, 20, 8000);

// adjust texture properties of sky box
dbSetObjectTexture ( 2, 3, 1 );

dbSetObjectCollisionOff ( 2 );
//dbSetObjectCollisionOff ( 1 );

dbLoadObject ( "taxi.x", 100 );
dbScaleObject ( 100, 3000, 3000, 3000 );
dbSetObjectLight ( 100, false );
dbPositionObject ( 100, 3000.0f, 0.0f, 7000.0f );
dbRotateObject ( 100, 0, 45, 0 );
//dbSetObjectCollisionToPolygons ( 100 );

dbLoadObject ( "taxi.x", 101 );
dbScaleObject ( 101, 2300, 1900, 1800 );
dbSetObjectLight ( 101, false );
dbPositionObject(101, 0, -26.0f, -15.0f);
dbLockObjectOn (101);
dbRotateObject ( 101, 0, 180, 0 );
//dbFixObjectPivot(101);
//dbSetBumpMappingOn(101,2);

dbLoadObject ( "x.x", 201 );
dbScaleObject ( 201, 1000000, 10000, 10000 );
dbSetObjectLight ( 201, false );
dbPositionObject ( 201, 8000.0f, 0.0f, 1000.0f );
dbRotateObject ( 201, 0, 720, 0 );
dbHideObject ( 201 );

dbLoadObject ( "x10.x", 202 );
dbScaleObject ( 202, 10000, 10000, 1000000 );
dbSetObjectLight ( 202, false );
dbPositionObject ( 202, 700.0f, 0.0f, 8000.0f );
dbRotateObject ( 202, 0, 720, 0 );
dbHideObject ( 202 );

dbLoadObject ( "x11.x", 203 );
dbScaleObject ( 203, 1000000, 10000, 10000 );
dbSetObjectLight ( 203, false );
dbPositionObject ( 203, 8000.0f, 0.0f, 24600.0f );
dbRotateObject ( 203, 0, 720, 0 );
dbHideObject ( 203 );

dbLoadObject ( "x12.x", 204 );
dbScaleObject ( 204, 10000, 10000, 1000000 );
dbSetObjectLight ( 204, false );
dbPositionObject ( 204, 24800.0f, 0.0f, 8000.0f );
dbRotateObject ( 204, 0, 720, 0 );
dbHideObject ( 204 );

dbLoadObject ( "x13.x", 205 );
dbScaleObject ( 205, 2000, 3000, 2000 );
dbSetObjectLight ( 205, false );
dbPositionObject ( 205, 3000.0f, 0.0f, 3000.0f );
dbRotateObject ( 205, 0, 720, 0 );


// make a new camera
dbMakeCamera ( 1 );
dbSetCameraView ( 1, 187 + 12, 10, 540 - 100, 120 - 23 );


// and now some camera properties
dbSetCurrentCamera ( 1 );
dbSetCameraRange ( 1, 10000000 );

//dbGhostObjectOn ( 1 );
//dbCloneObject ( 2, 1 );



// make a new camera
dbMakeCamera ( 2 );
dbSetCameraView ( 2, 0, 400, 150, 500 );
dbSetCurrentCamera ( 2 );
dbSetCameraRange ( 2, 10000000 );


// make a new camera
//dbMakeCamera ( 3 );
//dbSetCameraView ( 3, 500, 400, 640, 120 - 53 );


// now onto our main loop
while ( LoopGDK ( ) )
{


dbSetCurrentCamera ( 1 );
dbSetCameraToFollow ( 1, 0, 0, 0, 0, -115, 135, 10.0, 0 );
dbSetCurrentCamera ( 1 );
dbSetCurrentCamera ( 2 );
dbSetCameraToFollow ( 2, 0, 0, 0, 0, -115, 135, 10.0, 0 );
dbSetCurrentCamera ( 2 );
//dbSetCurrentCamera ( 3 );
//dbSetCameraToFollow ( 0, 0, 0, 135, 0, 0, 10.0, 0 );


if ( dbUpKey () ==1 && dbRightKey () == 1 )
{
dbTurnCameraRight ( 1, 1 );
}

if ( dbUpKey () ==1 && dbLeftKey () == 1 )
{
dbTurnCameraLeft ( 1, 1 );
}



if ( dbUpKey () ==1 && dbRightKey () == 1 )
{
dbTurnCameraRight ( 2, 1 );
}

if ( dbUpKey () ==1 && dbLeftKey () == 1 )
{
dbTurnCameraLeft ( 2, 1 );
}


if ( dbUpKey () == 1 )
{

dbControlCameraUsingArrowKeys ( 0, 10.0f , 1 );

}
// find the ground height of the terrain
float fHeight = dbGetTerrainGroundHeight ( 1, dbCameraPositionX ( ), dbCameraPositionZ ( ) );

dbPositionCamera ( dbCameraPositionX (), fHeight + 20.0f, dbCameraPositionZ () );


if ( dbSpaceKey ( ) == 1 )
{
dbTurnObjectLeft ( 100, 1.0f );
}

if ( dbShiftKey ( ) == 1 )
{
dbTurnObjectRight ( 100, 1.0f );
}


for ( float speed = 0.01f; speed <= 3; speed++ )
{
dbMoveObject (100, -speed);
}

// update the terrain
dbUpdateTerrain ( );

// update the screen
dbSync ( );
}
}[center]


here is my code..

always be humble..

Login to post a reply

Server time is: 2024-10-01 23:33:23
Your offset time is: 2024-10-01 23:33:23