本文整理汇总了C++中Ref::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ Ref::GetData方法的具体用法?C++ Ref::GetData怎么用?C++ Ref::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ref
的用法示例。
在下文中一共展示了Ref::GetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
bool Init() override
{
m_commonGUIStyle = g_commonGUIStyle;
m_canvas = Utility::MakeRef(new Canvas());
// Load textures for song select
m_style = SongSelectStyle::Get(g_application);
// Split between statistics and selection wheel (in percentage)
const float screenSplit = 0.4f;
// Statistics window
m_statisticsWindow = Ref<SongStatistics>(new SongStatistics(m_style));
Canvas::Slot* statisticsSlot = m_canvas->Add(m_statisticsWindow.As<GUIElementBase>());
statisticsSlot->anchor = Anchor(0, 0, screenSplit, 1.0f);
statisticsSlot->SetZOrder(2);
// Background
Panel* background = new Panel();
background->imageFillMode = FillMode::Fill;
background->texture = g_application->LoadTexture("bg.png");
background->color = Color(0.5f);
Canvas::Slot* bgSlot = m_canvas->Add(background->MakeShared());
bgSlot->anchor = Anchors::Full;
bgSlot->SetZOrder(-2);
LayoutBox* box = new LayoutBox();
Canvas::Slot* boxSlot = m_canvas->Add(box->MakeShared());
boxSlot->anchor = Anchor(screenSplit, 0, 1.0f, 1.0f);
box->layoutDirection = LayoutBox::Vertical;
{
m_searchField = Ref<TextInputField>(new TextInputField(m_commonGUIStyle));
LayoutBox::Slot* searchFieldSlot = box->Add(m_searchField.As<GUIElementBase>());
searchFieldSlot->fillX = true;
m_searchField->OnTextUpdated.Add(this, &SongSelect_Impl::OnSearchTermChanged);
m_selectionWheel = Ref<SelectionWheel>(new SelectionWheel(m_style));
LayoutBox::Slot* selectionSlot = box->Add(m_selectionWheel.As<GUIElementBase>());
selectionSlot->fillY = true;
m_selectionWheel->OnMapSelected.Add(this, &SongSelect_Impl::OnMapSelected);
m_selectionWheel->OnDifficultySelected.Add(this, &SongSelect_Impl::OnDifficultySelected);
}
// Select interface sound
m_selectSound = g_audio->CreateSample("audio/menu_click.wav");
// Setup the map database
m_mapDatabase.AddSearchPath(g_gameConfig.GetString(GameConfigKeys::SongFolder));
m_mapDatabase.OnMapsAdded.Add(m_selectionWheel.GetData(), &SelectionWheel::OnMapsAdded);
m_mapDatabase.OnMapsUpdated.Add(m_selectionWheel.GetData(), &SelectionWheel::OnMapsUpdated);
m_mapDatabase.OnMapsRemoved.Add(m_selectionWheel.GetData(), &SelectionWheel::OnMapsRemoved);
m_mapDatabase.OnMapsCleared.Add(m_selectionWheel.GetData(), &SelectionWheel::OnMapsCleared);
m_mapDatabase.StartSearching();
m_selectionWheel->SelectRandom();
return true;
}
示例2: runtime_error
NiSkinPartition::NiSkinPartition(Ref<NiTriBasedGeom> shape, int maxBonesPerPartition, int maxBonesPerVertex ) {
NiSkinInstanceRef skinInst = shape->GetSkinInstance();
if ( skinInst == NULL ) {
throw runtime_error( "You must bind a skin before setting generating skin partitions. No NiSkinInstance found." );
}
NiSkinDataRef skinData = skinInst->GetSkinData();
if ( skinData == NULL ) {
throw runtime_error( "You must bind a skin before setting generating skin partitions. No NiSkinData found." );
}
NiTriBasedGeomDataRef geomData = DynamicCast<NiTriBasedGeomData>(shape->GetData() );
if ( geomData == NULL ) {
throw runtime_error( "Attempted to generate a skin partition on a mesh with no geometry data." );
}
// read in the weights from NiSkinData
vector<Vector3> verts = geomData->GetVertices();
vector< BoneWeightList > weights;
if (verts.empty()){
throw runtime_error( "Attempted to generate a skin partition on a mesh with no vertices." );
}
Triangles triangles = geomData->GetTriangles();
if (triangles.empty()) {
throw runtime_error( "Attempted to generate a skin partition on a mesh with no triangles." );
}
weights.resize( verts.size() );
int numBones = skinData->GetBoneCount();
for ( int bone = 0; bone < numBones; bone++ )
{
vector<SkinWeight> vertexWeights = skinData->GetBoneWeights(bone);
for (int r = 0; r < int(vertexWeights.size()); ++r ){
int vertex = vertexWeights[r].index;
float weight = vertexWeights[r].weight;
if ( vertex >= int(weights.size()) )
throw runtime_error( "bad NiSkinData - vertex count does not match" );
weights[vertex].insert( weights[vertex].end(), BoneWeight(bone, weight) );
}
}
// count min and max bones per vertex
int minBones, maxBones;
minBones = maxBones = weights[0].size();
for(vector< BoneWeightList >::iterator itr = weights.begin(); itr != weights.end(); ++itr ){
int n = (*itr).size();
minBones = min(n, minBones);
maxBones = max(n, maxBones);
}
if ( minBones <= 0 )
throw runtime_error( "bad NiSkinData - some vertices have no weights at all" );
// reduce vertex influences if necessary
if ( maxBones > maxBonesPerVertex )
{
int c = 0;
for ( vector< BoneWeightList >::iterator it = weights.begin(); it != weights.end(); ++it )
{
BoneWeightList & lst = *it;
if ( int(lst.size()) > maxBonesPerVertex )
c++;
while ( int(lst.size()) > maxBonesPerVertex ) {
int j = 0;
float weight = lst.front().second;
for ( int i = 0; i < int(lst.size()); i++ )
{
if ( lst[i].second < weight )
j = i;
}
BoneWeightList::iterator jit = lst.begin() + j;
lst.erase( jit );
}
float totalWeight = 0;
for (BoneWeightList::iterator bw = lst.begin(); bw != lst.end(); ++bw) {
totalWeight += (*bw).second;
}
for (BoneWeightList::iterator bw = lst.begin(); bw != lst.end(); ++bw) {
(*bw).second /= totalWeight;
}
}
//qWarning() << "reduced" << c << "vertices to" << maxBonesPerVertex << "bone influences (maximum number of bones per vertex was" << maxBones << ")";
}
maxBones = maxBonesPerVertex;
// reduces bone weights so that the triangles fit into the partitions
typedef multimap<int,int> matchmap;
typedef pair<matchmap::iterator, matchmap::iterator> matchrange;
matchmap match;
bool doMatch = true;
BoneList tribones;
int cnt = 0;
for (Triangles::iterator itr = triangles.begin(); itr != triangles.end(); ++itr) {
Triangle& tri = (*itr);
do
{
//.........这里部分代码省略.........