uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiMeshVisual.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-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:   Definition of CHuiMeshVisual. CHuiMeshVisual is a visual
       
    15 *                that is able to display a 3D triangle mesh.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __HUIMESHVISUAL_H__
       
    22 #define __HUIMESHVISUAL_H__
       
    23 
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <uiacceltk/HuiOwnedPointer.h>
       
    27 #include <uiacceltk/HuiVisual.h>
       
    28 #include <uiacceltk/HuiSkin.h>
       
    29 #include <uiacceltk/HuiGc.h>
       
    30 #include <uiacceltk/HuiMesh.h>
       
    31 #include <uiacceltk/HuiImage.h>
       
    32 
       
    33 
       
    34 /* Forward declarations. */
       
    35 class CHuiControl;
       
    36 class CHuiProceduralMesh;
       
    37 class CHuiM3GMesh;
       
    38 
       
    39 /**
       
    40  * Visual that displays a 3D triangle mesh. 
       
    41  * This implementation only supports OpenGL ES as the renderer.
       
    42  */
       
    43 NONSHARABLE_CLASS(CHuiMeshVisual) : public CHuiVisual
       
    44     {
       
    45 public:
       
    46 
       
    47     /* Constructors and destructor. */
       
    48 
       
    49     /**
       
    50      * Constructs and appends a new mesh visual to the owner control.
       
    51      *
       
    52      * Creates a concrete CHuiMesh - derived implementation into this mesh visual
       
    53      * depending on the given mesh type. This method can leave with any leave codes
       
    54      * defined in the NewL - method of the concrete mesh class that is
       
    55      * constructed. This method allows creation of a specific mesh type upon the 
       
    56      * construction of the visual. When visual is created through CHuiControl::AppendVisualL()
       
    57      * or CHuiControl::AppendVisualLC() EHuiMeshTypeProcedural is used as the mesh
       
    58      * type. The mesh type can be changed by calling CreateMeshL().
       
    59      * 
       
    60      * @param aOwnerControl  Control that will own the new visual.    
       
    61      * 
       
    62      * @param aMeshType The enumerator describing the type of concrete mesh
       
    63      * to be created.     
       
    64      *
       
    65      * @return  The new visual.
       
    66      */
       
    67     IMPORT_C static CHuiMeshVisual* AddNewL(CHuiControl& aOwnerControl,
       
    68     										THuiMeshType aMeshType,
       
    69                                             CHuiLayout* aParentLayout = 0);
       
    70 
       
    71     /**
       
    72      * Constructor.
       
    73      */
       
    74     CHuiMeshVisual(MHuiVisualOwner& aOwner);
       
    75 
       
    76     /**
       
    77      * Second-phase constructor.
       
    78      */
       
    79     void ConstructL();
       
    80 
       
    81     /**
       
    82      * Destructor.
       
    83      */
       
    84     ~CHuiMeshVisual();
       
    85 
       
    86 
       
    87     /* Methods. */
       
    88 	/**
       
    89 	 * Creates CHuiMesh - derived object and attaches it to this CHuiMeshVisual.
       
    90 	 * This method will destroy the mesh object that was attached to this
       
    91 	 * mesh visual before. The created mesh object can be queried through
       
    92 	 * Mesh().
       
    93 	 *
       
    94 	 * @param aMeshType Mesh type to be created.
       
    95 	 */
       
    96 	IMPORT_C void CreateMeshL(THuiMeshType aMeshType);    
       
    97     
       
    98     /**
       
    99      * Sets the texture image used with this CHuiMeshVisual.
       
   100      */    
       
   101     IMPORT_C void SetImage(const THuiImage& aImage);
       
   102 
       
   103     /**
       
   104      * Secondary image is used for crossfading.
       
   105      */    
       
   106     IMPORT_C void SetSecondaryImage(const THuiImage& aImage);
       
   107 
       
   108     IMPORT_C void SetSpecularImage(const THuiImage& aImage);
       
   109 
       
   110 	
       
   111     /**
       
   112      * Returns the mesh object of the mesh visual.
       
   113      *
       
   114      * @return  Mesh.
       
   115      */
       
   116     IMPORT_C CHuiMesh& Mesh();
       
   117 
       
   118 	/**
       
   119 	 * Returns pointer to the procedural mesh of the mesh visual. If the 
       
   120 	 * contained mesh isn't procedural mesh, function returns NULL.
       
   121 	 * 
       
   122 	 * @return Pointer to the procedural mesh.
       
   123 	 */
       
   124 	IMPORT_C CHuiProceduralMesh* ProceduralMesh() const; 
       
   125 
       
   126 	/**
       
   127 	 * Returns pointer to the M3G mesh of the mesh visual. If the contained 
       
   128 	 * mesh isn't M3G mesh, function returns NULL.
       
   129 	 * 
       
   130 	 * @return Pointer to the M3G mesh.
       
   131 	 */
       
   132 	IMPORT_C CHuiM3GMesh* M3GMesh() const; 
       
   133 
       
   134     void GetClassName(TDes& aName) const
       
   135         {
       
   136         aName = _L("CHuiMeshVisual");
       
   137         }
       
   138 
       
   139 public: // From CHuiVisual
       
   140 
       
   141 	void SetSize(const THuiRealSize& aSize, TInt aTransitionTime = 0);
       
   142 	
       
   143    	void SetPos(const THuiRealPoint& aPos, TInt aTransitionTime = 0);
       
   144 
       
   145 	void SetRect(const THuiRealRect& aRect, TInt aTransitionTime = 0);
       
   146  	
       
   147  	/**
       
   148      * Draw the visual.
       
   149      */
       
   150     void DrawSelf(CHuiGc& aGc, const TRect& aDisplayRect) const;
       
   151 
       
   152     TBool Changed() const;
       
   153 
       
   154     void ClearChanged();
       
   155 
       
   156 private:
       
   157 
       
   158     /** Triangle mesh. */
       
   159     RHuiOwnedPointer<CHuiMesh> iMesh;
       
   160 
       
   161     /** Surface image for the mesh. */
       
   162     THuiImage iImage;
       
   163     
       
   164     /** Secondary surface image for the mesh. */
       
   165     THuiImage iSecondaryImage;
       
   166 
       
   167 
       
   168 public:
       
   169 
       
   170     /* Public properties. */
       
   171     
       
   172     /** Alpha level of the secondary image. */
       
   173     THuiTimedValue iSecondaryAlpha;
       
   174     
       
   175     THuiTimedValue iYawAngle;
       
   176     
       
   177     THuiTimedValue iPitchAngle;
       
   178     
       
   179     THuiTimedValue iScale;
       
   180 
       
   181     };
       
   182 
       
   183 #endif  // __HUIMESHVISUAL_H__