64
|
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: Mesh base class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "alf/alfmesh.h"
|
|
21 |
#include "alf/alfgencomponent.h"
|
|
22 |
#include "alf/alfconstants.h"
|
|
23 |
#include "alflogger.h"
|
|
24 |
#include "alf/alftexture.h"
|
|
25 |
|
|
26 |
#include <uiacceltk/HuiUtil.h>
|
|
27 |
|
|
28 |
struct CAlfMesh::TMeshPrivateData
|
|
29 |
{
|
|
30 |
CAlfGenComponent* iComms; // not own
|
|
31 |
TInt iMeshType;
|
|
32 |
};
|
|
33 |
|
|
34 |
// ======== MEMBER FUNCTIONS ========
|
|
35 |
|
|
36 |
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
// ?description_if_needed
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CAlfMesh::CAlfMesh()
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// ?description_if_needed
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
void CAlfMesh::ConstructL( CAlfGenComponent& aComms, TInt aMeshType )
|
|
51 |
{
|
|
52 |
iData = new (ELeave) TMeshPrivateData;
|
|
53 |
iData->iComms = &aComms;
|
|
54 |
|
|
55 |
iData->iMeshType = aMeshType;
|
|
56 |
}
|
|
57 |
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
// ?description_if_needed
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CAlfMesh* CAlfMesh::NewL( CAlfGenComponent& aComms )
|
|
64 |
{
|
|
65 |
CAlfMesh* self = new( ELeave ) CAlfMesh;
|
|
66 |
CleanupStack::PushL( self );
|
|
67 |
self->ConstructL( aComms );
|
|
68 |
CleanupStack::Pop( self );
|
|
69 |
return self;
|
|
70 |
}
|
|
71 |
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
// ?description_if_needed
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
CAlfMesh::~CAlfMesh()
|
|
77 |
{
|
|
78 |
delete iData;
|
|
79 |
iData = NULL;
|
|
80 |
}
|
|
81 |
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
// Returns the mesh type definition of this mesh.
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
EXPORT_C TInt CAlfMesh::MeshType() const
|
|
87 |
{
|
|
88 |
return iData->iMeshType;
|
|
89 |
}
|
|
90 |
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
// ?implementation_description
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
EXPORT_C void CAlfMesh::Reset()
|
|
96 |
{
|
|
97 |
TBuf8<1> outDummy;
|
|
98 |
TInt err = iData->iComms->DoSynchronousCmd( EAlfMeshReset, KNullDesC8(), outDummy);
|
|
99 |
if (err)
|
|
100 |
{
|
|
101 |
__ALFLOGSTRING1( "CAlfMesh::Reset panic error %d", err )
|
|
102 |
USER_INVARIANT();
|
|
103 |
}
|
|
104 |
}
|
|
105 |
|
|
106 |
EXPORT_C void CAlfMesh::StretchUniformly(
|
|
107 |
TReal32 aXLimit,
|
|
108 |
TReal32 aXOffset,
|
|
109 |
TReal32 aYLimit,
|
|
110 |
TReal32 aYOffset,
|
|
111 |
TReal32 aZLimit,
|
|
112 |
TReal32 aZOffset) __SOFTFP
|
|
113 |
{
|
|
114 |
TRAP_IGNORE(StretchUniformlyL(aXLimit, aXOffset,aYLimit, aYOffset, aZLimit, aZOffset))
|
|
115 |
}
|
|
116 |
|
|
117 |
void CAlfMesh::StretchUniformlyL(
|
|
118 |
TReal32 aXLimit,
|
|
119 |
TReal32 aXOffset,
|
|
120 |
TReal32 aYLimit,
|
|
121 |
TReal32 aYOffset,
|
|
122 |
TReal32 aZLimit,
|
|
123 |
TReal32 aZOffset)
|
|
124 |
{
|
|
125 |
RArray<TReal32> array;
|
|
126 |
CleanupClosePushL( array );
|
|
127 |
|
|
128 |
array.AppendL( aXLimit );
|
|
129 |
array.AppendL( aXOffset );
|
|
130 |
array.AppendL( aYLimit );
|
|
131 |
array.AppendL( aYOffset );
|
|
132 |
array.AppendL( aZLimit );
|
|
133 |
array.AppendL( aZOffset );
|
|
134 |
|
|
135 |
HBufC8* buffer = ExternalizeLC(array);
|
|
136 |
TBuf8<1> outDummy;
|
|
137 |
|
|
138 |
TInt err = iData->iComms->DoSynchronousCmd( EAlfMeshStretchUniformly, *buffer, outDummy);
|
|
139 |
if (err)
|
|
140 |
{
|
|
141 |
__ALFLOGSTRING1( "CAlfMesh::StretchUniformly panic error %d", err )
|
|
142 |
USER_INVARIANT();
|
|
143 |
}
|
|
144 |
|
|
145 |
CleanupStack::PopAndDestroy( buffer );
|
|
146 |
CleanupStack::PopAndDestroy( &array );
|
|
147 |
}
|
|
148 |
|
|
149 |
EXPORT_C void CAlfMesh::ScaleUniformly(TReal32 aX, TReal32 aY, TReal32 aZ) __SOFTFP
|
|
150 |
{
|
|
151 |
TRAP_IGNORE(ScaleUniformlyL(aX, aY, aZ))
|
|
152 |
}
|
|
153 |
|
|
154 |
void CAlfMesh::ScaleUniformlyL(TReal32 aX, TReal32 aY, TReal32 aZ)
|
|
155 |
{
|
|
156 |
RArray<TReal32> array;
|
|
157 |
CleanupClosePushL( array );
|
|
158 |
|
|
159 |
array.AppendL( aX );
|
|
160 |
array.AppendL( aY );
|
|
161 |
array.AppendL( aZ );
|
|
162 |
|
|
163 |
HBufC8* buffer = ExternalizeLC(array);
|
|
164 |
TBuf8<1> outDummy;
|
|
165 |
|
|
166 |
TInt err = iData->iComms->DoSynchronousCmd( EAlfMeshScaleUniformly, *buffer, outDummy);
|
|
167 |
if (err)
|
|
168 |
{
|
|
169 |
__ALFLOGSTRING1( "CAlfMesh::ScaleUniformly panic error %d", err )
|
|
170 |
USER_INVARIANT();
|
|
171 |
}
|
|
172 |
|
|
173 |
CleanupStack::PopAndDestroy( buffer );
|
|
174 |
CleanupStack::PopAndDestroy( &array );
|
|
175 |
}
|
|
176 |
|
|
177 |
|
|
178 |
EXPORT_C TInt CAlfMesh::AnimationControllerCount() const
|
|
179 |
{
|
|
180 |
return DoAnimationControllerCount();
|
|
181 |
}
|
|
182 |
|
|
183 |
TInt CAlfMesh::DoAnimationControllerCount() const
|
|
184 |
{
|
|
185 |
TInt result = 0;
|
|
186 |
TPckg<TBool> outBuf( result );
|
|
187 |
|
|
188 |
TInt err = iData->iComms->DoSynchronousCmd(
|
|
189 |
EAlfMeshAnimationControllerCount,
|
|
190 |
KNullDesC8(),
|
|
191 |
outBuf );
|
|
192 |
|
|
193 |
if (err)
|
|
194 |
{
|
|
195 |
__ALFLOGSTRING1( "CAlfMesh::AnimationControllerCount panic error %d", err )
|
|
196 |
USER_INVARIANT();
|
|
197 |
}
|
|
198 |
|
|
199 |
return result;
|
|
200 |
}
|
|
201 |
|
|
202 |
EXPORT_C void CAlfMesh::SetAnimationPosition(TInt aControllerId, TReal32 aTarget, TInt aTime) __SOFTFP
|
|
203 |
{
|
|
204 |
TRAP_IGNORE(SetAnimationPositionL(aControllerId, aTarget, aTime))
|
|
205 |
}
|
|
206 |
|
|
207 |
void CAlfMesh::SetAnimationPositionL(TInt aControllerId, TReal32 aTarget, TInt aTime)
|
|
208 |
{
|
|
209 |
ASSERT(iData != NULL);
|
|
210 |
|
|
211 |
// Create input and output buffers for inter-process communication
|
|
212 |
TAlfMeshAnimationPositionParams params;
|
|
213 |
params.iControllerId = aControllerId;
|
|
214 |
params.iTarget = aTarget;
|
|
215 |
params.iTime = aTime;
|
|
216 |
|
|
217 |
TPckg<TAlfMeshAnimationPositionParams > paramsPckg(params);
|
|
218 |
|
|
219 |
// Call a synchronous command
|
|
220 |
TInt err = iData->iComms->DoCmdNoReply(EAlfMeshSetAnimationPosition, paramsPckg );
|
|
221 |
if (err)
|
|
222 |
{
|
|
223 |
__ALFLOGSTRING1( "CAlfM3GMesh::SetAnimationPosition leave error %d", err )
|
|
224 |
User::Leave( err );
|
|
225 |
}
|
|
226 |
}
|
|
227 |
|
|
228 |
EXPORT_C void CAlfMesh::StartAnimationController(TInt aControllerId)
|
|
229 |
{
|
|
230 |
TRAP_IGNORE(StartAnimationControllerL(aControllerId))
|
|
231 |
}
|
|
232 |
|
|
233 |
void CAlfMesh::StartAnimationControllerL(TInt aControllerId)
|
|
234 |
{
|
|
235 |
ASSERT(iData != NULL);
|
|
236 |
|
|
237 |
TBuf8<1> outDummy;
|
|
238 |
TInt params = aControllerId;
|
|
239 |
|
|
240 |
TPckg<TInt> paramsPckg(params);
|
|
241 |
|
|
242 |
// Call a synchronous command
|
|
243 |
TInt err = iData->iComms->DoSynchronousCmd(EAlfMeshStartAnimationController, paramsPckg, outDummy);
|
|
244 |
if (err)
|
|
245 |
{
|
|
246 |
__ALFLOGSTRING1( "CAlfM3GMesh::StartAnimationController leave error %d", err )
|
|
247 |
User::Leave( err );
|
|
248 |
}
|
|
249 |
}
|
|
250 |
|
|
251 |
EXPORT_C void CAlfMesh::StopAnimationController(TInt aControllerId)
|
|
252 |
{
|
|
253 |
TRAP_IGNORE(StopAnimationControllerL(aControllerId))
|
|
254 |
}
|
|
255 |
|
|
256 |
void CAlfMesh::StopAnimationControllerL(TInt aControllerId)
|
|
257 |
{
|
|
258 |
ASSERT(iData != NULL);
|
|
259 |
|
|
260 |
TBuf8<1> outDummy;
|
|
261 |
TInt params = aControllerId;
|
|
262 |
|
|
263 |
TPckg<TInt> paramsPckg(params);
|
|
264 |
|
|
265 |
// Call a synchronous command
|
|
266 |
TInt err = iData->iComms->DoSynchronousCmd(EAlfMeshStopAnimationController, paramsPckg, outDummy);
|
|
267 |
if (err)
|
|
268 |
{
|
|
269 |
__ALFLOGSTRING1( "CAlfM3GMesh::StopAnimationController leave error %d", err )
|
|
270 |
User::Leave( err );
|
|
271 |
}
|
|
272 |
}
|
|
273 |
|