wavelength 1.0.0
Loading...
Searching...
No Matches
avatar.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "game/avatarpart.h"
7#include "math/rect.h"
8#include "rnd/rndcam.h"
9#include "rnd/rndloader.h"
10#include "rnd/rndtex.h"
11#include "rnd/rndview.h"
12#include "script/dataarray.h"
13
14class AvatarPartSet;
15
24class Avatar {
25public:
27 static constexpr float kNever = 1.0e7f;
28
34 class Anim {
35 public:
48 void Set(const char *pszAnim, int nKey);
49
59 float Frame() const;
60
68 bool IsDone() const;
69
71 const char *GetAnim() const {
72 return mAnim;
73 }
74
80 void SetAnim(const char *pszAnim) {
81 mAnim = pszAnim;
82 }
83
85 int GetLoop() const {
86 return mLoop;
87 }
88
89 private:
90 const char *mAnim;
91 int mLoop;
92 float mStart;
93 float mEnd;
94 float mOffset;
95 };
96
104 explicit Avatar(int nIndex);
105
113
120 static void Init();
121
130 static void Terminate();
131
139 static int NumAvatars();
140
149 static Avatar *GetAvatar(int nIndex);
150
161 static void Poll(float fTime);
162
171 static void DrawCamera();
172
183 static void GetDepthRange(float *pfNear, float *pfFar);
184
195 static void SetDepthRange(float fNear, float fFar);
196
207 static void SetViewAngles(float fTilt, float fTurn);
208
220 static void SetFreqSize(int nFreqSize, bool bSnap);
221
231 static bool IsShown();
232
243 static void SetCamera(const char *pszCam);
244
254 static void SnapCamera(const char *pszCam);
255
266 void SetPose(const char *pszPose, bool bImmediate);
267
279 void SetBaseAnim(const char *pszAnim, bool bOneShot, bool bImmediate);
280
289 void Reset();
290
299 AvatarPart *GetPart(int nPart);
300
311 void Draw(const Rect *pScreenRect);
312
323 void CatchGem(int nKey, int bRestartPose);
324
332 void SetUser(AvatarPartSet *pUser);
333
335 int GetIndex() const {
336 return mIndex;
337 }
338
341 return mUser;
342 }
343
345 static const char *GetNone() {
346 return sNone;
347 }
348
351 return sTargetTex;
352 }
353
354private:
355 std::vector<std::unique_ptr<AvatarPart>> mParts;
356 int mIndex;
357 AvatarPartSet *mUser;
358 Anim mBody;
359 Anim mPrevBody;
360 int mOneShot;
361 float mBodyBlendStart;
362 Anim mPoseAnim;
363 Anim mPrevPoseAnim;
364 float mPoseBlendStart;
365 const char *mPose;
366 const char *mPrevPose;
367 float mPoseChangeTime;
368 float mActiveTime;
369
375 static float sAnimBlend;
376
382 static float sTimeToIdle;
383
389 static float sFov;
390
396 static float sCamBlend;
397
404 static std::unique_ptr<RndLoader> sLoader;
405
412 static RndTex *sTargetTex;
413
420 static RndView *sView;
421
428 static const char *sNone;
429
436 static const char *sIdle;
437
444 static DataArray *sCams;
445
452 static RndCam *sCam;
453
460 static const char *sCurrentCam;
461
468 static const char *sPreviousCam;
469
476 static float sCamBlendStart;
477
484 static int sFreqSize;
485
492 static float sTime;
493
500 static DataArray *sAnims;
501
507 static std::vector<std::unique_ptr<Avatar>> sAvatars;
517 void UpdateInstrument();
518
532 void
533 SetPartFrames(const Anim *pFrom, const Anim *pTo, float *pfBlendStart, int nFirst, int nEnd);
534};
Parts and colours of a player's avatar, the Freq the Freq maker edits.
Definition avatarpartset.h:23
The model of one part of an avatar that an Avatar draws.
Definition avatarpart.h:29
The position in one of the anims of the avatar entry of the "db" section.
Definition avatar.h:34
void Set(const char *pszAnim, int nKey)
Start an animation.
int GetLoop() const
Definition avatar.h:85
float Frame() const
Report the frame at Avatar::sTime.
void SetAnim(const char *pszAnim)
Set only the animation, without a frame range.
Definition avatar.h:80
bool IsDone() const
Report whether an animation that does not loop has passed its last frame.
const char * GetAnim() const
Definition avatar.h:71
~Avatar()
Delete the part models.
void SetBaseAnim(const char *pszAnim, bool bOneShot, bool bImmediate)
Change the body animation.
static void SnapCamera(const char *pszCam)
Move the shared camera to one of the cams at once, with no blend.
static void GetDepthRange(float *pfNear, float *pfFar)
Report the depth range the shared camera draws into.
static void Init()
Read the avatar entry of the "db" section, load the base model, and build the avatars.
static void SetDepthRange(float fNear, float fFar)
Set the depth range the shared camera draws into.
static RndTex * GetTargetTex()
Definition avatar.h:350
static int NumAvatars()
Report the number of avatars.
static constexpr float kNever
The time a blend that never started or already ended records.
Definition avatar.h:27
int GetIndex() const
Definition avatar.h:335
static Avatar * GetAvatar(int nIndex)
Report an avatar.
void SetUser(AvatarPartSet *pUser)
Set mUser.
static void SetViewAngles(float fTilt, float fTurn)
Turn the avatars in front of the shared camera.
void SetPose(const char *pszPose, bool bImmediate)
Change the pose, and with it the model of the instrument.
void CatchGem(int nKey, int bRestartPose)
React to a gem the player of the avatar caught.
Avatar(int nIndex)
Build an avatar and its part models.
AvatarPart * GetPart(int nPart)
Report the model of a part.
static void DrawCamera()
Draw the shared camera alone, and restore the current camera and environment.
void Reset()
Return to the idle animation with no pose.
static void SetCamera(const char *pszCam)
Blend the shared camera to one of the cams, unless it already heads there.
void Draw(const Rect *pScreenRect)
Pose the part models at sTime and draw them with the shared camera.
static bool IsShown()
Report whether the avatar display is shown at all.
static void Poll(float fTime)
Advance every avatar to a time.
static void Terminate()
Delete the avatars and the loader of the base model.
static void SetFreqSize(int nFreqSize, bool bSnap)
Choose the camera for a size of the avatar display.
AvatarPartSet * GetUser()
Definition avatar.h:340
static const char * GetNone()
Definition avatar.h:345
Reference-counted array of script data nodes.
Definition dataarray.h:20
Camera.
Definition rndcam.h:23
Texture, a bitmap loaded from a file or rendered to.
Definition rndtex.h:17
View that shows the children of another view, its children owner, under its own transform and frame.
Definition rndview.h:27
Axis-aligned rectangle given by a corner and a size.
Definition rect.h:11