From 7861992fe6c8bc02600917c80053e08d9dcaa501 Mon Sep 17 00:00:00 2001 From: majestic Date: Wed, 7 Oct 2020 18:43:50 -0700 Subject: CWaterCreatures --- src/entities/Entity.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/entities/Entity.cpp') diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index cf1dd9e7..d7159e8c 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -1207,4 +1207,37 @@ bool CEntity::IsEntityOccluded(void) { } return false; +} + +/* +0x487A10 - SetAtomicAlphaCB +0x4879E0 - SetClumpAlphaCB +*/ + +RpMaterial* SetAtomicAlphaCB(RpMaterial *material, void *data) { + ((RwRGBA*)RpMaterialGetColor(material))->alpha = (uint8)(uintptr)data; + return material; +} + +RpAtomic* SetClumpAlphaCB(RpAtomic *atomic, void *data) { + RpGeometry *geometry = RpAtomicGetGeometry(atomic); + RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR); + RpGeometryForAllMaterials(geometry, SetAtomicAlphaCB, (void*)data); + return atomic; +} + +void CEntity::SetRwObjectAlpha(int32 alpha) { + if (m_rwObject != nil) { + switch (RwObjectGetType(m_rwObject)) { + case rpATOMIC: { + RpGeometry *geometry = RpAtomicGetGeometry(GetFirstAtomic(GetClump())); + RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR); + RpGeometryForAllMaterials(geometry, SetAtomicAlphaCB, (void*)alpha); + break; + } + case rpCLUMP: + RpClumpForAllAtomics((RpClump*)m_rwObject, SetClumpAlphaCB, (void*)alpha); + break; + } + } } \ No newline at end of file -- cgit v1.2.3