<?xml version="1.0" encoding="utf-8" ?>
<sector name="Player">
  <vEye> {0 0 0 0} </vEye>
  <vTarget> {0 0 0 0} </vTarget>
  <fHeading> 0.0 </fHeading>
  <fPitch> 30.0 </fPitch>

  <vForward> {0.0, 0.0, 1.0, 0.0} </vForward>
  <vRight> {1.0, 0.0, 0.0, 0.0} </vRight>
  <vUp> {0.0, 1.0, 0.0, 0.0} </vUp>

  <vViewport> {0.0, 0.0, 640.0, 480.0} </vViewport>
  <fFOV> 75.0 </fFOV>
  <!-- horizontal -->
  <fClipNear> 0.1 </fClipNear>
  <fClipFar> 10000.0 </fClipFar>
  <fForceConstant> 50.0 </fForceConstant>
  <fMinVelocity> 0.0 </fMinVelocity>
  <fMaxVelocity> 10.0 </fMaxVelocity>

  <fPi> 3.14159 </fPi>
  
  <tPlayer prototype="EntityCollidable">
    <!-- Graphics Related -->
    <pVertexBuffer>NULL</pVertexBuffer>
    <pIndexBuffer>NULL</pIndexBuffer>
    <sFilename>cube.obj</sFilename> <!-- TODO: Change the .obj -->
    <iNumVertices>0</iNumVertices>
    <iNumFaces>0</iNumFaces>
    <iUseIndexBuffer>true</iUseIndexBuffer>
    <iHasNormals>false</iHasNormals>
    <iHasTexCoords>false</iHasTexCoords>
    <vScale> {1.0, 1.0, 1.0} </vScale>
    <xRotate> {1 0 0 0  0 1 0 0  0 0 1 0  0 0 0 1} </xRotate>
    <vRotate> {0.0, 0.0, 1.0, 0.0} </vRotate>
    <vTranslate> {0.0, 5.0, 0.0} </vTranslate> <!-- meters -->
    <pMaterial>NULL</pMaterial>
    <pTexture>NULL</pTexture>
    <pVertexShader>NULL</pVertexShader>
    <pPixelShader>NULL</pPixelShader>
    <!-- Physics Related -->
    <vOrientation> {0 0 0 0} </vOrientation>
    <vAngMomentum> {0 0 0 0} </vAngMomentum>
    <vAngVelocity> {0 0 0 0} </vAngVelocity>
    <vMomentum> {0 0 0 0} </vMomentum>
    <vVelocity> {0 0 0 0} </vVelocity>
    <vForce> {0 0 0 0} </vForce> <!-- Drag Force -->
    <vForce index="1"> {0 0 0 0} </vForce> <!-- Forward Force -->
    <vForce index="2"> {0 0 0 0} </vForce> <!-- Reverse Force -->
    <vForce index="3"> {0 0 0 0} </vForce> <!-- Left Force -->
    <vForce index="4"> {0 0 0 0} </vForce> <!-- Right Force -->
    <vPosOfForce> {0 0 0 0} </vPosOfForce>
    <vPosOfForce index="1"> {0 0 0 0} </vPosOfForce>
    <vPosOfForce index="2"> {0 0 0 0} </vPosOfForce>
    <vPosOfForce index="3"> {0 0 0 0} </vPosOfForce>
    <vPosOfForce index="4"> {0 0 0 0} </vPosOfForce>
    <!-- Collidable Entity Prescribed Attributes -->
    <fMassInverse> 1.0 </fMassInverse>
    <fMass> 1.0 </fMass>
    <vCenterOfMass> {0,0,0,0} </vCenterOfMass>
    <fElacticity> 0.0 </fElacticity>
    <fBoundingRadius> 0.79 </fBoundingRadius>
    <iBoundingVolumeType>SPHR</iBoundingVolumeType>
    <vConvexHull index="0"> {1,0,0,0.395} </vConvexHull>
    <vConvexHull index="1"> {-1,0,0,-0.395} </vConvexHull>
    <vConvexHull index="2"> {0,1,0,0.395} </vConvexHull>
    <vConvexHull index="3"> {0,-1,0,-0.395} </vConvexHull>
    <vConvexHull index="4"> {0,0,1,0.395} </vConvexHull>
    <vConvexHull index="5"> {0,0,-1,-0.395} </vConvexHull>
    <rConvexHull> vConvexHull </rConvexHull>
    <rPosition> vTranslate </rPosition>
    <rVelocity> vVelocity </rVelocity>
    <rMomentum> vMomentum </rMomentum>
    <rForce> vForce </rForce>
    <rPosOfForce> vPosOfForce </rPosOfForce>
    <rOrientation> xRotate </rOrientation>
    <rAngMomentum> vAngMomentum </rAngMomentum>
    <rAngVelocity> vAngVelocity </rAngVelocity>
    <!-- ActionUpdateDynamics Related -->
    <fCoeffDrag> 0.1 </fCoeffDrag>
    <fCrossSectionalArea> 0.0 </fCrossSectionalArea>
    <fVelocityMagnitude> 0.0 </fVelocityMagnitude>
    <iPrintKick>0</iPrintKick>
    <sKickString> NoKick </sKickString>
    <sKickString index="1"> Kick </sKickString>

    <!-- Player related -->
    
    <Init>
      <tCreateGeometry prototype="ActionCreateGeometryBuffers">
        <rVertexBuffer>pVertexBuffer</rVertexBuffer>
        <rIndexBuffer>pIndexBuffer</rIndexBuffer>
        <rFilename>sFilename</rFilename>
        <rNumVertices>iNumVertices</rNumVertices>
        <rNumFaces>iNumFaces</rNumFaces>
        <rUseIndexBuffer>iUseIndexBuffer</rUseIndexBuffer>
        <rHasNormals>iHasNormals</rHasNormals>
        <rHasTexCoords>iHasTexCoords</rHasTexCoords>
      </tCreateGeometry>
      <tSetMaterial prototype="ActionSetMaterial">
        <rMaterialPointer>pMaterial</rMaterialPointer>
        <rTexturePointer>pTexture</rTexturePointer>
        <rVertexShaderPointer>pVertexShader</rVertexShaderPointer>
        <rPixelShaderPointer>pPixelShader</rPixelShaderPointer>
        <vDiffuse> {1.0, 1.0, 1.0, 1.0} </vDiffuse>
        <sTextureFile> fiealogo.dds </sTextureFile>
        <sVertexShader> C3E2v_varying.cg </sVertexShader>
        <sPixelShader> C3E3f_texture.cg </sPixelShader>
        <!-- <vAmbient> {1.0, 0.0, 0.0, 1.0} </vAmbient> -->
        <!-- <vSpecular> {1.0, 0.0, 0.0, 1.0} </vSpecular> -->
        <!-- <vEmissive> {0.0, 0.0, 1.0, 1.0} </vEmissive> -->
        <!-- <fPower>1.0</fPower> -->
      </tSetMaterial>
      <tActionSetCameraTranslate prototype="ActionList">
        <expr> vEye = vTranslate</expr>       
      </tActionSetCameraTranslate>
      <tInitFPCamera prototype="ActionSetFPCamera">
        <rEye> vEye </rEye>
        <rTarget> vTarget </rTarget>
        <rForward> vForward </rForward>
        <rRight> vRight </rRight>
        <rUp>vUp </rUp>
        <rHeading> fHeading </rHeading>
        <rPitch> fPitch </rPitch>
      </tInitFPCamera>
      <tInitCameras prototype="ActionSetCamera">
        <rViewport> vViewport </rViewport>
        <rEye> vEye </rEye>
        <rTarget> vTarget </rTarget>
        <rUp> vUp </rUp>
        <rFOV> fFOV </rFOV>
        <rClipNear> fClipNear </rClipNear>
        <rClipFar> fClipFar </rClipFar>
      </tInitCameras>
      <expr> fCrossSectionalArea = fPi * fBoundingRadius * fBoundingRadius </expr>
    </Init>

    <Update>
      <tExpressionUpdate prototype="ActionList">
        <expr> fVelocityMagnitude = sqrt ( vVelocity * vVelocity )  </expr>
        <expr> fVelocityMagnitude = fVelocityMagnitude * fCrossSectionalArea </expr>
        <expr> fVelocityMagnitude = fVelocityMagnitude * fCoeffDrag </expr>
        <expr> vForce = vVelocity * ( - fVelocityMagnitude ) </expr>
        <expr> vEye = vTranslate </expr>
      </tExpressionUpdate>
      <tRefreshFPCam prototype="ActionSetFPCamera">
        <rEye> vEye </rEye>
        <rTarget> vTarget </rTarget>
        <rForward> vForward </rForward>
        <rRight> vRight </rRight>
        <rUp> vUp </rUp>
        <rHeading> fHeading </rHeading>
        <rPitch> fPitch </rPitch>
      </tRefreshFPCam>
      <tRefreshCamera prototype="ActionSetCamera">
        <rEye> vEye </rEye>
        <rTarget> vTarget </rTarget>
        <rUp> vUp </rUp>
      </tRefreshCamera>
      <tUpdateDynamics prototype="ActionUpdateDynamics">
        <iApplyGravity> 1 </iApplyGravity>
        <rPosition> vTranslate </rPosition>
        <rVelocity> vVelocity </rVelocity>
        <rForce> vForce </rForce>
        <rMomentum> vMomentum </rMomentum>
        <!--<rShapes>tShapes</rShapes>-->
        <rRadius>fBoundingRadius</rRadius>
        <rOrientation>xRotate</rOrientation>
        <rAngMomentum>vAngMomentum</rAngMomentum>
        <rPosOfForce>vPosOfForce</rPosOfForce>
        <rAngVelocity>vAngVelocity</rAngVelocity>
        <rMass>fMass</rMass>
        <rMassInverse>fMassInverse</rMassInverse>
        <rCenterOfMass>vCenterOfMass</rCenterOfMass>
      </tUpdateDynamics>
      <tClampVelocity prototype="ActionClampVector">
        <rVectorToClamp> vVelocity </rVectorToClamp>
        <rUpperBound> fMaxVelocity </rUpperBound>
      </tClampVelocity>
      <tResetKick prototype="ActionList">
        <expr> iPrintKick = 0 </expr>
         <!--Display kick--> 
      </tResetKick>
    </Update>

    <Render>
      <tSetMaterial prototype="ActionSetMaterial">
        <rMaterialPointer>pMaterial</rMaterialPointer>
        <rTexturePointer>pTexture</rTexturePointer>
        <rVertexShaderPointer>pVertexShader</rVertexShaderPointer>
        <rPixelShaderPointer>pPixelShader</rPixelShaderPointer>
      </tSetMaterial>
      <tRenderGeometry prototype="ActionRenderGeometry">
        <rVertexBuffer>pVertexBuffer</rVertexBuffer>
        <rIndexBuffer>pIndexBuffer</rIndexBuffer>
        <rFilename>sFilename</rFilename>
        <rNumVertices>iNumVertices</rNumVertices>
        <rNumFaces>iNumFaces</rNumFaces>
        <rUseIndexBuffer>iUseIndexBuffer</rUseIndexBuffer>
        <rHasNormals>iHasNormals</rHasNormals>
        <rHasTexCoords>iHasTexCoords</rHasTexCoords>
        <rScale>vScale</rScale>
        <rOrientation>xRotate</rOrientation>
        <rRotate>vRotate</rRotate>
        <rTranslate>vTranslate</rTranslate>
      </tRenderGeometry>
      <sText> Forces: </sText>
      <sText index="1"> null </sText>
      <sText index="2"> null </sText>
      <sText index="3"> null </sText>
      <sText index="4"> null </sText>
      <sText index="5"> null </sText>
      <sText index="6"> null </sText>
      <sText index="7"> null </sText>
      <vColor> {1,1,1,1} </vColor>
      <sFont> Courier New </sFont>
      <iSize> 20 </iSize>
      <tExprList prototype="ActionList">
        <expr> sText [ 1 ] = vForce [ 0 ] </expr>
        <expr> sText [ 2 ] = vForce [ 1 ] </expr>
        <expr> sText [ 3 ] = vForce [ 2 ] </expr>
        <expr> sText [ 4 ] = vForce [ 3 ] </expr>
        <expr> sText [ 5 ] = vForce [ 4 ] </expr>
        <expr> sText [ 6 ] = sKickString [ iPrintKick ] </expr>
        <expr> sText [ 7 ] = vVelocity </expr>
      </tExprList>
      <tRenderForces prototype="ActionRenderText">
        <vPosition> {0,0,0,0} </vPosition>
        <rText> sText </rText>
        <rPosition> vPosition </rPosition>
        <rColor> vColor </rColor>
        <rFont> sFont </rFont>
        <rSize> iSize </rSize>
      </tRenderForces>
    </Render>
    
    <!-- Input Reactions -->
    <tReactionAccelerateForward prototype="ReactionInput">
      <iSoughtInputs>btnw</iSoughtInputs>
      <iMask>-1</iMask>
      <tDetermineForwardForce prototype="ActionList">
         <expr> vForce [ 1 ] = fForceConstant * vForward </expr>
      </tDetermineForwardForce>
    </tReactionAccelerateForward>

    <tReactionAccelerateBackward prototype="ReactionInput">
      <iSoughtInputs>btns</iSoughtInputs>
      <iMask>-1</iMask>
      <tDetermineBackwardForce prototype="ActionList">
        <expr> vForce [ 2 ] = ( - fForceConstant ) * vForward </expr>
      </tDetermineBackwardForce>
    </tReactionAccelerateBackward>

    <tReactionAccelerateLeft prototype="ReactionInput">
      <iSoughtInputs>btna</iSoughtInputs>
      <iMask>-1</iMask>
      <tDetermineLeftForce prototype="ActionList">
        <expr> vForce [ 3 ] = ( - fForceConstant ) * vRight </expr>
      </tDetermineLeftForce>
    </tReactionAccelerateLeft>

    <tReactionAccelerateRight prototype="ReactionInput">
      <iSoughtInputs>btnd</iSoughtInputs>
      <iMask>-1</iMask>
      <tDetermineRightForce prototype="ActionList">
       <expr> vForce [ 4 ] = fForceConstant * vRight </expr>
      </tDetermineRightForce>
    </tReactionAccelerateRight>

    <tReactionKick prototype="ReactionInput">
      <iSoughtInputs>spce</iSoughtInputs>
      <iMask>-1</iMask>
      <tKick prototype="ActionList">
        <expr> iPrintKick = 1 </expr>
      </tKick>
    </tReactionKick>
  </tPlayer>
</sector>
