1 /* 2 * Animation Controller operations specific to D3DX9. 3 * 4 * Copyright (C) 2015 Christian Costa 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21 #include "d3dx9_36_private.h" 22 23 struct d3dx9_animation_controller 24 { 25 ID3DXAnimationController ID3DXAnimationController_iface; 26 LONG ref; 27 28 UINT max_outputs; 29 UINT max_sets; 30 UINT max_tracks; 31 UINT max_events; 32 }; 33 34 static inline struct d3dx9_animation_controller *impl_from_ID3DXAnimationController(ID3DXAnimationController *iface) 35 { 36 return CONTAINING_RECORD(iface, struct d3dx9_animation_controller, ID3DXAnimationController_iface); 37 } 38 39 static HRESULT WINAPI d3dx9_animation_controller_QueryInterface(ID3DXAnimationController *iface, REFIID riid, void **out) 40 { 41 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); 42 43 if (IsEqualGUID(riid, &IID_IUnknown) || 44 IsEqualGUID(riid, &IID_ID3DXAnimationController)) 45 { 46 iface->lpVtbl->AddRef(iface); 47 *out = iface; 48 return D3D_OK; 49 } 50 51 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); 52 *out = NULL; 53 return E_NOINTERFACE; 54 } 55 56 static ULONG WINAPI d3dx9_animation_controller_AddRef(ID3DXAnimationController *iface) 57 { 58 struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface); 59 ULONG refcount = InterlockedIncrement(&animation->ref); 60 61 TRACE("%p increasing refcount to %u.\n", animation, refcount); 62 63 return refcount; 64 } 65 66 static ULONG WINAPI d3dx9_animation_controller_Release(ID3DXAnimationController *iface) 67 { 68 struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface); 69 ULONG refcount = InterlockedDecrement(&animation->ref); 70 71 TRACE("%p decreasing refcount to %u.\n", animation, refcount); 72 73 if (!refcount) 74 { 75 HeapFree(GetProcessHeap(), 0, animation); 76 } 77 78 return refcount; 79 } 80 81 static UINT WINAPI d3dx9_animation_controller_GetMaxNumAnimationOutputs(ID3DXAnimationController *iface) 82 { 83 struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface); 84 85 TRACE("iface %p.\n", iface); 86 87 return animation->max_outputs; 88 } 89 90 static UINT WINAPI d3dx9_animation_controller_GetMaxNumAnimationSets(ID3DXAnimationController *iface) 91 { 92 struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface); 93 94 TRACE("iface %p.\n", iface); 95 96 return animation->max_sets; 97 } 98 99 static UINT WINAPI d3dx9_animation_controller_GetMaxNumTracks(ID3DXAnimationController *iface) 100 { 101 struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface); 102 103 TRACE("iface %p.\n", iface); 104 105 return animation->max_tracks; 106 } 107 108 static UINT WINAPI d3dx9_animation_controller_GetMaxNumEvents(ID3DXAnimationController *iface) 109 { 110 struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface); 111 112 TRACE("iface %p.\n", iface); 113 114 return animation->max_events; 115 } 116 117 static HRESULT WINAPI d3dx9_animation_controller_RegisterAnimationOutput(ID3DXAnimationController *iface, 118 const char *name, D3DXMATRIX *matrix, D3DXVECTOR3 *scale, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation) 119 { 120 FIXME("iface %p, name %s, matrix %p, scale %p, rotation %p, translation %p stub.\n", iface, debugstr_a(name), 121 matrix, scale, rotation, translation); 122 123 return E_NOTIMPL; 124 } 125 126 static HRESULT WINAPI d3dx9_animation_controller_RegisterAnimationSet(ID3DXAnimationController *iface, 127 ID3DXAnimationSet *anim_set) 128 { 129 FIXME("iface %p, anim_set %p stub.\n", iface, anim_set); 130 131 return E_NOTIMPL; 132 } 133 134 static HRESULT WINAPI d3dx9_animation_controller_UnregisterAnimationSet(ID3DXAnimationController *iface, 135 ID3DXAnimationSet *anim_set) 136 { 137 FIXME("iface %p, anim_set %p stub.\n", iface, anim_set); 138 139 return E_NOTIMPL; 140 } 141 142 static UINT WINAPI d3dx9_animation_controller_GetNumAnimationSets(ID3DXAnimationController *iface) 143 { 144 FIXME("iface %p stub.\n", iface); 145 146 return 0; 147 } 148 149 static HRESULT WINAPI d3dx9_animation_controller_GetAnimationSet(ID3DXAnimationController *iface, 150 UINT index, ID3DXAnimationSet **anim_set) 151 { 152 FIXME("iface %p, index %u, anim_set %p stub.\n", iface, index, anim_set); 153 154 return E_NOTIMPL; 155 } 156 157 static HRESULT WINAPI d3dx9_animation_controller_GetAnimationSetByName(ID3DXAnimationController *iface, 158 const char *name, ID3DXAnimationSet **anim_set) 159 { 160 FIXME("iface %p, name %s, anim_set %p stub.\n", iface, debugstr_a(name), anim_set); 161 162 return E_NOTIMPL; 163 } 164 165 static HRESULT WINAPI d3dx9_animation_controller_AdvanceTime(ID3DXAnimationController *iface, double time_delta, 166 ID3DXAnimationCallbackHandler *callback_handler) 167 { 168 FIXME("iface %p, time_delta %.16e, callback_handler %p stub.\n", iface, time_delta, callback_handler); 169 170 return E_NOTIMPL; 171 } 172 173 static HRESULT WINAPI d3dx9_animation_controller_Reset(ID3DXAnimationController *iface) 174 { 175 FIXME("iface %p stub.\n", iface); 176 177 return E_NOTIMPL; 178 } 179 180 static double WINAPI d3dx9_animation_controller_GetTime(ID3DXAnimationController *iface) 181 { 182 FIXME("iface %p stub.\n", iface); 183 184 return 0.0; 185 } 186 187 static HRESULT WINAPI d3dx9_animation_controller_SetTrackAnimationSet(ID3DXAnimationController *iface, 188 UINT track, ID3DXAnimationSet *anim_set) 189 { 190 FIXME("iface %p, track %u, anim_set %p stub.\n", iface, track, anim_set); 191 192 return E_NOTIMPL; 193 } 194 195 static HRESULT WINAPI d3dx9_animation_controller_GetTrackAnimationSet(ID3DXAnimationController *iface, 196 UINT track, ID3DXAnimationSet **anim_set) 197 { 198 FIXME("iface %p, track %u, anim_set %p stub.\n", iface, track, anim_set); 199 200 return E_NOTIMPL; 201 } 202 203 static HRESULT WINAPI d3dx9_animation_controller_SetTrackPriority(ID3DXAnimationController *iface, 204 UINT track, D3DXPRIORITY_TYPE priority) 205 { 206 FIXME("iface %p, track %u, priority %u stub.\n", iface, track, priority); 207 208 return E_NOTIMPL; 209 } 210 211 static HRESULT WINAPI d3dx9_animation_controller_SetTrackSpeed(ID3DXAnimationController *iface, 212 UINT track, float speed) 213 { 214 FIXME("iface %p, track %u, speed %.8e stub.\n", iface, track, speed); 215 216 return E_NOTIMPL; 217 } 218 219 static HRESULT WINAPI d3dx9_animation_controller_SetTrackWeight(ID3DXAnimationController *iface, 220 UINT track, float weight) 221 { 222 FIXME("iface %p, track %u, weight %.8e stub.\n", iface, track, weight); 223 224 return E_NOTIMPL; 225 } 226 227 static HRESULT WINAPI d3dx9_animation_controller_SetTrackPosition(ID3DXAnimationController *iface, 228 UINT track, double position) 229 { 230 FIXME("iface %p, track %u, position %.16e stub.\n", iface, track, position); 231 232 return E_NOTIMPL; 233 } 234 235 static HRESULT WINAPI d3dx9_animation_controller_SetTrackEnable(ID3DXAnimationController *iface, 236 UINT track, BOOL enable) 237 { 238 FIXME("iface %p, track %u, enable %#x stub.\n", iface, track, enable); 239 240 return E_NOTIMPL; 241 } 242 243 static HRESULT WINAPI d3dx9_animation_controller_SetTrackDesc(ID3DXAnimationController *iface, 244 UINT track, D3DXTRACK_DESC *desc) 245 { 246 FIXME("iface %p, track %u, desc %p stub.\n", iface, track, desc); 247 248 return E_NOTIMPL; 249 } 250 251 static HRESULT WINAPI d3dx9_animation_controller_GetTrackDesc(ID3DXAnimationController *iface, 252 UINT track, D3DXTRACK_DESC *desc) 253 { 254 FIXME("iface %p, track %u, desc %p stub.\n", iface, track, desc); 255 256 return E_NOTIMPL; 257 } 258 259 static HRESULT WINAPI d3dx9_animation_controller_SetPriorityBlend(ID3DXAnimationController *iface, 260 float blend_weight) 261 { 262 FIXME("iface %p, blend_weight %.8e stub.\n", iface, blend_weight); 263 264 return E_NOTIMPL; 265 } 266 267 static float WINAPI d3dx9_animation_controller_GetPriorityBlend(ID3DXAnimationController *iface) 268 { 269 FIXME("iface %p stub.\n", iface); 270 271 return 0.0f; 272 } 273 274 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackSpeed(ID3DXAnimationController *iface, 275 UINT track, float new_speed, double start_time, double duration, D3DXTRANSITION_TYPE transition) 276 { 277 FIXME("iface %p, track %u, new_speed %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface, 278 track, new_speed, start_time, duration, transition); 279 280 return 0; 281 } 282 283 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackWeight(ID3DXAnimationController *iface, 284 UINT track, float new_weight, double start_time, double duration, D3DXTRANSITION_TYPE transition) 285 { 286 FIXME("iface %p, track %u, new_weight %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface, 287 track, new_weight, start_time, duration, transition); 288 289 return 0; 290 } 291 292 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackPosition(ID3DXAnimationController *iface, 293 UINT track, double new_position, double start_time) 294 { 295 FIXME("iface %p, track %u, new_position %.16e, start_time %.16e stub.\n", iface, 296 track, new_position, start_time); 297 298 return 0; 299 } 300 301 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackEnable(ID3DXAnimationController *iface, 302 UINT track, BOOL new_enable, double start_time) 303 { 304 FIXME("iface %p, track %u, new_enable %#x, start_time %.16e stub.\n", iface, 305 track, new_enable, start_time); 306 307 return 0; 308 } 309 310 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackBlend(ID3DXAnimationController *iface, 311 float new_blend_weight, double start_time, double duration, D3DXTRANSITION_TYPE transition) 312 { 313 FIXME("iface %p, new_blend_weight %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface, 314 new_blend_weight, start_time, duration, transition); 315 316 return 0; 317 } 318 319 static HRESULT WINAPI d3dx9_animation_controller_UnkeyEvent(ID3DXAnimationController *iface, D3DXEVENTHANDLE event) 320 { 321 FIXME("iface %p, event %u stub.\n", iface, event); 322 323 return E_NOTIMPL; 324 } 325 326 static HRESULT WINAPI d3dx9_animation_controller_UnkeyAllTrackEvents(ID3DXAnimationController *iface, UINT track) 327 { 328 FIXME("iface %p, track %u stub.\n", iface, track); 329 330 return E_NOTIMPL; 331 } 332 333 static HRESULT WINAPI d3dx9_animation_controller_UnkeyAllPriorityBlends(ID3DXAnimationController *iface) 334 { 335 FIXME("iface %p stub.\n", iface); 336 337 return E_NOTIMPL; 338 } 339 340 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetCurrentTrackEvent(ID3DXAnimationController *iface, 341 UINT track, D3DXEVENT_TYPE event_type) 342 { 343 FIXME("iface %p, track %u, event_type %u stub.\n", iface, track, event_type); 344 345 return 0; 346 } 347 348 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetCurrentPriorityBlend(ID3DXAnimationController *iface) 349 { 350 FIXME("iface %p stub.\n", iface); 351 352 return 0; 353 } 354 355 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetUpcomingTrackEvent(ID3DXAnimationController *iface, 356 UINT track, D3DXEVENTHANDLE event) 357 { 358 FIXME("iface %p, track %u, event %u stub.\n", iface, track, event); 359 360 return 0; 361 } 362 363 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetUpcomingPriorityBlend(ID3DXAnimationController *iface, 364 D3DXEVENTHANDLE event) 365 { 366 FIXME("iface %p, event %u stub.\n", iface, event); 367 368 return 0; 369 } 370 371 static HRESULT WINAPI d3dx9_animation_controller_ValidateEvent(ID3DXAnimationController *iface, D3DXEVENTHANDLE event) 372 { 373 FIXME("iface %p, event %u stub.\n", iface, event); 374 375 return E_NOTIMPL; 376 } 377 378 static HRESULT WINAPI d3dx9_animation_controller_GetEventDesc(ID3DXAnimationController *iface, 379 D3DXEVENTHANDLE event, D3DXEVENT_DESC *desc) 380 { 381 FIXME("iface %p, event %u, desc %p stub.\n", iface, event, desc); 382 383 return E_NOTIMPL; 384 } 385 386 static HRESULT WINAPI d3dx9_animation_controller_CloneAnimationController(ID3DXAnimationController *iface, UINT max_outputs, 387 UINT max_sets, UINT max_tracks, UINT max_events, ID3DXAnimationController **anim_controller) 388 { 389 FIXME("iface %p, max_outputs %u, max_sets %u, max_tracks %u, max_events %u, anim_controller %p stub.\n", 390 iface, max_outputs, max_sets, max_tracks, max_events, anim_controller); 391 392 return E_NOTIMPL; 393 } 394 395 static /* const */ struct ID3DXAnimationControllerVtbl d3dx9_animation_controller_vtbl = 396 { 397 d3dx9_animation_controller_QueryInterface, 398 d3dx9_animation_controller_AddRef, 399 d3dx9_animation_controller_Release, 400 d3dx9_animation_controller_GetMaxNumAnimationOutputs, 401 d3dx9_animation_controller_GetMaxNumAnimationSets, 402 d3dx9_animation_controller_GetMaxNumTracks, 403 d3dx9_animation_controller_GetMaxNumEvents, 404 d3dx9_animation_controller_RegisterAnimationOutput, 405 d3dx9_animation_controller_RegisterAnimationSet, 406 d3dx9_animation_controller_UnregisterAnimationSet, 407 d3dx9_animation_controller_GetNumAnimationSets, 408 d3dx9_animation_controller_GetAnimationSet, 409 d3dx9_animation_controller_GetAnimationSetByName, 410 d3dx9_animation_controller_AdvanceTime, 411 d3dx9_animation_controller_Reset, 412 d3dx9_animation_controller_GetTime, 413 d3dx9_animation_controller_SetTrackAnimationSet, 414 d3dx9_animation_controller_GetTrackAnimationSet, 415 d3dx9_animation_controller_SetTrackPriority, 416 d3dx9_animation_controller_SetTrackSpeed, 417 d3dx9_animation_controller_SetTrackWeight, 418 d3dx9_animation_controller_SetTrackPosition, 419 d3dx9_animation_controller_SetTrackEnable, 420 d3dx9_animation_controller_SetTrackDesc, 421 d3dx9_animation_controller_GetTrackDesc, 422 d3dx9_animation_controller_SetPriorityBlend, 423 d3dx9_animation_controller_GetPriorityBlend, 424 d3dx9_animation_controller_KeyTrackSpeed, 425 d3dx9_animation_controller_KeyTrackWeight, 426 d3dx9_animation_controller_KeyTrackPosition, 427 d3dx9_animation_controller_KeyTrackEnable, 428 d3dx9_animation_controller_KeyTrackBlend, 429 d3dx9_animation_controller_UnkeyEvent, 430 d3dx9_animation_controller_UnkeyAllTrackEvents, 431 d3dx9_animation_controller_UnkeyAllPriorityBlends, 432 d3dx9_animation_controller_GetCurrentTrackEvent, 433 d3dx9_animation_controller_GetCurrentPriorityBlend, 434 d3dx9_animation_controller_GetUpcomingTrackEvent, 435 d3dx9_animation_controller_GetUpcomingPriorityBlend, 436 d3dx9_animation_controller_ValidateEvent, 437 d3dx9_animation_controller_GetEventDesc, 438 d3dx9_animation_controller_CloneAnimationController 439 }; 440 441 HRESULT WINAPI D3DXCreateAnimationController(UINT max_outputs, UINT max_sets, 442 UINT max_tracks, UINT max_events, ID3DXAnimationController **controller) 443 { 444 struct d3dx9_animation_controller *object; 445 446 TRACE("max_outputs %u, max_sets %u, max_tracks %u, max_events %u, controller %p.\n", 447 max_outputs, max_sets, max_tracks, max_events, controller); 448 449 if (!max_outputs || !max_sets || !max_tracks || !max_events || !controller) 450 return D3D_OK; 451 452 object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object)); 453 if (!object) 454 return E_OUTOFMEMORY; 455 456 object->ID3DXAnimationController_iface.lpVtbl = &d3dx9_animation_controller_vtbl; 457 object->ref = 1; 458 object->max_outputs = max_outputs; 459 object->max_sets = max_sets; 460 object->max_tracks = max_tracks; 461 object->max_events = max_events; 462 463 *controller = &object->ID3DXAnimationController_iface; 464 465 return D3D_OK; 466 } 467