int luaLoadLand(lua_State *L) { char *str=(char*)lua_tostring(L, 1); int r=0; char st[_MAX_PATH]; if(strcmp(szLandFileName0,str)!=0) { char *s=SearchFolder(CurrDataDir,str,st); if(s==NULL) { char *s=SearchFolder(DataDir,str,st); if(s==NULL) { s=SearchFolder(ResourceDir,str,st); if(s==NULL) { lua_pushnumber(L,0); return 1; } } } r=LoadLand(G3dDevice, s); if(r==0) { char szDrive[_MAX_DRIVE + 1]; // ドライブ名格納領域 char szPath [_MAX_PATH + 1]; // パス名格納領域 char szTitle[_MAX_FNAME + 1]; // ファイルタイトル格納領域 char szExt [_MAX_EXT + 1]; // ファイル拡張子格納領域 // 絶対パスを分解 _splitpath ( str, szDrive, szPath, szTitle, szExt); lstrcpy(szLandFileName,str); lstrcpy(szLandFileName0,szTitle); lstrcat(szLandFileName0,szExt); GFloat y=World->Land->GetY(0,0); Chip[0]->CalcTotalCenter(); Chip[0]->X=GVector(0,Chip[0]->Top->TotalRadius*2+2+y,0); Chip[0]->R=GMatrix33(); World->RestoreLink(Chip[0],Chip[0]); if(Chip[0]->X.y<=-100000.0f)Chip[0]->X.y=0.0f; m_pLandMesh->InvalidateDeviceObjects(); m_pLandMesh->RestoreDeviceObjects(G3dDevice); } } World->MainStepCount=-1; lua_pushnumber(L,r); return 1; }
GMatrix33 GAnimTRSNode2D::InverseMatrix(const GTimeValue TimePos, const GSpaceSystem Space, GTimeInterval& ValidInterval) const { GProperty *tmpProp = Property("transform"); // this can be the case of a curve not created through a kernel if (!tmpProp) { ValidInterval = G_FOREVER_TIMEINTERVAL; return GMatrix33(); } GMatrix33 invTranslation; GMatrix33 invRotation; GMatrix33 invScale; GTimeInterval tmpValid = G_FOREVER_TIMEINTERVAL; GKeyValue xValue, yValue; GError xErr, yErr; GProperty *transProp = tmpProp->Property("position"); GProperty *rotProp = tmpProp->Property("rotation"); GProperty *scaleProp = tmpProp->Property("scale"); G_ASSERT(transProp != NULL); G_ASSERT(rotProp != NULL); G_ASSERT(scaleProp != NULL); // extract translation GProperty *xProp = transProp->Property("x"); GProperty *yProp = transProp->Property("y"); G_ASSERT(xProp != NULL); G_ASSERT(yProp != NULL); // build translation factor xErr = xProp->Value(xValue, tmpValid, TimePos, G_ABSOLUTE_VALUE); yErr = yProp->Value(yValue, tmpValid, TimePos, G_ABSOLUTE_VALUE); if (xErr != G_NO_ERROR || yErr != G_NO_ERROR) return GMatrix33(); TranslationToMatrix(invTranslation, GVector2(-xValue.RealValue(), -yValue.RealValue())); // build rotation factor xErr = rotProp->Value(xValue, tmpValid, TimePos, G_ABSOLUTE_VALUE); if (xErr != G_NO_ERROR) return GMatrix33(); RotationToMatrix(invRotation, -xValue.RealValue()); // extract scale xProp = scaleProp->Property("x"); yProp = scaleProp->Property("y"); G_ASSERT(xProp != NULL); G_ASSERT(yProp != NULL); // build scale factor xErr = xProp->Value(xValue, tmpValid, TimePos, G_ABSOLUTE_VALUE); yErr = yProp->Value(yValue, tmpValid, TimePos, G_ABSOLUTE_VALUE); if (xErr != G_NO_ERROR || yErr != G_NO_ERROR) return GMatrix33(); GPoint2 tmpScale(1, 1); if (GMath::Abs(xValue.RealValue()) > G_EPSILON) tmpScale[G_X] = 1 / xValue.RealValue(); if (GMath::Abs(yValue.RealValue()) > G_EPSILON) tmpScale[G_Y] = 1 / yValue.RealValue(); ScaleToMatrix(invScale, tmpScale); ValidInterval = tmpValid; // take care of father GMatrix33 invLocalMatrix = (invScale * (invRotation * invTranslation)); if (gFather && Space == G_WORLD_SPACE) { GMatrix33 invFatherMatrix = gFather->InverseMatrix(TimePos, G_WORLD_SPACE, tmpValid); ValidInterval &= tmpValid; return (invLocalMatrix * invFatherMatrix); } return invLocalMatrix; }