uiacceltk/hitchcock/Client/src/alfm3gmesh.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   M3G 3D Mesh
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alfm3gmesh.h"
       
    21 #include "alf/alfenv.h"
       
    22 #include "alf/alfgencomponent.h"
       
    23 #include "alf/alfconstants.h"
       
    24 #include "alflogger.h"
       
    25 
       
    26 struct CAlfM3GMesh::TM3GMeshPrivateData
       
    27     {
       
    28     CAlfEnv* iEnv; // Not owned
       
    29     CAlfGenComponent* iComms; // Not owned
       
    30     };
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // Exposed constructor
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CAlfM3GMesh* CAlfM3GMesh::NewL( CAlfGenComponent& aComms, CAlfEnv& aEnv )
       
    39     {
       
    40     CAlfM3GMesh* self = new( ELeave ) CAlfM3GMesh;
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL( aComms, aEnv );
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // First phase constructor
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CAlfM3GMesh::CAlfM3GMesh()
       
    52     {
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // Second phase constructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void CAlfM3GMesh::ConstructL( CAlfGenComponent& aComms, CAlfEnv& aEnv )
       
    60     {
       
    61     // Construct the base class
       
    62     CAlfMesh::ConstructL(aComms, EAlfMeshTypeM3G);
       
    63     
       
    64     // Create object data.
       
    65     iData = new (ELeave) TM3GMeshPrivateData;
       
    66     
       
    67     // Zero all object data
       
    68     iData->iEnv = NULL;
       
    69     iData->iComms = NULL;
       
    70     
       
    71     // Fill data
       
    72     iData->iEnv = &aEnv;
       
    73     iData->iComms = &aComms;
       
    74     
       
    75     // Create input and output buffers for inter-process communication
       
    76     TBuf8<1> outDummy;
       
    77     TInt param = EAlfMeshTypeM3G;
       
    78     TPckgC<TInt> buf(param);
       
    79         
       
    80     // Call a synchronous command to create an associated server-side M3G mesh.
       
    81     TInt err = iData->iComms->DoSynchronousCmd(EAlfMeshVisualCreateMesh, buf, outDummy);
       
    82     if (err)
       
    83         {
       
    84         __ALFLOGSTRING1( "CAlfM3GMesh::ConstructL leave error %d", err )
       
    85         User::Leave( err );
       
    86         }
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // Destructor
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 CAlfM3GMesh::~CAlfM3GMesh()
       
    94     {
       
    95     delete iData;
       
    96     iData = NULL;
       
    97     }
       
    98 
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // Loads a new M3G Mesh scene into this M3G mesh
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 EXPORT_C void CAlfM3GMesh::LoadSceneL(const TDesC& aFileName)
       
   105     {
       
   106     ASSERT(iData != NULL);
       
   107     
       
   108     TFileName filename = aFileName;
       
   109     
       
   110     // Prepend the image file path to the filename.
       
   111     iData->iEnv->TextureManager().PrependImagePath(filename);
       
   112     
       
   113     // Create input and output buffers for inter-process communication
       
   114     TBuf8<1> outDummy;
       
   115     TAlfMeshLoadM3GSceneParams params;
       
   116     params.iFilename = filename;
       
   117     
       
   118     TPckg<TAlfMeshLoadM3GSceneParams> paramsPckg(params);
       
   119     
       
   120     // Call a synchronous command to load the M3G scene graph
       
   121     TInt err = iData->iComms->DoSynchronousCmd(EAlfMeshLoadM3GScene, paramsPckg, outDummy);
       
   122     if (err)
       
   123         {
       
   124         __ALFLOGSTRING1( "CAlfM3GMesh::LoadSceneL leave error %d", err )
       
   125         User::Leave( err );
       
   126         }    
       
   127     }