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