Professional Web Applications Themes

problems with adding Camera as child to object - Macromedia Director 3D

Heres the problem. If I simply parent my camera to the pCamPar model all the rotation is skewed ie. The pCamPar posotion is not exactly the same as the camera. So I tried getting the current camera position/rotation and putting the vectors in camPosition/camRotation variables. Then set the position/rotation of pCamPar to these. When I test this the message window displays the pCamPar and camera are in the exact same position but I can see the pCamPar model in front of the camera at vector(0,0,0) (I assume ?cant test it ?cause the message window says its at the camera pos.) ...

  1. #1

    Default problems with adding Camera as child to object

    Heres the problem.
    If I simply parent my camera to the pCamPar model
    all the rotation is skewed ie. The pCamPar posotion is not exactly the same as the camera.

    So I tried getting the current camera position/rotation and putting the vectors in camPosition/camRotation variables. Then set the position/rotation of pCamPar to these. When I test this the message window displays the pCamPar and camera are in the exact same position but I can see the pCamPar model in front of the camera at vector(0,0,0) (I assume ?cant test it ?cause the message window says its at the camera pos.)
    The model moves with the cam but the cam rotations center point is at the models visible location.

    It does the same thing if I set the pCamera position/rotation with a fixed vector

    If I set the pCamera and pCamPar with fixed vectors it works.

    This doesn?t make sense because if the camera was at vector(0,50,0) for example and you made a variable of that vector and passed it to the pCamPar shouldn?t that do the same as what the working script is doing?

    Does anyone have an Idea
    Thanks, Rhys
    [email]rhysburniehotmail.com[/email]

    HERES THE SCRIPT
    on beginSprite me
    ---------------
    gTriggerYes=0
    gWhichMod=0
    ---------------
    p3dMember = sprite(me.spriteNum).member
    pSprite = sprite(me.spriteNum)
    pCamera = pSprite.camera


    pDownArrow = FALSE
    pLeftArrow = FALSE
    pRightArrow = FALSE

    GET CAMRERA POSITION

    -- camPosition=p3dMember.camera[1].transform.position
    -- camRotation=p3dMember.camera[1].transform.rotation
    -- camPosition=vector(0,50,0)
    -- camRotation=vector(0,0,0)

    pCamera.transform.position=vector(0,50,0)
    pCamera.transform.rotation=vector(0,0,0)
    -- create 'parent' Sphere ------------------------------

    p3dMember.deleteModelResource("cameraPar") -- deletes if allready exists
    camPar = p3dMember.newModelResource("cameraPar",#Sphere)
    camPar.radius=10
    p3dMember.deleteModel("cameraPar") --delete existing "cameraShere" Model
    pCamPar = p3dMember.newModel("cameraPar",camPar)

    -- pCamPar.transform.position=camPosition
    -- pCamPar.transform.rotation=camRotation

    pCamPar.transform.position=vector(0,50,0)
    pCamPar.transform.rotation=vector(0,0,0)
    -----------------------------------------------------
    --
    -- create the camera's bounding sphere --------------

    p3dMember.deleteModelResource("cameraSphere") -- deletes if allready exists
    camSphere = p3dMember.newModelResource("cameraSphere",#sphere)
    camSphere.radius = 100
    p3dMember.deleteModel("cameraSphere") --delete existing "cameraShere" Model
    pCameraSphere = p3dMember.newModel("cameraSphere",camSphere)
    -----------------------------------------------------
    --
    -- create a light to carry with the camera

    p3dMember.deleteLight("cameraLight") --delete existing "cameraLight"
    camLight = p3dMember.newLight("cameraLight",#point)
    camLight.color = rgb(170,170,170)

    -- PARENT ITEMS -------------------------------------
    -- make pCameraBox parent of pCamera
    pCamPar.addChild(pCamera, #preserveParent)
    -- make pCameraSphere & camLight children of pCamera
    pCamera.addChild(pCameraSphere,#preserveParent)
    pCamera.addChild(camLight,#preserveParent)

    -- register the member for regular timeMS events in order to respond to
    -- user input and resolve camera collisions
    p3dMember.registerForEvent(#timeMS,#controlCamera, me,2500,50,0)

    end



    Bazmati webforumsuser@macromedia.com Guest

  2. #2

    Default Re: problems with adding Camera as child to object

    Hello,

    Instead of setting the parent of the camera to the pCamPar model, use the
    addChild() lingo instruction:
    pCamPar.addChild(pCamera, #preserveWorld)

    The #preserveWorld parameter of the addChild() lingo instruction allows to
    keep the relative position intact when attaching nodes to one another.

    Karl.



    Karl Sigiscar Guest

Similar Threads

  1. Object being in the camera's view
    By Ziggi in forum Macromedia Director 3D
    Replies: 1
    Last Post: March 14th, 12:40 AM
  2. Camera rotation around an object
    By aperion0 in forum Macromedia Director 3D
    Replies: 0
    Last Post: July 14th, 04:51 AM
  3. adding multiple child records
    By acidrain9 in forum Dreamweaver AppDev
    Replies: 1
    Last Post: February 19th, 08:14 PM
  4. child object oddity
    By Word of Mouth Productions in forum Macromedia Director Lingo
    Replies: 2
    Last Post: October 22nd, 11:54 PM
  5. child object on demand?
    By Mike S in forum PHP Development
    Replies: 1
    Last Post: July 8th, 06:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139