Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

# TranslationModel.cpp

Go to the documentation of this file.

    00001 //------------------------------------------------------------------------------
    00002 // Lamp : Open source game middleware
    00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
    00004 //
    00005 // This library is free software; you can redistribute it and/or
    00006 // modify it under the terms of the GNU Lesser General Public
    00007 // License as published by the Free Software Foundation; either
    00008 // version 2.1 of the License, or (at your option) any later version.
    00009 //
    00010 // This library is distributed in the hope that it will be useful,
    00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013 // Lesser General Public License for more details.
    00014 //
    00015 // You should have received a copy of the GNU Lesser General Public
    00016 // License along with this library; if not, write to the Free Software
    00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018 //------------------------------------------------------------------------------
    00019
    00020 /** @file
    00021  * 変換モデル実装
    00022  * @author Junpee
    00023  */
    00024
    00025 #include "System/stdafx.h"
    00026 #include "Translator/Model/TranslationModel.h"
    00027 #include "Translator/Mesh/TranslationMesh.h"
    00028
    00029 namespace LampForMaya{
    00030
    00031 //------------------------------------------------------------------------------
    00032 // コンストラクタ
    00033 TranslationModel::TranslationModel(
    00034     const MObject& initializeObject, const String& initializeName) :
    00035     object_(initializeObject), name_(initializeName), visibility_(false){
    00036 }
    00037 //------------------------------------------------------------------------------
    00038 // デストラクタ
    00039 TranslationModel::~TranslationModel(){
    00040 }
    00041 //------------------------------------------------------------------------------
    00042 // ピボットのコンパイル
    00043 void TranslationModel::compilePivot(const Vector3& pivot){
    00044     int meshCount = meshes_.getCount();
    00045     for(int i = 0; i < meshCount; i++){
    00046         TranslationMesh* mesh = meshes_.get(i);
    00047         mesh->compilePivot(pivot);
    00048     }
    00049 }
    00050 //------------------------------------------------------------------------------
    00051 // モデルのアナライズ
    00052 bool TranslationModel::analyzeModel(){
    00053     visibility_ = MayaAttributeUtility::getBool(object_, "visibility");
    00054     return true;
    00055 }
    00056 //------------------------------------------------------------------------------
    00057 // シェーダ名の取得
    00058 String TranslationModel::getShaderName(const MObject& shadingEngine){
    00059     MStatus result;
    00060     if(!shadingEngine.hasFn(MFn::kShadingEngine)){
    00061         MayaErrorOut(String("TranslationModel::getShaderName() ") +
    00062             name_ + "にシェーディングエンジンが接続されていません");
    00063         return "";
    00064     }
    00065     // シェーディングエンジンからサーフェースシェーダをたどる
    00066     MPlug surfaceShaderPlug = MayaNodeUtility::getPlug(
    00067         shadingEngine, "surfaceShader");
    00068     MPlugArray shaderArray;
    00069     surfaceShaderPlug.connectedTo(shaderArray, true, false, &result);
    00070     MayaStatusCheck(result);
    00071     if(shaderArray.length() == 0){
    00072         MayaErrorOut(String("TranslationStandardModel::analyze() ") +
    00073             name_ + "にサーフェースシェーダが接続されていません");
    00074         return "";
    00075     }
    00076     return MayaNodeUtility::getName(shaderArray[0].node());
    00077 }
    00078 //------------------------------------------------------------------------------
    00079 } // End of namespace LampForMaya
    00080 //------------------------------------------------------------------------------