本文整理汇总了C++中ModelManager::obtainSpriteInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelManager::obtainSpriteInfo方法的具体用法?C++ ModelManager::obtainSpriteInfo怎么用?C++ ModelManager::obtainSpriteInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelManager
的用法示例。
在下文中一共展示了ModelManager::obtainSpriteInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restore
void SpriteModel::restore() {
_TRACE3_("_model_name=" << _model_name << " start");
ModelManager* pModelManager = pGOD->_pModelManager;
_papTextureConnection = nullptr;
HRESULT hr;
std::string xfile_name = ModelManager::getSpriteFileName(_model_name, "sprx");
ModelManager::SpriteXFileFmt xdata;
pModelManager->obtainSpriteInfo(&xdata, xfile_name);
_model_width_px = xdata.width;
_model_height_px = xdata.height;
_row_texture_split = xdata.row_texture_split;
_col_texture_split = xdata.col_texture_split;
//テクスチャ取得しモデルに保持させる
TextureConnection* model_pTextureConnection = (TextureConnection*)(pModelManager->_pModelTextureManager->connect(xdata.texture_file, this));
//テクスチャの参照を保持させる。
_papTextureConnection = NEW TextureConnection*[1];
_papTextureConnection[0] = model_pTextureConnection;
SpriteModel::VERTEX* paVertex = NEW SpriteModel::VERTEX[4];
_size_vertices = sizeof(SpriteModel::VERTEX)*4;
_size_vertex_unit = sizeof(SpriteModel::VERTEX);
//頂点配列情報をモデルに保持させる
//UVは左上の1つ分(アニメパターン0)をデフォルトで設定する。
//シェーダーが描画時にアニメパターン番号をみてUV座標をずらす仕様としよっと。
//x,y の ÷2 とは、モデル中心をローカル座標の原点中心としたいため
// float tex_width = (float)(model_pTextureConnection->peek()->_pD3DXIMAGE_INFO->Width); //テクスチャの幅(px)
// float tex_height = (float)(model_pTextureConnection->peek()->_pD3DXIMAGE_INFO->Height); //テクスチャの高さ(px)
double du = 0.0;
double dv = 0.0;
//左上
paVertex[0].x = PX_DX(xdata.width) / -2.0;
paVertex[0].y = PX_DX(xdata.height) / 2.0;
paVertex[0].z = 0.0f;
paVertex[0].nx = 0.0f;
paVertex[0].ny = 0.0f;
paVertex[0].nz = -1.0f;
paVertex[0].color = D3DCOLOR_ARGB(255,255,255,255);
paVertex[0].tu = (float)du;
paVertex[0].tv = (float)dv;
//右上
paVertex[1].x = PX_DX(xdata.width) / 2.0;
paVertex[1].y = PX_DX(xdata.height) / 2.0;
paVertex[1].z = 0.0f;
paVertex[1].nx = 0.0f;
paVertex[1].ny = 0.0f;
paVertex[1].nz = -1.0f;
paVertex[1].color = D3DCOLOR_ARGB(255,255,255,255);
paVertex[1].tu = (float)((1.0 / xdata.col_texture_split) - du);
paVertex[1].tv = (float)dv;
//左下
paVertex[2].x = PX_DX(xdata.width) / -2.0;
paVertex[2].y = PX_DX(xdata.height) / -2.0;
paVertex[2].z = 0.0f;
paVertex[2].nx = 0.0f;
paVertex[2].ny = 0.0f;
paVertex[2].nz = -1.0f;
paVertex[2].color = D3DCOLOR_ARGB(255,255,255,255);
paVertex[2].tu = (float)du;
paVertex[2].tv = (float)((1.0 / xdata.row_texture_split) - dv);
//右下
paVertex[3].x = PX_DX(xdata.width) / 2.0;
paVertex[3].y = PX_DX(xdata.height) / -2.0;
paVertex[3].z = 0.0f;
paVertex[3].nx = 0.0f;
paVertex[3].ny = 0.0f;
paVertex[3].nz = -1.0f;
paVertex[3].color = D3DCOLOR_ARGB(255,255,255,255);
paVertex[3].tu = (float)((1.0 / xdata.col_texture_split) - du);
paVertex[3].tv = (float)((1.0 / xdata.row_texture_split) - dv);
//距離
FLOAT model_bounding_sphere_radius = (FLOAT)(sqrt(paVertex[0].x * paVertex[0].x +
paVertex[0].y * paVertex[0].y +
paVertex[0].z * paVertex[0].z));
_bounding_sphere_radius = model_bounding_sphere_radius;
//バッファ作成
if (_pVertexBuffer == nullptr) {
hr = God::_pID3DDevice9->CreateVertexBuffer(
_size_vertices,
D3DUSAGE_WRITEONLY,
SpriteModel::FVF,
D3DPOOL_DEFAULT, //D3DPOOL_DEFAULT
&(_pVertexBuffer),
nullptr);
checkDxException(hr, D3D_OK, "_pID3DDevice9->CreateVertexBuffer 失敗 model="<<(_model_name));
}
//頂点バッファ作成
//頂点情報をビデオカード頂点バッファへロード
void *pVertexBuffer;
hr = _pVertexBuffer->Lock(0, _size_vertices, (void**)&pVertexBuffer, 0);
checkDxException(hr, D3D_OK, "頂点バッファのロック取得に失敗 model="<<_model_name);
memcpy(pVertexBuffer, paVertex, _size_vertices); //pVertexBuffer ← paVertex
//.........这里部分代码省略.........
示例2: restore
void MassSpriteModel::restore() {
_TRACE3_("_model_name=" << _model_name << " start");
ModelManager* pModelManager = pGOD->_pModelManager;
HRESULT hr;
if (!_paVtxBuffer_data_model) {
//静的な情報設定
std::vector<std::string> names = UTIL::split(std::string(_model_name), ",");
std::string xfile_name = ""; //読み込むXファイル名
if (names.size() == 1) {
_TRACE_(FUNC_NAME<<" "<<_model_name<<" の最大同時描画オブジェクト数は、デフォルトの"<<GGAFDXMASS_MAX_INSTANCE_NUM<<" が設定されました。");
_set_num = GGAFDXMASS_MAX_INSTANCE_NUM;
xfile_name = ModelManager::getSpriteFileName(names[0], "sprx");
} else if (names.size() == 2) {
_set_num = STOI(names[0]);
xfile_name = ModelManager::getSpriteFileName(names[1], "sprx");
} else {
throwCriticalException("_model_name には \"xxxxxx\" or \"8/xxxxx\" 形式を指定してください。 \n"
"実際は、_model_name="<<_model_name<<" でした。");
}
if (_set_num < 1 || _set_num > GGAFDXMASS_MAX_INSTANCE_NUM) {
throwCriticalException(_model_name<<"の最大同時描画オブジェクト数が不正。範囲は 1〜"<<GGAFDXMASS_MAX_INSTANCE_NUM<<"セットです。_set_num="<<_set_num);
}
if (xfile_name == "") {
throwCriticalException("スプライト定義ファイル(*.sprx)が見つかりません。model_name="<<(_model_name));
}
ModelManager::SpriteXFileFmt xdata;
pModelManager->obtainSpriteInfo(&xdata, xfile_name);
_model_width_px = xdata.width;
_model_height_px = xdata.height;
_model_half_width_px = _model_width_px/2;
_model_half_height_px = _model_height_px/2;
_row_texture_split = xdata.row_texture_split;
_col_texture_split = xdata.col_texture_split;
_nVertices = 4;
_nFaces = 2;
_paVtxBuffer_data_model = NEW MassSpriteModel::VERTEX_model[_nVertices];
_size_vertex_unit_model = sizeof(MassSpriteModel::VERTEX_model);
_size_vertices_model = sizeof(MassSpriteModel::VERTEX_model) * _nVertices;
// float tex_width = (float)(model_pTextureConnection->peek()->_pD3DXIMAGE_INFO->Width); //テクスチャの幅(px)
// float tex_height = (float)(model_pTextureConnection->peek()->_pD3DXIMAGE_INFO->Height); //テクスチャの高さ(px)
double du = 0.0;
double dv = 0.0;
//左上
_paVtxBuffer_data_model[0].x = PX_DX(xdata.width) / -2.0;
_paVtxBuffer_data_model[0].y = PX_DX(xdata.height) / 2.0;
_paVtxBuffer_data_model[0].z = 0.0f;
_paVtxBuffer_data_model[0].nx = 0.0f;
_paVtxBuffer_data_model[0].ny = 0.0f;
_paVtxBuffer_data_model[0].nz = -1.0f;
_paVtxBuffer_data_model[0].tu = du;
_paVtxBuffer_data_model[0].tv = dv;
//右上
_paVtxBuffer_data_model[1].x = PX_DX(xdata.width) / 2.0;
_paVtxBuffer_data_model[1].y = PX_DX(xdata.height) / 2.0;
_paVtxBuffer_data_model[1].z = 0.0f;
_paVtxBuffer_data_model[1].nx = 0.0f;
_paVtxBuffer_data_model[1].ny = 0.0f;
_paVtxBuffer_data_model[1].nz = -1.0f;
_paVtxBuffer_data_model[1].tu = (1.0/xdata.col_texture_split) - du;
_paVtxBuffer_data_model[1].tv = dv;
//左下
_paVtxBuffer_data_model[2].x = PX_DX(xdata.width) / -2.0;
_paVtxBuffer_data_model[2].y = PX_DX(xdata.height) / -2.0;
_paVtxBuffer_data_model[2].z = 0.0f;
_paVtxBuffer_data_model[2].nx = 0.0f;
_paVtxBuffer_data_model[2].ny = 0.0f;
_paVtxBuffer_data_model[2].nz = -1.0f;
_paVtxBuffer_data_model[2].tu = du;
_paVtxBuffer_data_model[2].tv = (1.0/xdata.row_texture_split) - dv;
//右下
_paVtxBuffer_data_model[3].x = PX_DX(xdata.width) / 2.0;
_paVtxBuffer_data_model[3].y = PX_DX(xdata.height) / -2.0;
_paVtxBuffer_data_model[3].z = 0.0f;
_paVtxBuffer_data_model[3].nx = 0.0f;
_paVtxBuffer_data_model[3].ny = 0.0f;
_paVtxBuffer_data_model[3].nz = -1.0f;
_paVtxBuffer_data_model[3].tu = 1.0/xdata.col_texture_split;
_paVtxBuffer_data_model[3].tv = 1.0/xdata.row_texture_split;
_paIndexBuffer_data = NEW WORD[(_nFaces*3)];
_paIndexBuffer_data[0] = 0;
_paIndexBuffer_data[1] = 1;
_paIndexBuffer_data[2] = 2;
_paIndexBuffer_data[3] = 1;
_paIndexBuffer_data[4] = 3;
_paIndexBuffer_data[5] = 2;
//距離
FLOAT model_bounding_sphere_radius = (FLOAT)(sqrt(_paVtxBuffer_data_model[0].x * _paVtxBuffer_data_model[0].x +
_paVtxBuffer_data_model[0].y * _paVtxBuffer_data_model[0].y +
_paVtxBuffer_data_model[0].z * _paVtxBuffer_data_model[0].z));
_bounding_sphere_radius = model_bounding_sphere_radius;
setMaterial();
_pa_texture_filenames[0] = std::string(xdata.texture_file);
}
//デバイスに頂点バッファ作成(モデル)
if (_pVertexBuffer_model == nullptr) {
//.........这里部分代码省略.........
示例3: restore
void RegularPolygonBoardModel::restore() {
_TRACE3_("_model_name=" << _model_name << " start");
HRESULT hr;
std::string model_name = std::string(_model_name); //_model_name は "8,CW,XXXX" or "8,XXXX"
std::vector<std::string> names = UTIL::split(model_name, ",");
std::string filenamae = "";
if (names.size() == 2) {
filenamae = names[1];
} else if (names.size() == 3) {
filenamae = names[2];
}
ModelManager* pModelManager = pGOD->_pModelManager;
std::string xfile_name = ModelManager::getSpriteFileName(filenamae, "sprx");
ModelManager::SpriteXFileFmt xdata;
pModelManager->obtainSpriteInfo(&xdata, xfile_name);
_model_width_px = xdata.width;
_model_height_px = xdata.height;
_row_texture_split = xdata.row_texture_split;
_col_texture_split = xdata.col_texture_split;
//テクスチャ取得しモデルに保持させる
_papTextureConnection = NEW TextureConnection*[1];
_papTextureConnection[0] = (TextureConnection*)(pModelManager->_pModelTextureManager->connect(xdata.texture_file, this));
RegularPolygonBoardModel::VERTEX* paVertex = NEW RegularPolygonBoardModel::VERTEX[_angle_num+2];
_size_vertices = sizeof(RegularPolygonBoardModel::VERTEX)*(_angle_num+2);
_size_vertex_unit = sizeof(RegularPolygonBoardModel::VERTEX);
float model_width = _model_width_px;
float model_height = _model_height_px;
float tu_rate = 1.0 / _col_texture_split;
float tv_rate = 1.0 / _row_texture_split;
_u_center = tu_rate * 0.5;
_v_center = tv_rate * 0.5;
_x_center = model_width * 0.5;
_y_center = model_height * 0.5;
//中心
paVertex[0].x = _x_center;
paVertex[0].y = _y_center;
paVertex[0].z = 0.0f;
paVertex[0].tu = _u_center;
paVertex[0].tv = _v_center;
if (_drawing_order == 0) { //反計回り
for (int ang = 0; ang < _angle_num; ang++) {
double rad = (PI2 * ang) / _angle_num;
paVertex[ang+1].x = paVertex[0].x + (cos(rad) * model_width * 0.5);
paVertex[ang+1].y = paVertex[0].y - (sin(rad) * model_height * 0.5);
paVertex[ang+1].z = 0.0f;
paVertex[ang+1].tu = paVertex[0].tu + (cos(rad) * tu_rate * 0.5);
paVertex[ang+1].tv = paVertex[0].tv - (sin(rad) * tv_rate * 0.5);
}
paVertex[_angle_num+1] = paVertex[1];
} else {
//時計回り
for (int ang = 0; ang < _angle_num; ang++) {
double rad = PI2 - ((PI2 * ang) / _angle_num);
paVertex[ang+1].x = paVertex[0].x + (cos(rad) * model_width * 0.5);
paVertex[ang+1].y = paVertex[0].y - (sin(rad) * model_height * 0.5);
paVertex[ang+1].z = 0.0f;
paVertex[ang+1].tu = paVertex[0].tu + (cos(rad) * tu_rate * 0.5);
paVertex[ang+1].tv = paVertex[0].tv - (sin(rad) * tv_rate * 0.5);
}
paVertex[_angle_num+1] = paVertex[1];
}
// RegularPolygonBoardModel::VERTEX* paVertex = NEW RegularPolygonBoardModel::VERTEX[_angle_num+2];
// _size_vertices = sizeof(RegularPolygonBoardModel::VERTEX)*(_angle_num+2);
// _size_vertex_unit = sizeof(RegularPolygonBoardModel::VERTEX);
//
// double du = 0.0;
// double dv = 0.0;
//
// //左上
// paVertex[0].x = 0.0f;
// paVertex[0].y = 0.0f;
// paVertex[0].z = 0.0f;
// paVertex[0].tu = (float)du;
// paVertex[0].tv = (float)dv;
// //右上
// paVertex[1].x = xdata.width;
// paVertex[1].y = 0.0f;
// paVertex[1].z = 0.0f;
// paVertex[1].tu = (float)((1.0 / xdata.col_texture_split) - du);
// paVertex[1].tv = (float)dv;
// //左下
// paVertex[2].x = 0.0f;
// paVertex[2].y = xdata.height;
// paVertex[2].z = 0.0f;
// paVertex[2].tu = (float)du;
// paVertex[2].tv = (float)((1.0 / xdata.row_texture_split) - dv);
// //右下
// paVertex[3].x = xdata.width;
// paVertex[3].y = xdata.height;
// paVertex[3].z = 0.0f;
// paVertex[3].tu = (float)((1.0 / xdata.col_texture_split) - du);
// paVertex[3].tv = (float)((1.0 / xdata.row_texture_split) - dv);
//バッファ作成
if (_pVertexBuffer == nullptr) {
//.........这里部分代码省略.........