Match game cam to editor cam – ShiVa Engine

Match game cam to editor cam

Use this script to place the main camera of your game in the same position and orientation as the default camera of the current scene (the camera used to move around when editing in the “Scene Viewer”).
The default camera must be tagged, use the “Scene Explorer” to do so, as you can’t select it from the “Scene Viewer”.
Utilisez ce script pour placer la camera principale à la même position et orientation que la camera par defaut de la scène courante (la camera utilisé dans le “Scene Viewer”).
La camera par defaut doit être taggé, utilisez le “Scene Explorer” pour celà, il est impossible de la sélectionner depuis le “Scene Viewer”.

--------------------------------------------------------------------------------
--  Handler.......... : onInit
--  Author........... : KYiS (kyosiris_AT_free.fr)
--  Description...... : Match main camera to default camera
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function mainCam_AI.onInit (  )
--------------------------------------------------------------------------------
    local hScene = application.getCurrentUserScene ( )
    local hDefault_Camera = scene.getTaggedObject ( hScene , "Default_Camera_Tag" )
    local hMain_Camera = this.getObject ( )
    local DCx, DCy, DCz = object.getTranslation ( hDefault_Camera , object.kGlobalSpace )
    local DCrx, DCry, DCrz = object.getRotation ( hDefault_Camera , object.kGlobalSpace )
    --log.message ( "Default Cam Translation = x("..DCx..") y("..DCy..") z("..DCz..")" )
    --log.message ( "Default Cam Rotation = rx("..DCrx..") ry("..DCry..") rz("..DCrz..")" )
    object.matchTranslation ( hMain_Camera , hDefault_Camera , object.kGlobalSpace )
    object.matchRotation ( hMain_Camera , hDefault_Camera , object.kGlobalSpace )
    --log.message ( "main camera matched" )
    --local MCx, MCy, MCz = object.getTranslation ( this.getObject ( ) , object.kGlobalSpace )
    --local MCrx, MCry, MCrz = object.getRotation ( this.getObject ( ) , object.kGlobalSpace )
    --log.message ( "Main Cam Translation = x("..MCx..") y("..MCy..") z("..MCz..")" )
    --log.message ( "Main Cam Rotation = rx("..MCrx..") ry("..MCry..") rz("..MCrz..")" )
    --Use this line to keep the visible geometry of the Default Camera out of the field of view of the main camera
    --you can also use the menu "display > object filter" to hide it, since shiva 1.7 you can hide the camera using runtime mode.
    --object.setTranslation ( hDefault_Camera , 9999 , 9999 , 9999, object.kGlobalSpace  )
--------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------



Need more answers?

  • slackBanner