//-***************************************************************************** void OWrapExisting() { Alembic::Abc::OArchive archive( Alembic::AbcCoreHDF5::WriteArchive(), "playground_owrap.abc" ); Alembic::Abc::OObject archiveTop = archive.getTop(); Alembic::Util::shared_ptr< Alembic::Abc::OObject > objAPtr = makeXform( archiveTop ); Alembic::Util::shared_ptr< Alembic::Abc::OObject > objBPtr = subdCube( *objAPtr ); // // NOW THE FUN BEGINS // TESTING_ASSERT( Alembic::AbcGeom::OSubD::matches( objBPtr->getHeader() ) ); { Alembic::Util::shared_ptr< Alembic::AbcGeom::OSubD > subdObjPtr = Alembic::Util::dynamic_pointer_cast< Alembic::AbcGeom::OSubD > ( objBPtr ); Alembic::AbcGeom::OSubD subdObj = *subdObjPtr; std::cout << "wrapped-existing subd has " << subdObj.getSchema().getNumSamples() << " num samples." << std::endl; std::vector<V3f> verts( 8, V3f(2.0, 2.0, 2.0 ) ); Alembic::AbcGeom::OSubDSchema::Sample sample; sample.setPositions( Alembic::Abc::V3fArraySample( &(verts[0]), verts.size() ) ); subdObj.getSchema().set( sample ); TESTING_ASSERT( subdObj.getSchema().getNumSamples() == 2 ); } TESTING_ASSERT( Alembic::AbcGeom::OXform::matches( objAPtr->getHeader() ) ); { XformOp transop( kTranslateOperation, kTranslateHint ); XformOp scaleop( kScaleOperation, kScaleHint ); XformSample samp; samp.addOp( transop, V3d( 4.0, 5.0, 6.0 ) ); samp.addOp( scaleop, V3d( 8.0, 10.0, 12.0 ) ); Alembic::Util::shared_ptr< Alembic::AbcGeom::OXform > xformObjPtr = Alembic::Util::dynamic_pointer_cast< Alembic::AbcGeom::OXform > ( objAPtr ); Alembic::AbcGeom::OXform xformObj = *xformObjPtr; xformObj.getSchema().set( samp ); TESTING_ASSERT( xformObj.getSchema().getNumSamples() == 2 ); } }
ALTransform::ALTransform(Alembic::AbcGeom::OXform &obj) { m_schema = obj.getSchema(); }
static void export_alembic_camera(AlembicArchive &archive, const RenderedBuffer & renderedBuffer, bool isUseEuler) { static const int cameraKey = 0xFFFFFF; Alembic::AbcGeom::OObject topObj(*archive.archive, Alembic::AbcGeom::kTop); Alembic::AbcGeom::OXform xform; if (archive.xform_map.find(cameraKey) != archive.xform_map.end()) { xform = archive.xform_map[cameraKey]; } else { xform = Alembic::AbcGeom::OXform(topObj, "camera_xform", archive.timesampling); archive.xform_map[cameraKey] = xform; Alembic::AbcGeom::OXformSchema &xformSchema = xform.getSchema(); archive.xform_schema_map[cameraKey] = xformSchema; } // set camera transform { Alembic::AbcGeom::OXformSchema &xformSchema = archive.xform_schema_map[cameraKey]; xformSchema.setTimeSampling(archive.timesampling); Alembic::AbcGeom::XformSample xformSample; D3DXMATRIX convertMat( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1); D3DXMATRIX convertedWordInv; ::D3DXMatrixMultiply(&convertedWordInv, &renderedBuffer.world_inv, &convertMat); D3DXVECTOR3 eye; { D3DXVECTOR3 v; UMGetCameraEye(&v); d3d_vector3_transform(eye, v,convertedWordInv); } D3DXVECTOR3 at; { D3DXVECTOR3 v; UMGetCameraAt(&v); d3d_vector3_transform(at, v, convertedWordInv); } D3DXVECTOR3 up; { D3DXVECTOR3 v; UMGetCameraUp(&v); d3d_vector3_dir_transform(up, v, convertedWordInv); ::D3DXVec3Normalize(&up, &up); } Imath::V3d trans((double)eye.x, (double)eye.y, (double)(eye.z)); xformSample.setTranslation(trans); D3DXMATRIX view; ::D3DXMatrixLookAtLH(&view, &eye, &at, &up); Imath::M44d rot( -view.m[0][0], view.m[0][1], view.m[0][2], 0, -view.m[1][0], view.m[1][1], view.m[1][2], 0, view.m[2][0], -view.m[2][1], -view.m[2][2], 0, 0, 0, 0, 1); Imath::Quatd quat = Imath::extractQuat(rot); quat.normalize(); if (isUseEuler) { Imath::V3d imeuler; quatToEuler(imeuler, quat); //UMMat44d umrot( // -view.m[0][0], view.m[0][1], view.m[0][2], 0, // -view.m[1][0], view.m[1][1], view.m[1][2], 0, // view.m[2][0], -view.m[2][1], -view.m[2][2], 0, // 0, 0, 0, 1); //UMVec3d umeuler = umbase::um_matrix_to_euler_xyz(umrot.transposed()); xformSample.setXRotation(umbase::um_to_degree(imeuler.y)); xformSample.setYRotation(umbase::um_to_degree(imeuler.x)); xformSample.setZRotation(-umbase::um_to_degree(imeuler.z)); } else { xformSample.setRotation(quat.axis(), umbase::um_to_degree(quat.angle())); } xformSchema.set(xformSample); } Alembic::AbcGeom::OCamera camera; if (archive.camera_map.find(cameraKey) != archive.camera_map.end()) { camera = archive.camera_map[cameraKey]; } else { camera = Alembic::AbcGeom::OCamera(xform, "camera", archive.timesampling); archive.camera_map[cameraKey] = camera; Alembic::AbcGeom::OCameraSchema &cameraSchema = camera.getSchema(); archive.camera_schema_map[cameraKey] = cameraSchema; } Alembic::AbcGeom::OCameraSchema &cameraSchema = archive.camera_schema_map[cameraKey]; cameraSchema.setTimeSampling(archive.timesampling); Alembic::AbcGeom::CameraSample sample; D3DXVECTOR4 v; UMGetCameraFovLH(&v); sample.setNearClippingPlane(v.z); sample.setFarClippingPlane(v.w); double fovy = v.x; double aspect = v.y; double fovx = 2.0 * atan(tan(fovy / 2.0)*(aspect)); double w = BridgeParameter::instance().frame_width / 10.0; double h = BridgeParameter::instance().frame_height / 10.0; double focalLength = w / (2.0 * tan(fovx / 2.0)); sample.setHorizontalAperture(w / 10.0); sample.setVerticalAperture(h / 10.0); sample.setFocalLength(focalLength); cameraSchema.set(sample); }