1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: gfx_StandardSkeleton.cpp
4
5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Revision: 25358 $
14 *---------------------------------------------------------------------------*/
15
16 #include "precompiled.h"
17
18 #include <nw/gfx/gfx_StandardSkeleton.h>
19
20 #include <nw/ut/ut_ResUtil.h>
21 #include <nw/ut/ut_ResDictionary.h>
22
23 namespace nw
24 {
25 namespace gfx
26 {
27
28 NW_UT_RUNTIME_TYPEINFO_DEFINITION(StandardSkeleton, Skeleton);
29
30 //----------------------------------------
31 StandardSkeleton*
Create(ResSkeleton resource,int maxCallbacks,bool isFixedSizeMemory,Skeleton::TransformPose::TransformArray poseTransforms,os::IAllocator * allocator)32 StandardSkeleton::Create(
33 ResSkeleton resource,
34 int maxCallbacks,
35 bool isFixedSizeMemory,
36 Skeleton::TransformPose::TransformArray poseTransforms,
37 os::IAllocator* allocator
38 )
39 {
40 NW_NULL_ASSERT(allocator);
41 NW_ASSERT(resource.IsValid());
42
43 void* memory = allocator->Alloc(sizeof(StandardSkeleton));
44 NW_NULL_ASSERT(memory);
45 Skeleton::TransformPose::TransformArray poseWorldTransforms(resource.GetBonesCount(), allocator);
46 Skeleton::MatrixPose::MatrixArray poseWorldMatrices(resource.GetBonesCount(), allocator);
47 Skeleton::MatrixPose::MatrixArray skiningMatrices(resource.GetBonesCount(), allocator);
48
49 for (int i = 0; i < resource.GetBonesCount(); ++i)
50 {
51 poseWorldTransforms.PushBackFast(nw::gfx::CalculatedTransform::Identity());
52 poseWorldMatrices.PushBackFast(math::MTX34::Identity());
53 skiningMatrices.PushBackFast(math::MTX34::Identity());
54 }
55
56 StandardSkeleton* skeleton = new(memory) StandardSkeleton(
57 allocator,
58 resource,
59 maxCallbacks,
60 isFixedSizeMemory,
61 poseTransforms,
62 poseWorldTransforms,
63 poseWorldMatrices,
64 skiningMatrices);
65
66 return skeleton;
67 }
68
69 } // namespace gfx
70 } // namespace nw
71