glScalefã®ãã«ã¤ãã¼ã½(`д)ã
ã¡ã¿ã»ã³ã¢ãã«ã®ãã¼ãã¼ãæ¹è¯ä¸ããªãã ããã©å¦ãªåé¡ã«ã¶ã¤ãã£ããã©ããã¦ãã¢ãã«ã®ã·ã§ã¼ãã£ã³ã°ããããããç°å¸¸ã«ãã¤ã©ã¤ãããã¤ãã£ããæãããããæ³ç·ã®è¨ç®ã«ã¼ãã³ããã°ã£ã¦ããã®ãã¨æãè¦ç´ãã¦ã¿ããåé¡ãªãæ§åãæ質ãã©ã¤ãã£ã³ã°ã®è¨å®ãããããå¼ã£ã¦ã¿ã¦ãã ãã½ãæ°æéæ©ãã
æãç«ã£ã¦ä½æ°ãªãglEnable(GL_NORMALIZE)ãæå¹ã«ãã¦ã¿ãã¨ããä¸æ°ã«è§£æ±ºãã©ãããç¯äººã¯ã¢ãã«ã®å¤§ãããåãããããã«ä½¿ã£ã¦ããglScalefãããã¤ã§æ¡å¤§ç¸®å°ããã¨ããã£ãããªãã¨ã«æ³ç·ã¾ã§æ¡å¤§ç¸®å°ããã¦ãã¾ãããããOpenGLã§ã¯æ³ç·ã¯åä½ãã¯ãã«é·ã§ãªããã°ãªããªãã®ã§ãã·ã§ã¼ãã£ã³ã°ããããããªã£ãããã ã
glScalefã使ãå ´åã¯GL_NORMALIZEæå¹ã«ãããæ³ç·ã®åæ£è¦åããã¾ãããã£ã¦ãã¨ã§ã
æ³ç·ã¯æ¡å¤§ç¸®å°ãããªãã¨åæã«æãè¾¼ãã§ããæ¼ããæªãã®ããå¤æè¡åã®ãã¨ãããããããªãããã¡ããã¨æ°å¦åå¼·ããªãã¨é§ç®ããªã
ã¨ããããã§æ³ç·ã®è¨ç®æ¹æ³ã®ãããã
1.é¢åä½ã®æ³ç·ãæ±ãã
ãã¨ãã°é ç¹v1ãv2ãv3ãå«ãé¢ã®æ³ç·ãæ±ããã«ã¯
Vector3 work1, work2; work1 = v2 - v1; work2 = v3 - v1; normal = crossProduct(work1, work2); // å¤ç©ãæ±ããã normal.normalize(); // ã¡ããã¨æ£è¦åãã¦ããã
注æç¹ã¯ãv1ãv2ãv3ãæ³ç·ã®æ¹åã«å¯¾ãã¦åæè¨åãã«ãªãããã«ããããããããã¯ãã«å士ã®æ¸ç®ã¨ããcrossProductããnormalizeã¯è³å é¢æ°ã«ç½®ãæãã¦ããªã¼ãºã
2.é ç¹åä½ã®æ³ç·ã決å®ãã
ãã®é ç¹ãå«ãå ¨ã¦ã®é¢ï¼é£ãåãé¢ï¼ã®æ³ç·ã®å¹³åãæ±ããã
スムースシェーディングで鋭角なエッジが潰れてしまうのを防ぐ法線生成テクニックãããã¹ã ã¼ã¹ã·ã§ã¼ãã£ã³ã°ã¨ãã©ããã·ã§ã¼ãã£ã³ã°ã®æ¯è¼ã®å³ãªããã§ãã¹ã ã¼ã¹ã·ã§ã¼ãã£ã³ã°ããããããç«æ¹ä½ããé ç¹å士ã®è²ãè£å®ããã¦ç«æ¹ä½ã®è§ãæ¶ãã¡ãã£ã¦ãã®ãè¦ãããã©ããããé²ãæ¹æ³ã