@@ -26,6 +26,7 @@ CubismModel::CubismModel(Core::csmModel* model)
2626 , _isOverwrittenModelMultiplyColors(false )
2727 , _isOverwrittenModelScreenColors(false )
2828 , _isOverwrittenCullings(false )
29+ , _modelOpacity(1 .0f )
2930{ }
3031
3132CubismModel::~CubismModel ()
@@ -378,15 +379,19 @@ void CubismModel::Initialize()
378379 }
379380 }
380381
382+ const csmInt32 partCount = Core::csmGetPartCount (_model);
381383 {
382384 const csmChar** partIds = Core::csmGetPartIds (_model);
383- const csmInt32 partCount = Core::csmGetPartCount (_model);
384385
385386 _partIds.PrepareCapacity (partCount);
386387 for (csmInt32 i = 0 ; i < partCount; ++i)
387388 {
388389 _partIds.PushBack (CubismFramework::GetIdManager ()->GetId (partIds[i]));
389390 }
391+
392+ _userPartMultiplyColors.PrepareCapacity (partCount);
393+ _userPartScreenColors.PrepareCapacity (partCount);
394+ _partChildDrawables.Resize (partCount);
390395 }
391396
392397 {
@@ -398,38 +403,69 @@ void CubismModel::Initialize()
398403 _userScreenColors.PrepareCapacity (drawableCount);
399404 _userCullings.PrepareCapacity (drawableCount);
400405
406+ // カリング設定
407+ DrawableCullingData userCulling;
408+ userCulling.IsOverwritten = false ;
409+ userCulling.IsCulling = 0 ;
410+
401411 // 乗算色
402412 Rendering::CubismRenderer::CubismTextureColor multiplyColor;
403413 multiplyColor.R = 1 .0f ;
404414 multiplyColor.G = 1 .0f ;
405415 multiplyColor.B = 1 .0f ;
406416 multiplyColor.A = 1 .0f ;
407- DrawableColorData userMultiplyColor;
408- userMultiplyColor.IsOverwritten = false ;
409- userMultiplyColor.Color = multiplyColor;
410417
411418 // スクリーン色
412419 Rendering::CubismRenderer::CubismTextureColor screenColor;
413420 screenColor.R = 0 .0f ;
414421 screenColor.G = 0 .0f ;
415422 screenColor.B = 0 .0f ;
416423 screenColor.A = 1 .0f ;
417- DrawableColorData userScreenColor;
418- userScreenColor.IsOverwritten = false ;
419- userScreenColor.Color = screenColor;
420-
421- // カリング設定
422- DrawableCullingData userCulling;
423- userCulling.IsOverwritten = false ;
424- userCulling.IsCulling = 0 ;
425424
425+ // Parts
426+ {
427+ // 乗算色
428+ PartColorData userMultiplyColor;
429+ userMultiplyColor.IsOverwritten = false ;
430+ userMultiplyColor.Color = multiplyColor;
431+
432+ // スクリーン色
433+ PartColorData userScreenColor;
434+ userScreenColor.IsOverwritten = false ;
435+ userScreenColor.Color = screenColor;
436+
437+ for (csmInt32 i = 0 ; i < partCount; ++i)
438+ {
439+ _userPartMultiplyColors.PushBack (userMultiplyColor);
440+ _userPartScreenColors.PushBack (userScreenColor);
441+ }
442+ }
426443
427- for (csmInt32 i = 0 ; i < drawableCount; ++i)
444+ // Drawables
428445 {
429- _drawableIds.PushBack (CubismFramework::GetIdManager ()->GetId (drawableIds[i]));
430- _userMultiplyColors.PushBack (userMultiplyColor);
431- _userScreenColors.PushBack (userScreenColor);
432- _userCullings.PushBack (userCulling);
446+ // 乗算色
447+ DrawableColorData userMultiplyColor;
448+ userMultiplyColor.IsOverwritten = false ;
449+ userMultiplyColor.Color = multiplyColor;
450+
451+ // スクリーン色
452+ DrawableColorData userScreenColor;
453+ userScreenColor.IsOverwritten = false ;
454+ userScreenColor.Color = screenColor;
455+
456+ for (csmInt32 i = 0 ; i < drawableCount; ++i)
457+ {
458+ _drawableIds.PushBack (CubismFramework::GetIdManager ()->GetId (drawableIds[i]));
459+ _userMultiplyColors.PushBack (userMultiplyColor);
460+ _userScreenColors.PushBack (userScreenColor);
461+ _userCullings.PushBack (userCulling);
462+
463+ csmInt32 parentIndex = Core::csmGetDrawableParentPartIndices (_model)[i];
464+ if (parentIndex >= 0 )
465+ {
466+ _partChildDrawables[parentIndex].PushBack (i);
467+ }
468+ }
433469 }
434470 }
435471}
@@ -440,6 +476,12 @@ CubismIdHandle CubismModel::GetDrawableId(csmInt32 drawableIndex) const
440476 return CubismFramework::GetIdManager ()->GetId (parameterIds[drawableIndex]);
441477}
442478
479+ CubismIdHandle CubismModel::GetPartId (csmUint32 partIndex)
480+ {
481+ const csmChar** partIds = Core::csmGetPartIds (_model);
482+ return CubismFramework::GetIdManager ()->GetId (partIds[partIndex]);
483+ }
484+
443485csmInt32 CubismModel::GetPartCount () const
444486{
445487 const csmInt32 partCount = Core::csmGetPartCount (_model);
@@ -675,6 +717,60 @@ void CubismModel::SetScreenColor(csmInt32 drawableIndex, csmFloat32 r, csmFloat3
675717 _userScreenColors[drawableIndex].Color .A = a;
676718}
677719
720+ Rendering::CubismRenderer::CubismTextureColor CubismModel::GetPartMultiplyColor (csmInt32 partIndex) const
721+ {
722+ return _userPartMultiplyColors[partIndex].Color ;
723+ }
724+
725+ Rendering::CubismRenderer::CubismTextureColor CubismModel::GetPartScreenColor (csmInt32 partIndex) const
726+ {
727+ return _userPartScreenColors[partIndex].Color ;
728+ }
729+
730+ void CubismModel::SetPartMultiplyColor (csmInt32 partIndex, const Rendering::CubismRenderer::CubismTextureColor& color)
731+ {
732+ SetPartMultiplyColor (partIndex, color.R , color.G , color.B , color.A );
733+ }
734+
735+ void CubismModel::SetPartColor (
736+ csmUint32 partIndex,
737+ csmFloat32 r, csmFloat32 g, csmFloat32 b, csmFloat32 a,
738+ csmVector<PartColorData>& partColors,
739+ csmVector <DrawableColorData>& drawableColors)
740+ {
741+ partColors[partIndex].Color .R = r;
742+ partColors[partIndex].Color .G = g;
743+ partColors[partIndex].Color .B = b;
744+ partColors[partIndex].Color .A = a;
745+
746+ if (partColors[partIndex].IsOverwritten )
747+ {
748+ for (csmUint32 i = 0 ; i < _partChildDrawables[partIndex].GetSize (); i++)
749+ {
750+ csmUint32 drawableIndex = _partChildDrawables[partIndex][i];
751+ drawableColors[drawableIndex].Color .R = r;
752+ drawableColors[drawableIndex].Color .G = g;
753+ drawableColors[drawableIndex].Color .B = b;
754+ drawableColors[drawableIndex].Color .A = a;
755+ }
756+ }
757+ }
758+
759+ void CubismModel::SetPartMultiplyColor (csmInt32 partIndex, csmFloat32 r, csmFloat32 g, csmFloat32 b, csmFloat32 a)
760+ {
761+ SetPartColor (partIndex, r, g, b, a, _userPartMultiplyColors, _userMultiplyColors);
762+ }
763+
764+ void CubismModel::SetPartScreenColor (csmInt32 partIndex, const Rendering::CubismRenderer::CubismTextureColor& color)
765+ {
766+ SetPartScreenColor (partIndex, color.R , color.G , color.B , color.A );
767+ }
768+
769+ void CubismModel::SetPartScreenColor (csmInt32 partIndex, csmFloat32 r, csmFloat32 g, csmFloat32 b, csmFloat32 a)
770+ {
771+ SetPartColor (partIndex, r, g, b, a, _userPartScreenColors, _userScreenColors);
772+ }
773+
678774csmBool CubismModel::GetOverwriteFlagForModelMultiplyColors () const
679775{
680776 return _isOverwrittenModelMultiplyColors;
@@ -715,6 +811,50 @@ void CubismModel::SetOverwriteFlagForDrawableScreenColors(csmUint32 drawableInde
715811 _userScreenColors[drawableIndex].IsOverwritten = value;
716812}
717813
814+ csmBool CubismModel::GetOverwriteColorForPartMultiplyColors (csmInt32 partIndex) const
815+ {
816+ return _userPartMultiplyColors[partIndex].IsOverwritten ;
817+ }
818+
819+ csmBool CubismModel::GetOverwriteColorForPartScreenColors (csmInt32 partIndex) const
820+ {
821+ return _userPartScreenColors[partIndex].IsOverwritten ;
822+ }
823+
824+ void CubismModel::SetOverwriteColorForPartColors (
825+ csmUint32 partIndex,
826+ csmBool value,
827+ csmVector<PartColorData>& partColors,
828+ csmVector <DrawableColorData>& drawableColors)
829+ {
830+ partColors[partIndex].IsOverwritten = value;
831+
832+ for (csmUint32 i = 0 ; i < _partChildDrawables[partIndex].GetSize (); i++)
833+ {
834+ csmUint32 drawableIndex = _partChildDrawables[partIndex][i];
835+ drawableColors[drawableIndex].IsOverwritten = value;
836+ if (value)
837+ {
838+ drawableColors[drawableIndex].Color .R = partColors[partIndex].Color .R ;
839+ drawableColors[drawableIndex].Color .G = partColors[partIndex].Color .G ;
840+ drawableColors[drawableIndex].Color .B = partColors[partIndex].Color .B ;
841+ drawableColors[drawableIndex].Color .A = partColors[partIndex].Color .A ;
842+ }
843+ }
844+ }
845+
846+ void CubismModel::SetOverwriteColorForPartMultiplyColors (csmUint32 partIndex, csmBool value)
847+ {
848+ _userPartMultiplyColors[partIndex].IsOverwritten = value;
849+ SetOverwriteColorForPartColors (partIndex, value, _userPartMultiplyColors, _userMultiplyColors);
850+ }
851+
852+ void CubismModel::SetOverwriteColorForPartScreenColors (csmUint32 partIndex, csmBool value)
853+ {
854+ _userPartScreenColors[partIndex].IsOverwritten = value;
855+ SetOverwriteColorForPartColors (partIndex, value, _userPartScreenColors, _userScreenColors);
856+ }
857+
718858csmInt32 CubismModel::GetDrawableCulling (csmInt32 drawableIndex) const
719859{
720860 if (GetOverwriteFlagForModelCullings () || GetOverwriteFlagForDrawableCullings (drawableIndex))
@@ -751,6 +891,16 @@ void CubismModel::SetOverwriteFlagForDrawableCullings(csmUint32 drawableIndex, c
751891 _userCullings[drawableIndex].IsOverwritten = value;
752892}
753893
894+ csmFloat32 CubismModel::GetModelOpacity ()
895+ {
896+ return _modelOpacity;
897+ }
898+
899+ void CubismModel::SetModelOpacity (csmFloat32 value)
900+ {
901+ _modelOpacity = value;
902+ }
903+
754904Core::csmModel* CubismModel::GetModel () const
755905{
756906 return _model;
0 commit comments