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

# TranslationMesh.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/Mesh/TranslationMesh.h"
    00027
    00028 namespace LampForMaya{
    00029
    00030 //------------------------------------------------------------------------------
    00031 // コンストラクタ
    00032 TranslationMesh::TranslationMesh(const String& initializeName) :
    00033     name_(initializeName), uvSetCount_(0){
    00034 }
    00035 //------------------------------------------------------------------------------
    00036 // デストラクタ
    00037 TranslationMesh::~TranslationMesh(){
    00038 }
    00039 //------------------------------------------------------------------------------
    00040 // 頂点論理チェック
    00041 bool TranslationMesh::vertexLogicalCheck(){
    00042     String errorString;
    00043     // 位置
    00044     int vertexCount = positions_.getCount();
    00045     if((vertexCount % 3) != 0){
    00046         errorString.format("TranslationMesh::vertexLogicalCheck() "
    00047             "%sの頂点数(%d)が3で割り切れません",
    00048             name_.getBytes(), vertexCount);
    00049         MayaErrorOut(errorString);
    00050         return false;
    00051     }
    00052
    00053     // 法線
    00054     int normalCount = normals_.getCount();
    00055     if(normalCount != vertexCount){
    00056         errorString.format("TranslationMesh::vertexLogicalCheck() "
    00057             "%sの頂点数(%d)と法線数(%d)が違います",
    00058             name_.getBytes(), vertexCount, normalCount);
    00059         MayaErrorOut(errorString);
    00060         return false;
    00061     }
    00062
    00063     // 法線の長さチェック
    00064     for(int i = 0; i < normalCount; i++){
    00065         Vector3 normal = normals_.get(i);
    00066         float length = normal.getLength();
    00067         if(Math::abs(length - 1.f) > Math::epsilon){
    00068             Vector3 position = positions_.get(i);
    00069             errorString.format("TranslationMesh::vertexLogicalCheck() "
    00070                 "%sの法線の長さ(%f)が1でありません position%s",
    00071                 name_.getBytes(), length, position.toString().getBytes());
    00072             MayaErrorOut(errorString);
    00073             return false;
    00074         }
    00075     }
    00076
    00077     // カラー
    00078     int colorCount = colors_.getCount();
    00079     if((colorCount != vertexCount) && (colorCount != 0)){
    00080         errorString.format("TranslationMesh::vertexLogicalCheck() "
    00081             "%sの頂点数(%d)と頂点カラー数(%d)が違います",
    00082             name_.getBytes(), vertexCount, colorCount);
    00083         MayaErrorOut(errorString);
    00084         return false;
    00085     }
    00086
    00087     // UV
    00088     int uvCount = uvs_.getCount();
    00089     if((uvCount != (vertexCount * uvSetCount_)) && (uvCount != 0)){
    00090         errorString.format("TranslationMesh::vertexLogicalCheck() "
    00091             "%sの頂点数(%d * %d)とUV数(%d)が違います",
    00092             name_.getBytes(), vertexCount, uvSetCount_, uvCount);
    00093         MayaErrorOut(errorString);
    00094         return false;
    00095     }
    00096     return true;
    00097 }
    00098 //------------------------------------------------------------------------------
    00099 } // End of namespace LampForMaya
    00100 //------------------------------------------------------------------------------