Switching Camera to different Placeholders

Blitz3D Forums/Blitz3D Beginners Area/Switching Camera to different Placeholders

3DMan(Posted 2007) [#1]
Greetings,

I would appreciate some help with the following few questions:

I want to set up a few fixed camera "pivots or placeholders" in different areas of a map in 3DS Max, and I would like to use them to switch the camera to those "placeholders"

a) when the player would come to a certain distance of a certain placeholder

b) when the player would come to a certain position (trigger), which would then switch to the corresponding camera

c) some cameras would turn with the player (always facing the player)

How could that be done?

Thank you :)


Danny(Posted 2007) [#2]
you can use EntityDistance() to check the distance between 2 entities. So for example;

if EntityDistance(player,camera4) < 5.0 then 'switch to camera 4'

you can use PointEntity to keep the camera (or any other entity) 'pointed' or 'facing in the direction of' another entity, like so: PointEntity(camera3, player) will point camera3 to the player (keeping it in center frame).

create pivots at the location where you want the camera to switch to, ie. your 'place holders'. Then simply place the camera at the pivot position, or parent the camera to the pivot.

hope that helps,

d.


3DMan(Posted 2007) [#3]
Thank you for your reply Danny.

['switch to camera 4']

[Then simply place the camera at the pivot position, or parent the camera to the pivot.]

Could I see a code example of how to do that please?


Danny(Posted 2007) [#4]
This will set the camera's positon to the xyz coordinates of 'pivot4':

positionEntity camera, entityx(pivot4), entityy(pivot4), entityZ(pivot4)

Check Blitz's examples to see how to place entities and cameras..


3DMan(Posted 2007) [#5]
Thank you Danny.

It says Entity doesn't exist if I do "PositionEntity camera, EntityX(cam_loc_1), EntityY(cam_loc_1), EntityZ(cam_loc_1)"
cam_loc_1 is a pivot inside the main map.
How can I make that work and could i use a cube inside the main map instead of pivot?

By the way - how many methods are there to trigger events - you mentioned checking for distance between the player and the trigger, are there any other?


Danny(Posted 2007) [#6]
Do these:
print camera
print cam_loc_1

if either one of them gives a zero '0' then it's not an entity. Also not sure if you can name a variable with _1 at the end. Try renaming that variable to CamLoc1 instead.

Check the code archives for many samples on intersections, etc. Here's one called 'Triggerplate system for detecting intrusion events':
http://www.blitzbasic.com/codearcs/codearcs.php?code=1901


3DMan(Posted 2007) [#7]
CamLoc1 ( and cam_loc_1 ) both return 0 in the debugger - I get the "Entity doesn't exist" before I could print anything out.

How can they not exist when they are included in the map and named before exporting, both from 3DSMax, and Gile[s].
Am I doing anything wrong?

Thank you again


Danny(Posted 2007) [#8]
you should create your camera's and pivots in blitz, not try to import them from external files.

camera = createcamera()
camLoc1 = createpivot()

d.


3DMan(Posted 2007) [#9]
Does that mean that I can't use -in 3d editor- prepositioned objects?


cermit(Posted 2007) [#10]
It depends on the format you're using Blitz3D with, but mostly the answer would be no i think.

However, you could use FindChild( "Name of joint/bone" ) in Blitz3D with the b3d format and then get the coords with EntityX() etc to create a pivot at that position.
CamCoords[ 4 ] = FindChild( "Camera 4" )
CamPivot[ 4 ] = CreatePivot(  )
PositionEntity CamPivot[ 4 ], EntityX( CamCoords[ 4 ] ), EntityY( CamCoords[ 4 ] ), EntityZ( CamCoords[ 4 ] )

That's what i would do or create some simple editor.


PowerPC603(Posted 2007) [#11]
You need to load your map as an animated mesh, that way Blitz will keep the hierarchical structure of your map, otherwise all entities are merged together as one big mesh.
map=LoadAnimMesh("YourMap.b3d")

Then to find the camera locations (the pivots you have placed in 3DSMax):
CamLoc1=FindChild(map, "cam_loc_1")


Now you should be able to use CamLoc1 to position your camera to that location, as you now have the entityhandle towards that location.
PositionEntity camera, EntityX(CamLoc1), EntityY(CamLoc1), EntityZ(CamLoc1)



3DMan(Posted 2007) [#12]
Thank you for helping guys.

And thank you very much PowerPC603 - it's exactly what I've been looking for - that works perfectly!