@ 2004-12-14 @
http://www.tokamakphysics.com - SDK download
http://www.adamdawes.com/programming/tokamak/index.html - Tokamak physics tutorials
¡ã tutorial 3 - ±¸¿Í ½Ç¸°´õ »ý¼º
http://www.codesampler.com/dx9src.htm¡ã tutorial 4 - reset°ú Ãâ·ÂÀ» À§ÇÑ ¹öÅؽº/À妽º ¹öÆÛ Ã¤¿ì±â ¡ã tutorial 5 - ÁöÇü CallBack »ç¿ëÇÏ´Â ¹æ¹ý(ÇÔ¼ö Æ÷ÀÎÅÍ·Î ¹ÞÀ½)
¡ã dx9_tokamak_chain - ¿ÀºêÁ§Æ® »óÀÌ¿¡ joint¸¦ µÎ¾î¼, üÀÎó·³ ¿¬°á(SDK°¡ À־, ¼³¸íÀÌ ¾ï¼ö·Î ºÎ½Ç(??))
¡ã dx9_tokamak_geometry - ¿ÀºêÁ§Æ®¸¦ .XÆÄÀÏÀ» »ç¿ë, neAnimatedBodyÀÇ È¸Àü󸮿Í, ÈûÀ» ¼ÂÆÃÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁÜ ¢¹ âÈÆÀÌ ½±´Ù´Â ¸»°ú ¼ÕÀÌ ³î°í ÀÖ¾î¼, Æ©Å丮¾ó µû¶óÇÏ°í Àִµ¥,
¹°¸®¿£ÁøÀÌ¶ó¼ ±×·±Áö ¸Æ½º¿¡¼ ÇϺ¹ Àû¿ëÇÒ ¶§¿Í °ÅÀÇ ºñ½ÁÇÑ ¼ø¼·Î Àû¿ëµÇ°í,
¢¹ ±Û½ê, ½á¸ÔÀ» ÀÏÀÌ ÀÖÀ»Áö´Â ³ªÁß ÀÏ, Áö±ÝÀº Æ©Å丮¾ó ÇÏ¸é¼ Á¤¸®ÇÏÀÚ.(¹°·Ð ³» ¼Õ °¡´Â´ë·Î ¤»¤»¤» )´Ù¸¥Á¡ÀÌ ÀÖ´Ù¸é UIÀÎÅÍÆäÀ̽º°¡ ¾Æ´Ï¶ó(ÇÊ¿äÇÏ¸é ¸¸µé¾ßÁö ^^;;) ¾ÆÁ÷Àº ÄÚµå·Î Ãijְí, ¸Ó¸®·Î »ó»óÀ» Á»´õ ÇؾߵǴ Á¤µµ·Î ¸Àº¸°í ÀÖÀ½
°ø°³¿£ÁøÀÌÁö¸¸, ¿ª½Ã³ª SDK¿¡ ¸¸Á·ÇÒ ¸¸ÇÑ ¼³¸íÀÌ ºÎÁ·Çؼ ¾Æ´Â¸¸Å Á¤¸®...
¢¹ Head¿¡ Æ÷ÇÔ
#pragma comment(lib, "tokamak.lib")
¢¹ ±¸¼º#include <tokamak.h>
neSimulator * gSim; // ¹°¸®°ø°£
¢º ¹°¸®°ø°£; neSimulator * gSim;neRigidBody * gCubesCUBECOUNT; // Ãæµ¹¹°Ã¼ neAnimatedBody * gFloorFloorCOUNT; // °íÁ¤¹°Ã¼
-1.¹°¸®°ø°£À» ÇØÁ¦ÇÏ¸é °ø°£¿¡ Á¸ÀçÇÏ´Â ¸ðµç ¹°Ã¼´Â ¼Ò°ÅµÈ´Ù.
¢º Ãæµ¹¹°Ã¼; neRigidBody * gCubesCUBECOUNT;if (gSim) { } -2.¼³Á¤
gSim = neSimulator::CreateSimulator(sizeInfo, NULL, &gravity);
neSimulatorSizeInfo sizeInfo; // Ãæµ¹ÀÌ ¹ß»ýÇÏ´Â °ø°£ÀÇ Á¤º¸
sizeInfo.rigidBodiesCount = CUBECOUNT;
sizeInfo.terrainNodesStartCount = 0; sizeInfo.animatedBodiesCount = FloorCOUNT; s32 totalBody = sizeInfo.rigidBodiesCount + sizeInfo.animatedBodiesCount; sizeInfo.geometriesCount = totalBody; // ¹°¸®°ø°£¿¡¼ ó¸®ÇØ¾ßµÉ Àüü¹°Ã¼ÀÇ °¹¼ö(Àû¾î¸é ¹Ù·Î error) sizeInfo.overlappedPairsCount = totalBody * (totalBody - 1) / 2; // Çѹø¿¡ ¾ó¸¶³ª ¸¹Àº ¹°Ã¼µéÀÌ Ãæµ¹ÇÒÁö ¼³Á¤, SDK¿¡¼ ÀÌ·±½ÄÀ¸·Î »ç¿ëÇ϶ó³×¿ä ?? sizeInfo.rigidParticleCount = 0; // ? sizeInfo.constraintsCount = 0; // ? // ÁöÇüÀÌ ¾øÀ» ¶§´Â 0À¸·Î ¼³Á¤ÇÏ°í, ÁöÇüÀÌ ÀÖÀ» ¶§´Â ÀÌ °ªÀ» ¼³Á¤ÇÏÁö ¾Ê´Â´Ù. neV3 gravity; // Áß·Â °¡¼Óµµ(neV3Àº float * 3 ŸÀÔÀÇ º¤ÅÍ)
gravity.Set(0.0f, -10.0f, 0.0f);
-1.¼³Á¤
¢º °íÁ¤¹°Ã¼; neAnimatedBody * gFloorFloorCOUNT;
neGeometry * geom; // ÀÌ Çü½ÄÀ» »ç¿ëÇؼ ¹°Ã¼ÀÇ ¼¼ºÎ»çÇ×À» ¼³Á¤(ÀÚ¼¼ÇÑ ³»¿ë SDK¿¡¼µµ ãÁö ¸øÇÔ)
gCubes[i]->SetInertiaTensor(neBoxInertiaTensor(boxSize1[0], boxSize1[1], boxSize1[2], 1.0f));neV3 boxSize1; // Ã⵿¹Ú½º Å©±â neV3 pos; // À§Ä¡ f32 mass; // Áú·®(Áß·ÂÀ» °¨¾ÈÇÑ´Ù¸é ¹«°Ô°¡ µÊ) gCubes[i] = gSim->CreateRigidBody(); // ¹°¸®°ø°£¿¡¼ ¾î¶² ¿ªÇÒÀ» ÇÒÁö ¼³Á¤
geom = gCubes[i]->AddGeometry();
gCubes[i]->UpdateBoundingInfo(); // Ãæµ¹¹Ú½º ¼³Á¤boxSize1.Set(1.0f, 1.0f, 1.0f); // Ãæµ¹¹Ú½º Å©±â geom->SetBoxSize(boxSize1[0], boxSize1[1], boxSize1[2]); // Ã浹ü¿¡ ´ëÇÑ Æ¯¼º ¼³Á¤ (mass, position, mass inertia tensor.)
mass = 1.0f;
// Tensor °ªÀÌ ³Ê¹« ÀÛÀ¸¸é neAnimatedBody¸¦ ¶Õ°í Áö³ª°£´Ù.(TensorÀÇ Á¾·ù¼³Á¤)
gCubes[i]->SetMass(mass); // Áú·® ¼³Á¤(°ªÀÌ ³Ê¹« Ä¿Áö¸é neAnimatedBody¸¦ ¶Õ°í Áö³ª°£´Ù.)
pos.Set((float)(i) / 4, 3.0f + i*2.0f, (float)(rand()%10) / 100); // ÃʱâÀ§Ä¡ ¼³Á¤
gCubes[i]->SetPos(pos);// Set the angular damping for the object - °ªÀÌ Ä¿Áö¸é Àß ±¸¸£Áö ¾Ê°í, Ãæµ¹ÇßÀ» ¶§ ¸¹ÀÌ Æ¤´Ù. gCubes[i]->SetAngularDamping(0.001f);
-0.°íÁ¤¹°Ã¼´Â mass³ª mass inertia tensorÀÇ ¼³Á¤ÀÌ ÇÊ¿ä¾ø´Ù.
¢º ÁöÇü;-1.¼³Á¤
gFloor = gSim->CreateAnimatedBody(); // ¹°¸®°ø°£¿¡¼ ¾î¶² ¿ªÇÒÀ» ÇÒÁö ¼³Á¤
geom = gFloor[i]->AddGeometry();
gFloor->UpdateBoundingInfo(); // Ãæµ¹¹Ú½º ¼³Á¤ boxSize1.Set(FLOORSIZE, 0.2f, FLOORSIZE); // Ãæµ¹¹Ú½º Å©±â geom->SetBoxSize(boxSize1[0],boxSize1[1],boxSize1[2]);
pos.Set(float(i)*4, -float(i)*3, 0.0f);
gFloor[i]->SetPos(pos); // ÃʱâÀ§Ä¡ ¼³Á¤
-0.gSim->SetTerrainMesh( neTriangleMesh &triMesh ); // triMesh¸¦ ä¿ì´Â ¹æ½ÄÀ¸·Î
Ãæµ¹/ °íÁ¤¹°Ã¼¿Í´Â ´Ù¸£°Ô 󸮵ǰí,
-1.¼³Á¤tutorial 4¿¡¼´Â D3DPT_TRIANGLELIST¹æ½ÄÀ¸·Î »ï°¢ÇüÀ» ä¿î´Ù.
neTriangleMesh triMesh; // ¹°¸®°ø°£¿¡ ÁöÇüÀ» ä¿î´Ù.
-9.ÁÖÀÇ
neV3 triVerticesTERRAIN_VERTEXCOUNT; // ÁöÇüÀÇ ¹öÅؽº Á¤º¸¸¦ ä¿î´Ù.
gSim->SetTerrainMesh(&triMesh);neTriangle triDataTERRAIN_TRIANGLECOUNT; // ÁöÇüÀÇ ¸é Á¤º¸¸¦ ä¿î´Ù.
triMesh.vertexCount = TERRAIN_VERTEXCOUNT;
triMesh.vertices = triVertices; triMesh.triangles = triData; // Set the triangles into the triMesh
¹°¸®°ø°£ÀÇ sizeInfo.terrainNodesStartCountÀÇ Á¤º¸¸¦ ¼³Á¤ÇÏÁö ¾Ê´Â´Ù.
// No need to tell Tokamak about our terrain nodes, the sizeInfo's default values will suffice ( tutorial 4ÀÇ ÁÖ¼®) ¢¹ º¯È(¿ª½Ã ¹°¸®¿£Áø¿£ ½Ã°£º¯¼ö°¡ º¯¼ö°¡ Ä£±¸^^*)
-1.loop°¡ µ¹ ¶§¸¶´Ù, µ¨Å¸½Ã°£À» ³Ö¾îÁÖ¸é ÀÚµ¿À¸·Î ¹°Ã¼µéÀÇ À§Ä¡¸¦ °è»ê
gSim->Advance(0.01f);
-2.ResetÀ» Çϱâ À§Çؼ´Â ¿ÀºêÁ§Æ®ÀÇ À§Ä¡, ¼Óµµ, ȸÀü, ȸÀü¸ð¿ì¸àÆ®¸¦ ÃʱâÈ ½ÃŲ´Ù.
(tokamakÀÇ ÀÎÅÍÆäÀ̽º¸¸ ¾Ë°í, ³»ºÎ »çÁ¤À» Àß ¸ð¸£±â ¶§¹®¿¡ ÀÎÅÍÆäÀ̽º¿¡ ¸ÂÃç¼ ÃʱâÈ ½ÃÅ´)
-3.°£´ÜÇÏ°Ô ¹°¸®°ø°£À» ÇØÁ¦ÇÏ°í, ´Ù½Ã ¸¸µé¾î¼ ÃʱâÈ ½Ãų ¼ö ÀÖÁö¸¸,neV3 pos; neV3 force; neM3 gCubes_InitM3;
force.Set( 0.0f, 0.0f, 0.0f );
for ( int i=0; i<CUBECOUNT; ++i){
gCubes[i]->SetRotation( gCubes_InitM3 ); // ȸÀü°ªÀ» ÃʱâÈ
}
pos.Set((float)(i) / 4, 3.0f + i*2.0f, (float)(rand()%10) / 100);
gCubes[i]->SetPos(pos); // À§Ä¡¸¦ ÃʱâÈgCubes[i]->SetVelocity( force ); // ¼Óµµ¸¦ ÃʱâÈ gCubes[i]->SetAngularMomentum( force );
Áö±ÝÀÇ »óÅ¿¡¼ ´ÙÀ½ º¯È¸¦ ÁÖ±â À§Çؼ´Â ³»ºÎ »óÅ°ªÀ» ¿øÇÏ´Â °ªÀ» ¼ÂÆÃÇؼ »ç¿ëÇØ¾ß ÇÑ´Ù.
¢¹ Ãæµ¹¹Ú½ºÀÇ ¸ð¾ç¿¡ µû¶ó ÆĶó¹ÌÅÍ Çü½ÄÀÌ Á¶±Ý¾¿ ´Ù¸£´Ù.
-1.Box
boxSize1.Set(1.0f, 1.0f, 1.0f); // Ãæµ¹¹Ú½º Å©±â
gCubes[i]->UpdateBoundingInfo(); // Ãæµ¹¹Ú½º ¼³Á¤geom->SetBoxSize(boxSize1[0], boxSize1[1], boxSize1[2]); -2.Sphere
geom->SetSphereDiameter(SPHEREDIAM);
gSpheres[i]->UpdateBoundingInfo();-3.Cylinder
geom->SetCylinder(CYLINDERDIAM, CYLINDERHEIGHT);
gCylinders[i]->UpdateBoundingInfo();
¢¹ CallBack ÇÔ¼ö°¡ ÇÔ¼ö Æ÷ÀÎÅ͸¦ ¹Þ´Â´Ù´Â Á¡¿¡ ÁÖÀÇÇؼ tutorial 5¸¦ Âü°í.
void SetTerrainTriangleQueryCallback(neTerrainTriangleQueryCallback * cb);
neTerrainTriangleQueryCallback * GetTerrainTriangleQueryCallback(); -1.¿ÀºêÁ§Æ®¿Í Ãæµ¹ÇÏ´Â TriangleÀÇ °ËÃâ ±âÁØÀÌ µÇ´Â neTriangleMesh¸¦ °¡°øÇÒ ¶§´Â
neTriangleMesh¸¦ ±¸¼ºÇÏ´Â neV3¿Í neTriangle ¹è¿À» ¹¾î¼ °°Àº (Àü¿ª)Çü½ÄÀ¸·Î ó¸®ÇÑ´Ù!
-2.¹°¸®¿£Áø ¼³Á¤½Ã, ¿ÀºêÁ§Æ®¿¡ °íÀ¯ ¹øÈ£¸¦ ºÎ¿©ÇÏ°í(gSpheres[i]->SetUserData(i);) CallBackÇÔ¼ö¸¦ È£ÃâÇÏ´Â °ÍÀ¸·Î ¼³Á¤À» ¸¶Ä¥ ¼ö ÀÖÀ¸¸ç, Tokamak¿¡ ¸Â´Â Çü½ÄÀ¸·Î TriangleÀ» ä¿î´Ù.
¢¹ º¯¼ö
-1.±âº»Á¤ÀÇ
¡Þ ¿ÜºÎÀÇ ¿µÇâÀ» À̵¿ÇÏ°í, ȸÀüÇÑ °á°ú¸¦ ´ÙÀÌ·ºÆ®X(API)¿¡ Àû¿ëÇϱâ À§Çؼ´Â
typedef _ float _ f32;
-2.neV3 ÇüÀº floatÇü 3°³ÀÇ °ªÀ» ¹Þ¾Æ º¤Å͸¦ Ç¥Çö( typedef float f32 ); typedef _ double _ f64;
neV3 pos;
-3.neM3 ÇüÀº ȸÀüÀ» Ç¥ÇöÇϱâ À§ÇÑ ±¸Á¶Ã¼pos.Set(0.0f, -10.0f, 0.0f);
struct neM3
{ neV3 M[3]; ÇÔ¼ö()...·Î ±¸¼º }
tokamak¿¡¼ °è»êµÈ °á°ú¸¦ Wroldº¯È¯ ¸ÅÆ®¸¯½º·Î °ªÀ¸·Î º¯È¯½ÃÄѼ Àû¿ë½ÃÄÑ ÁÖ´Â ¹æ½ÄÀ¸·Î »ç¿ëÇÏ¸é µÇ´Âµ¥,
¢¹ dx9_tokamak_chain¿¡ º¸´Â ¹Ù¿Í °°ÀÌ, °üÀýó·³ »ç¿ëÇÒ ¼ö ÀÖ´Â joint¿¡ ´ëÇÑ ¼³Á¤µµ ÀÖ°í,½ºÇÉ(ȸÀü)µµ °¡Áö±â ¶§¹®¿¡ ¹°Ã¼ÀÇ Æ¯¼ºÀ» ³ªÅ¸³»´Â Ư¼ºÄ¡ ¼³Á¤¿¡ ÁÖÀÇ°¡ ÇÊ¿äÇÏ´Ù. -.¼³Á¤ °ª¿¡ µû¶ó °úµµÇÏ°Ô Æ¢±âµµ ÇÏ°í, °íÁ¤¹°À» ¶Õ°í Áö³ª°¡±â ¶§¹®¿¡ Å×½ºÆ®°¡ ÇÊ¿ä
º¯¼öµéÀ» º¸¸é ÆÄƼŬÀ» ó¸®ÇÏ´Â ºÎºÐµµ ÀÖÁö¸¸ ¿©±â¿¡ °üÇÑ Á¤º¸´Â tutorial¿¡¼ ãÀ» ¼ö ¾øÁö¸¸, Âü°í·Î tokamakȨ¿¡ Forum¿¡ ¿©±â¼ ´Ù·çÁö ¾Ê´Â ºÎºÐ¿¡ °üÇÑ ³»¿ëÀÌ ÀÖ´Ù.
¸Þ¸ðÀåÀ¸·Î °¡±â
|
¿À´ÃÀÇ ½ÇÆд Áö³³¯ÀÇ ÇãºñÇÑ ½Ã°£µéÀÇ º¹¼ö´Ù(³ªÆú·¹¿Ë) BoardMacro WinInet_´Ù¿î·Îµå/¾÷·Îµå_ÁøÇàÁ¤º¸ µüÁö_±Û·Î¹ú°ÔÀÓ»ê¾÷Trend_2012 Ã¥°¥ÇÇ_Games |