@@ -23,6 +23,8 @@ CubismModel::CubismModel(Core::csmModel* model)
2323 , _parameterMaximumValues(NULL )
2424 , _parameterMinimumValues(NULL )
2525 , _partOpacities(NULL )
26+ , _isOverwrittenModelMultiplyColors(false )
27+ , _isOverwrittenModelScreenColors(false )
2628{ }
2729
2830CubismModel::~CubismModel ()
@@ -386,9 +388,34 @@ void CubismModel::Initialize()
386388 const csmInt32 drawableCount = Core::csmGetDrawableCount (_model);
387389
388390 _drawableIds.PrepareCapacity (drawableCount);
391+ _userMultiplyColors.PrepareCapacity (drawableCount);
392+ _userScreenColors.PrepareCapacity (drawableCount);
393+
394+ // 乗算色
395+ Rendering::CubismRenderer::CubismTextureColor multiplyColor;
396+ multiplyColor.R = 1 .0f ;
397+ multiplyColor.G = 1 .0f ;
398+ multiplyColor.B = 1 .0f ;
399+ multiplyColor.A = 1 .0f ;
400+ DrawableColorData userMultiplyColor;
401+ userMultiplyColor.IsOverwritten = false ;
402+ userMultiplyColor.Color = multiplyColor;
403+
404+ // スクリーン色
405+ Rendering::CubismRenderer::CubismTextureColor screenColor;
406+ screenColor.R = 0 .0f ;
407+ screenColor.G = 0 .0f ;
408+ screenColor.B = 0 .0f ;
409+ screenColor.A = 1 .0f ;
410+ DrawableColorData userScreenColor;
411+ userScreenColor.IsOverwritten = false ;
412+ userScreenColor.Color = screenColor;
413+
389414 for (csmInt32 i = 0 ; i < drawableCount; ++i)
390415 {
391416 _drawableIds.PushBack (CubismFramework::GetIdManager ()->GetId (drawableIds[i]));
417+ _userMultiplyColors.PushBack (userMultiplyColor);
418+ _userScreenColors.PushBack (userScreenColor);
392419 }
393420 }
394421}
@@ -459,6 +486,18 @@ csmFloat32 CubismModel::GetDrawableOpacity(csmInt32 drawableIndex) const
459486 return opacities[drawableIndex];
460487}
461488
489+ Core::csmVector4 CubismModel::GetDrawableMultiplyColor (csmInt32 drawableIndex) const
490+ {
491+ const Core::csmVector4* multiplyColors = Core::csmGetDrawableMultiplyColors (_model);
492+ return multiplyColors[drawableIndex];
493+ }
494+
495+ Core::csmVector4 CubismModel::GetDrawableScreenColor (csmInt32 drawableIndex) const
496+ {
497+ const Core::csmVector4* screenColors = Core::csmGetDrawableScreenColors (_model);
498+ return screenColors[drawableIndex];
499+ }
500+
462501csmInt32 CubismModel::GetDrawableCulling (csmInt32 drawableIndex) const
463502{
464503 const Core::csmFlags* constantFlags = Core::csmGetDrawableConstantFlags (_model);
@@ -501,6 +540,11 @@ csmBool CubismModel::GetDrawableDynamicFlagVertexPositionsDidChange(csmInt32 dra
501540 return IsBitSet (dynamicFlags[drawableIndex], Core::csmVertexPositionsDidChange) != 0 ? true : false ;
502541}
503542
543+ csmBool CubismModel::GetDrawableDynamicFlagBlendColorDidChange (csmInt32 drawableIndex) const
544+ {
545+ const Core::csmFlags* dynamicFlags = Core::csmGetDrawableDynamicFlags (_model);
546+ return IsBitSet (dynamicFlags[drawableIndex], Core::csmBlendColorDidChange) != 0 ? true : false ;
547+ }
504548
505549Rendering::CubismRenderer::CubismBlendMode CubismModel::GetDrawableBlendMode (csmInt32 drawableIndex) const
506550{
@@ -564,6 +608,95 @@ void CubismModel::SaveParameters()
564608 }
565609}
566610
611+ Rendering::CubismRenderer::CubismTextureColor CubismModel::GetMultiplyColor (csmInt32 drawableIndex) const
612+ {
613+ if (GetOverwriteFlagForModelMultiplyColors () || GetOverwriteFlagForDrawableMultiplyColors (drawableIndex))
614+ {
615+ return _userMultiplyColors[drawableIndex].Color ;
616+ }
617+
618+ const Core::csmVector4 color = GetDrawableMultiplyColor (drawableIndex);
619+
620+ return Rendering::CubismRenderer::CubismTextureColor (color.X , color.Y , color.Z , color.W );
621+ }
622+
623+ Rendering::CubismRenderer::CubismTextureColor CubismModel::GetScreenColor (csmInt32 drawableIndex) const
624+ {
625+ if (GetOverwriteFlagForModelScreenColors () || GetOverwriteFlagForDrawableScreenColors (drawableIndex))
626+ {
627+ return _userScreenColors[drawableIndex].Color ;
628+ }
629+
630+ const Core::csmVector4 color = GetDrawableScreenColor (drawableIndex);
631+ return Rendering::CubismRenderer::CubismTextureColor (color.X , color.Y , color.Z , color.W );
632+ }
633+
634+ void CubismModel::SetMultiplyColor (csmInt32 drawableIndex, const Rendering::CubismRenderer::CubismTextureColor& color)
635+ {
636+ SetMultiplyColor (drawableIndex, color.R , color.G , color.B , color.A );
637+ }
638+
639+ void CubismModel::SetMultiplyColor (csmInt32 drawableIndex, csmFloat32 r, csmFloat32 g, csmFloat32 b, csmFloat32 a)
640+ {
641+ _userMultiplyColors[drawableIndex].Color .R = r;
642+ _userMultiplyColors[drawableIndex].Color .G = g;
643+ _userMultiplyColors[drawableIndex].Color .B = b;
644+ _userMultiplyColors[drawableIndex].Color .A = a;
645+ }
646+
647+ void CubismModel::SetScreenColor (csmInt32 drawableIndex, const Rendering::CubismRenderer::CubismTextureColor& color)
648+ {
649+ SetScreenColor (drawableIndex, color.R , color.G , color.B , color.A );
650+ }
651+
652+ void CubismModel::SetScreenColor (csmInt32 drawableIndex, csmFloat32 r, csmFloat32 g, csmFloat32 b, csmFloat32 a)
653+ {
654+ _userScreenColors[drawableIndex].Color .R = r;
655+ _userScreenColors[drawableIndex].Color .G = g;
656+ _userScreenColors[drawableIndex].Color .B = b;
657+ _userScreenColors[drawableIndex].Color .A = a;
658+ }
659+
660+ csmBool CubismModel::GetOverwriteFlagForModelMultiplyColors () const
661+ {
662+ return _isOverwrittenModelMultiplyColors;
663+ }
664+
665+ csmBool CubismModel::GetOverwriteFlagForModelScreenColors () const
666+ {
667+ return _isOverwrittenModelScreenColors;
668+ }
669+
670+ void CubismModel::SetOverwriteFlagForModelMultiplyColors (csmBool value)
671+ {
672+ _isOverwrittenModelMultiplyColors = value;
673+ }
674+
675+ void CubismModel::SetOverwriteFlagForModelScreenColors (csmBool value)
676+ {
677+ _isOverwrittenModelScreenColors = value;
678+ }
679+
680+ csmBool CubismModel::GetOverwriteFlagForDrawableMultiplyColors (csmInt32 drawableIndex) const
681+ {
682+ return _userMultiplyColors[drawableIndex].IsOverwritten ;
683+ }
684+
685+ csmBool CubismModel::GetOverwriteFlagForDrawableScreenColors (csmInt32 drawableIndex) const
686+ {
687+ return _userScreenColors[drawableIndex].IsOverwritten ;
688+ }
689+
690+ void CubismModel::SetOverwriteFlagForDrawableMultiplyColors (csmUint32 drawableIndex, csmBool value)
691+ {
692+ _userMultiplyColors[drawableIndex].IsOverwritten = value;
693+ }
694+
695+ void CubismModel::SetOverwriteFlagForDrawableScreenColors (csmUint32 drawableIndex, csmBool value)
696+ {
697+ _userScreenColors[drawableIndex].IsOverwritten = value;
698+ }
699+
567700Core::csmModel* CubismModel::GetModel () const
568701{
569702 return _model;
0 commit comments