//-***************************************************************************** void lightTest() { std::string fileName = "light1.abc"; { OArchive archive( Alembic::AbcCoreHDF5::WriteArchive(), fileName ); OLight emptyLightObj( OObject( archive, kTop ), "emptyLight" ); OLight lightObj( OObject( archive, kTop ), "myLight" ); CameraSample samp; lightObj.getSchema().setCameraSample( samp ); samp = CameraSample( -0.35, 0.75, 0.1, 0.5 ); samp.setChildBounds( Abc::Box3d( Abc::V3d( 0.0, 0.1, 0.2), Abc::V3d( 0.3, 0.4, 0.5 ) ) ); lightObj.getSchema().setCameraSample( samp ); Abc::OCompoundProperty arb = lightObj.getSchema().getArbGeomParams(); OFloatGeomParam param(arb, "test", false, Alembic::AbcGeom::kConstantScope, 1); Abc::OCompoundProperty user = lightObj.getSchema().getUserProperties(); OFloatProperty(user, "test"); } { CameraSample samp; double top, bottom, left, right; IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(), fileName ); ILight emptyLightObj( IObject( archive, kTop ), "emptyLight" ); ILight lightObj( IObject( archive, kTop ), "myLight" ); TESTING_ASSERT( ! emptyLightObj.getSchema().getArbGeomParams() ); TESTING_ASSERT( ! emptyLightObj.getSchema().getUserProperties() ); TESTING_ASSERT( ! emptyLightObj.getSchema().getCameraSchema().valid() ); TESTING_ASSERT( lightObj.getSchema().getArbGeomParams().getNumProperties() == 1 ); TESTING_ASSERT( lightObj.getSchema().getUserProperties().getNumProperties() == 1 ); lightObj.getSchema().getCameraSchema().get( samp, 0 ); samp.getScreenWindow( top, bottom, left, right ); TESTING_ASSERT( almostEqual( top, 0.666666666666667 ) ); TESTING_ASSERT( almostEqual( bottom, -0.666666666666667 ) ); TESTING_ASSERT( almostEqual( left, -1.0 ) ); TESTING_ASSERT( almostEqual( right, 1.0 ) ); lightObj.getSchema().getCameraSchema().get( samp, 1 ); samp.getScreenWindow( top, bottom, left, right ); TESTING_ASSERT( almostEqual( top, -0.35 ) ); TESTING_ASSERT( almostEqual( bottom, 0.75 ) ); TESTING_ASSERT( almostEqual( left, 0.1 ) ); TESTING_ASSERT( almostEqual( right, 0.5 ) ); TESTING_ASSERT( ! lightObj.getSchema().getCameraSchema().getChildBoundsProperty() ); } }
//-***************************************************************************** void OLightSchema::setCameraSample( const CameraSample &iSamp ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OLightSchema::setCameraSample" ); if ( ! m_cameraSchema.valid() ) { m_cameraSchema = OCameraSchema( this->getPtr(), ".camera", m_tsPtr ); } // clear the child bounds if they happen to be set on the camera sample // since that data is meaninless because we have child bounds on the // light schema CameraSample samp = iSamp; Abc::Box3d childBounds; samp.setChildBounds(childBounds); m_cameraSchema.set( samp ); ALEMBIC_ABC_SAFE_CALL_END(); }