Change between cameras

Blitz3D Forums/Blitz3D Programming/Change between cameras

Chad(Posted 2007) [#1]
Hey, as I dive deeper into my project I've been getting into harder and more complicated code that I'm not so familiar with. With this in mind, this is not for the simple minded.

What I'm interested in, is on keyhit(b) for example, to create a new camera, with a png I have as a mask over the screen. So basically, I have a camera that I use all the time, what I want is some example code or full code, for creating a new camera with a texture blocking out some of the view. Is this possible in B3D?


For my next question it gets slightly harder. Again it deals with creating a new camera, but on collision with an entity AND keyhit(f). It's a stationary gun, and as you collide with it's collision and press f then it puts you in control of the weapon, which, basically I will have the camera viewing from the back of it, nothing special.


I can do most of all the positioning and everything of the cameras and entities and all that, what I need help on is the commands or variables for setting up these new cameras. To be honest, I have no idea how to even start these out. I'm going to need complete help and patience.

On a side note, the basic framework for my cameras, collisions, and other stuff along those lines follow WolRon's FPS code found here:

http://home.cmit.net/rwolbeck/programmingtutorial/

I can pretty much follow anything that gets added here, as I refer back to it quite often.

Thanks,
Chad


LAB[au](Posted 2007) [#2]
Well first of all the texture you are talking about isn't a property of the camera, but nevertheless it's possible. It will be a sprite or a quad parented to the camera, the you will have to mess up with entityorder (look in the documentation) if you want to ensure that it draws itself over everything else.

Look in the code archive for HUD or for the Pixie (pixel perfect sprites parented to camera). I am sure you can find everything you want in the code archives. Just browse...

I wouldn't create a "new" camera, I would just have a custom types list with the key values to apply to the camera (the one and only or almost...).


GfK(Posted 2007) [#3]
Well first of all the texture you are talking about isn't a property of the camera, but nevertheless it's possible. It will be a sprite or a quad parented to the camera, the you will have to mess up with entityorder (look in the documentation) if you want to ensure that it draws itself over everything else.
You'll also need to use CameraClsMode to disable colour buffer clearing on the HUD camera. Otherwise all you'll see is your HUD, and everything else black.


REJLA(Posted 2007) [#4]
One way to do the first is to draw the png image between the 'renderworld' and the 'flip' commands in the main loop

While KeyHit(1)=0
    ;... whatever code here
    RenderWorld 
    DrawImage PngImage,0,0
    Flip 
Wend


The non transparent portions of the drawn image should obscure the rest of the scene


Chad(Posted 2007) [#5]
Rejla, should I use loadanimtexture or load image?


REJLA(Posted 2007) [#6]
It works with both
Using LoadAnimImage would look something like this

;...
PngImage=LoadAnimImage(PngImageStrip,W,H,0,N)
;...

while Keyhit(1)=0
    ;....
    RenderWorld
    DrawImage PngImage X,Y,CurrentFrame
   Flip
wend



Of course you would need to determine the CurrentFrame variable on every loop, and it would depend on your program


Also, you would only use LoadAnimImage if you wish the image to be animated