Switch between camera's ( FreeBASIC + IrrLicht )

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Switch between camera's ( FreeBASIC + IrrLicht )

Post by wahagn »

Hey all,

As you can see I didn't switch to any other 3d engine I just switched the PL I use from c++ to FreeBASIC and am now using irrlicht with the freeBASIC wrapper. I already succeeded in making a usefull code snippet for this forum.

this code snippet is for beginners who want to know how to switch betwwen camera's using key reading... it's very easy but I couldn't find a tut on this in the tutorials given with the wrapper so I made a tut myself. I hope there will be some people who will find this usefull...

Code: Select all


' include the irrlichtwrapper to use irrlicht with FreeBasic
#include "IrrlichtWrapper.bi"

' declare two camera's to swith between them
dim camera as irr_camera
dim camera2 as irr_camera
' make a key event pointer to be able to use keyboard keys 
dim keyevent as IRR_KEY_EVENT PTR


' start up an Irrlicht window 
IrrStart(IRR_EDT_DIRECT3D9,800,600,IRR_BITS_PER_PIXEL_32,IRR_WINDOWED,_
IRR_NO_SHADOWS,IRR_CAPTURE_EVENTS,IRR_VERTICAL_SYNC_ON)

' set a title for this application
IrrSetWindowCaption("Title of application")

' add two diffrent camera's to switch between those two
camera = IrrAddMayaCamera( IRR_NO_OBJECT, 100.0, 100.0, 100.0 )
camera2 = IrrAddFPSCamera



While IrrRunning
    
  IrrBeginScene( 50,50,50 )
  

' while there are key events waiting
  While IrrKeyEventAvailable

' read the key events
keyevent = IrrReadKeyEvent

' if the letter R is pressed on the keyboard
    if keyevent->key = KEY_KEY_R then
' look with the camera : camera  so the FPS camera
        IrrSetActiveCamera (camera)
' else look with camera: camera 2 so the Maya one 
        else IrrSetActiveCamera (camera2)
    End if
    
WEND
    
    IrrDrawScene
    

    
    IrrEndScene
    
Wend 

IrrStop





BTW: if you pressed R but want back to the FPS Camera hit one of the the arrow keys then your looking with the FPS Camera again...


BTW2: if you're a beginner and you want to do something with freeBASIC + IrrLicht but don't know how to archive what you want: tell me and maybe I will make a code snippet of it ( but I have to say that I'm not a irrLicht + FB guru; I started a week ago or so but I was learning c++ before then so FB was very easy for me )
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
Kalango
Posts: 157
Joined: Thu Apr 26, 2007 12:46 am

Post by Kalango »

Congratulations wahagn, keep evolving and doing stuff. You're better off doing stuff than searching for engines ;).
Hope to see some completed game from you.
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Post by wahagn »

Kalango wrote:Congratulations wahagn, keep evolving and doing stuff. You're better off doing stuff than searching for engines ;).
Hope to see some completed game from you.
Yeah.. thank you Kalongo and all the others helping me out on that topic ( panda3d vs irrlicht ).

although none of you suggested to use the irrlicht FreeBASIC wrapper :P ... you explaining me that irrlicht is easy and one of the best freeware engine's on the web helped me to stick with IrrLicht but just find an easy way to work with it :D... so I started searching and accidently came across the FreeBASIC website and found out that there is a irrlicht wrapper for that compiler. I appreciate all the help given to me on that topic.

BTW: I'm already busy with a ( probably big ) game wich I will start very small and add new features and options, that's why I mad this code and then I realised that I can post it here on the code snippet part of the forum
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

although none of you suggested to use the irrlicht FreeBASIC wrapper
Well, wrappers do usually lack features that engine has, also it will lack latest bug fixes that you can have with svn from irrlicht repositionary.

Also I read that its using irrlicht 1.7.1 and uses only directx so you can't make your project cross platform, unless you add support yourself for opengl and software renderers.

the only thing that I like about this wrapper is that it has ?102? examples, tough I haven't seen them.

Good luck on your project.
Start small go BIG
Working on game: Marrbles (Currently stopped).
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Post by wahagn »

serengeor wrote:
although none of you suggested to use the irrlicht FreeBASIC wrapper
Well, wrappers do usually lack features that engine has, also it will lack latest bug fixes that you can have with svn from irrlicht repositionary.

Also I read that its using irrlicht 1.7.1 and uses only directx so you can't make your project cross platform, unless you add support yourself for opengl and software renderers.

the only thing that I like about this wrapper is that it has ?102? examples, tough I haven't seen them.

Good luck on your project.
Start small go BIG

It doesn't only use the direct3d render, take a look here :

This is a part of the documentation for the wrapper:

Code: Select all

Syntax
IrrStart ( device type , screen width as integer, screen height as integer, bits per pixel, full screen, use shadows, capture mouse and keyboard, vertical syncronisation )

Description
Starts the Irrlicht interface and opens a window for rendering.

device type specifies the renderer to use when drawing to the display this may be one of the following types: -

IRR_EDT_NULL
A NULL device with no display
IRR_EDT_SOFTWARE
Irrlichts default software renderer
IRR_EDT_SOFTWARE2
An improved quality software renderer
IRR_EDT_OPENGL
Hardware accelerated OpenGL renderer
IRR_EDT_DIRECT3D8
Hardware accelerated DirectX 8 renderer (not included in the Wrappers 'Irlicht.dll' distribution)
IRR_EDT_DIRECT3D9
Hardware accelerated DirectX 9 renderer (not included in the Wrappers 'Irlicht.dll' distribution)




BTW: actually there are 111 examples :P
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

Oh well maybe I missed something in the original freebasic wrapper thread.
The latest release is based on Irrlicht 1.7.1 and is build for DirectX support out of the box.
Working on game: Marrbles (Currently stopped).
Post Reply