00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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 }
00100