MoniWikiµüÁö_Tokamak
Login:
Password:
´ë¹®|ã±â|¹Ù²ï±Û|¸ñ·Ï|¸Þ¸ðÀå|Ã¥°¥ÇÇ|¿¬²É|¸µÅ©
Edit Diff Reload Search Print Info Mail Help RSS

@ 2004-12-14 @

  the Tokamak physics engine
http://www.tokamakphysics.com - SDK download
http://www.adamdawes.com/programming/tokamak/index.html - Tokamak physics tutorials
¡ã tutorial 3 - ±¸¿Í ½Ç¸°´õ »ý¼º
¡ã tutorial 4 - reset°ú Ãâ·ÂÀ» À§ÇÑ ¹öÅؽº/À妽º ¹öÆÛ Ã¤¿ì±â
¡ã tutorial 5 - ÁöÇü CallBack »ç¿ëÇÏ´Â ¹æ¹ý(ÇÔ¼ö Æ÷ÀÎÅÍ·Î ¹ÞÀ½)
http://www.codesampler.com/dx9src.htm
¡ã dx9_tokamak_chain - ¿ÀºêÁ§Æ® »óÀÌ¿¡ joint¸¦ µÎ¾î¼­, üÀÎó·³ ¿¬°á(SDK°¡ À־, ¼³¸íÀÌ ¾ï¼ö·Î ºÎ½Ç(??))
¡ã dx9_tokamak_geometry - ¿ÀºêÁ§Æ®¸¦ .XÆÄÀÏÀ» »ç¿ë, neAnimatedBodyÀÇ È¸Àü󸮿Í, ÈûÀ» ¼ÂÆÃÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁÜ

¢¹ âÈÆÀÌ ½±´Ù´Â ¸»°ú ¼ÕÀÌ ³î°í À־, Æ©Å丮¾ó µû¶óÇÏ°í Àִµ¥,
¹°¸®¿£ÁøÀÌ¶ó¼­ ±×·±Áö ¸Æ½º¿¡¼­ ÇϺ¹ Àû¿ëÇÒ ¶§¿Í °ÅÀÇ ºñ½ÁÇÑ ¼ø¼­·Î Àû¿ëµÇ°í,
´Ù¸¥Á¡ÀÌ ÀÖ´Ù¸é UIÀÎÅÍÆäÀ̽º°¡ ¾Æ´Ï¶ó(ÇÊ¿äÇÏ¸é ¸¸µé¾ßÁö ^^;;)
¾ÆÁ÷Àº ÄÚµå·Î Ãijְí, ¸Ó¸®·Î »ó»óÀ» Á»´õ ÇؾߵǴ Á¤µµ·Î ¸Àº¸°í ÀÖÀ½
¢¹ ±Û½ê, ½á¸ÔÀ» ÀÏÀÌ ÀÖÀ»Áö´Â ³ªÁß ÀÏ, Áö±ÝÀº Æ©Å丮¾ó Çϸ鼭 Á¤¸®ÇÏÀÚ.(¹°·Ð ³» ¼Õ °¡´Â´ë·Î ¤»¤»¤» )
°ø°³¿£ÁøÀÌÁö¸¸, ¿ª½Ã³ª SDK¿¡ ¸¸Á·ÇÒ ¸¸ÇÑ ¼³¸íÀÌ ºÎÁ·Çؼ­ ¾Æ´Â¸¸Å­ Á¤¸®...

          # ±âº» ±¸Á¶
          # mass inertia tensor ¼³Á¤
          # ÁöÇü CallBack ¼³Á¤½Ã ÁÖÀÇÁ¡
          # ±âŸ
{_r} ¸Þ¸ðÀåÀ¸·Î °¡±â


    ¡Ý ±âº» ±¸Á¶
¢¹ Head¿¡ Æ÷ÇÔ
#pragma comment(lib, "tokamak.lib")
#include <tokamak.h>
¢¹ ±¸¼º
neSimulator * gSim; // ¹°¸®°ø°£
neRigidBody * gCubesCUBECOUNT; // Ãæµ¹¹°Ã¼
neAnimatedBody * gFloorFloorCOUNT; // °íÁ¤¹°Ã¼
¢º ¹°¸®°ø°£; neSimulator * gSim;
-1.¹°¸®°ø°£À» ÇØÁ¦ÇÏ¸é °ø°£¿¡ Á¸ÀçÇÏ´Â ¸ðµç ¹°Ã¼´Â ¼Ò°ÅµÈ´Ù.
if (gSim)
{
neSimulator::DestroySimulator(gSim);
gSim = NULL;
}
-2.¼³Á¤
gSim = neSimulator::CreateSimulator(sizeInfo, NULL, &gravity);
neSimulatorSizeInfo sizeInfo; // Ãæµ¹ÀÌ ¹ß»ýÇÏ´Â °ø°£ÀÇ Á¤º¸
sizeInfo.rigidBodiesCount = CUBECOUNT;
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À¸·Î ¼³Á¤ÇÏ°í, ÁöÇüÀÌ ÀÖÀ» ¶§´Â ÀÌ °ªÀ» ¼³Á¤ÇÏÁö ¾Ê´Â´Ù.
(_cr) sizeInfo.terrainNodesStartCount = 0;
neV3 gravity; // Áß·Â °¡¼Óµµ(neV3Àº float * 3 ŸÀÔÀÇ º¤ÅÍ)
gravity.Set(0.0f, -10.0f, 0.0f);
¢º Ãæµ¹¹°Ã¼; neRigidBody * gCubesCUBECOUNT;
-1.¼³Á¤
neGeometry * geom; // ÀÌ Çü½ÄÀ» »ç¿ëÇؼ­ ¹°Ã¼ÀÇ ¼¼ºÎ»çÇ×À» ¼³Á¤(ÀÚ¼¼ÇÑ ³»¿ë SDK¿¡¼­µµ ãÁö ¸øÇÔ)
neV3 boxSize1; // Ã⵿¹Ú½º Å©±â
neV3 pos; // À§Ä¡
f32 mass; // Áú·®(Áß·ÂÀ» °¨¾ÈÇÑ´Ù¸é ¹«°Ô°¡ µÊ)

gCubes[i] = gSim->CreateRigidBody(); // ¹°¸®°ø°£¿¡¼­ ¾î¶² ¿ªÇÒÀ» ÇÒÁö ¼³Á¤
geom = gCubes[i]->AddGeometry();
boxSize1.Set(1.0f, 1.0f, 1.0f); // Ãæµ¹¹Ú½º Å©±â
geom->SetBoxSize(boxSize1[0], boxSize1[1], boxSize1[2]);
gCubes[i]->UpdateBoundingInfo(); // Ãæµ¹¹Ú½º ¼³Á¤
// Ã浹ü¿¡ ´ëÇÑ Æ¯¼º ¼³Á¤ (mass, position, mass inertia tensor.)
mass = 1.0f;
(_cr) gCubes[i]->SetInertiaTensor(neBoxInertiaTensor(boxSize1[0], boxSize1[1], boxSize1[2], 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);

¢º °íÁ¤¹°Ã¼; neAnimatedBody * gFloorFloorCOUNT;
-0.°íÁ¤¹°Ã¼´Â mass³ª mass inertia tensorÀÇ ¼³Á¤ÀÌ ÇÊ¿ä¾ø´Ù.
-1.¼³Á¤
gFloor = gSim->CreateAnimatedBody(); // ¹°¸®°ø°£¿¡¼­ ¾î¶² ¿ªÇÒÀ» ÇÒÁö ¼³Á¤
geom = gFloor[i]->AddGeometry();
boxSize1.Set(FLOORSIZE, 0.2f, FLOORSIZE); // Ãæµ¹¹Ú½º Å©±â
geom->SetBoxSize(boxSize1[0],boxSize1[1],boxSize1[2]);
gFloor->UpdateBoundingInfo(); // Ãæµ¹¹Ú½º ¼³Á¤
pos.Set(float(i)*4, -float(i)*3, 0.0f);
gFloor[i]->SetPos(pos); // ÃʱâÀ§Ä¡ ¼³Á¤

¢º ÁöÇü;
-0.gSim->SetTerrainMesh( neTriangleMesh &triMesh ); // triMesh¸¦ ä¿ì´Â ¹æ½ÄÀ¸·Î
Ãæµ¹/ °íÁ¤¹°Ã¼¿Í´Â ´Ù¸£°Ô 󸮵ǰí,
tutorial 4¿¡¼­´Â D3DPT_TRIANGLELIST¹æ½ÄÀ¸·Î »ï°¢ÇüÀ» ä¿î´Ù.
-1.¼³Á¤
neTriangleMesh triMesh; // ¹°¸®°ø°£¿¡ ÁöÇüÀ» ä¿î´Ù.
neV3 triVerticesTERRAIN_VERTEXCOUNT; // ÁöÇüÀÇ ¹öÅؽº Á¤º¸¸¦ ä¿î´Ù.
neTriangle triDataTERRAIN_TRIANGLECOUNT; // ÁöÇüÀÇ ¸é Á¤º¸¸¦ ä¿î´Ù.
triMesh.vertexCount = TERRAIN_VERTEXCOUNT;
triMesh.vertices = triVertices;
triMesh.triangles = triData; // Set the triangles into the triMesh
gSim->SetTerrainMesh(&triMesh);
-9.ÁÖÀÇ
¹°¸®°ø°£ÀÇ 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ÀÇ ÀÎÅÍÆäÀ̽º¸¸ ¾Ë°í, ³»ºÎ »çÁ¤À» Àß ¸ð¸£±â ¶§¹®¿¡ ÀÎÅÍÆäÀ̽º¿¡ ¸ÂÃç¼­ ÃʱâÈ­ ½ÃÅ´)
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 );
}
-3.°£´ÜÇÏ°Ô ¹°¸®°ø°£À» ÇØÁ¦ÇÏ°í, ´Ù½Ã ¸¸µé¾î¼­ ÃʱâÈ­ ½Ãų ¼ö ÀÖÁö¸¸,
Áö±ÝÀÇ »óÅ¿¡¼­ ´ÙÀ½ º¯È­¸¦ ÁÖ±â À§Çؼ­´Â ³»ºÎ »óÅ°ªÀ» ¿øÇÏ´Â °ªÀ» ¼ÂÆÃÇؼ­ »ç¿ëÇØ¾ß ÇÑ´Ù.


    ¡Ý mass inertia tensor ¼³Á¤
¢¹ Ãæµ¹¹Ú½ºÀÇ ¸ð¾ç¿¡ µû¶ó ÆĶó¹ÌÅÍ Çü½ÄÀÌ Á¶±Ý¾¿ ´Ù¸£´Ù.
-1.Box
boxSize1.Set(1.0f, 1.0f, 1.0f); // Ãæµ¹¹Ú½º Å©±â
geom->SetBoxSize(boxSize1[0], boxSize1[1], boxSize1[2]);
gCubes[i]->UpdateBoundingInfo(); // Ãæµ¹¹Ú½º ¼³Á¤
-2.Sphere
geom->SetSphereDiameter(SPHEREDIAM);
gSpheres[i]->UpdateBoundingInfo();
-3.Cylinder
geom->SetCylinder(CYLINDERDIAM, CYLINDERHEIGHT);
gCylinders[i]->UpdateBoundingInfo();


    ¡Ý ÁöÇü CallBack ¼³Á¤½Ã ÁÖÀÇÁ¡
¢¹ CallBack ÇÔ¼ö°¡ ÇÔ¼ö Æ÷ÀÎÅ͸¦ ¹Þ´Â´Ù´Â Á¡¿¡ ÁÖÀÇÇؼ­ tutorial 5¸¦ Âü°í.
void SetTerrainTriangleQueryCallback(neTerrainTriangleQueryCallback * cb);
neTerrainTriangleQueryCallback * GetTerrainTriangleQueryCallback();
-1.¿ÀºêÁ§Æ®¿Í Ãæµ¹ÇÏ´Â TriangleÀÇ °ËÃâ ±âÁØÀÌ µÇ´Â neTriangleMesh¸¦ °¡°øÇÒ ¶§´Â
neTriangleMesh¸¦ ±¸¼ºÇÏ´Â neV3¿Í neTriangle ¹è¿­À» ¹­¾î¼­ °°Àº (Àü¿ª)Çü½ÄÀ¸·Î ó¸®ÇÑ´Ù!
-2.¹°¸®¿£Áø ¼³Á¤½Ã, ¿ÀºêÁ§Æ®¿¡ °íÀ¯ ¹øÈ£¸¦ ºÎ¿©ÇÏ°í(gSpheres[i]->SetUserData(i);) CallBackÇÔ¼ö¸¦ È£ÃâÇÏ´Â °ÍÀ¸·Î ¼³Á¤À» ¸¶Ä¥ ¼ö ÀÖÀ¸¸ç, Tokamak¿¡ ¸Â´Â Çü½ÄÀ¸·Î TriangleÀ» ä¿î´Ù.


    ¡Ý ±âŸ
¢¹ º¯¼ö
-1.±âº»Á¤ÀÇ
typedef _ float _ f32;
typedef _ double _ f64;
-2.neV3 ÇüÀº floatÇü 3°³ÀÇ °ªÀ» ¹Þ¾Æ º¤Å͸¦ Ç¥Çö( typedef float f32 );
neV3 pos;
pos.Set(0.0f, -10.0f, 0.0f);
-3.neM3 ÇüÀº ȸÀüÀ» Ç¥ÇöÇϱâ À§ÇÑ ±¸Á¶Ã¼
struct neM3
{ neV3 M[3];
ÇÔ¼ö()...·Î ±¸¼º }
¡Þ ¿ÜºÎÀÇ ¿µÇâÀ» À̵¿ÇÏ°í, ȸÀüÇÑ °á°ú¸¦ ´ÙÀÌ·ºÆ®X(API)¿¡ Àû¿ëÇϱâ À§Çؼ­´Â
tokamak¿¡¼­ °è»êµÈ °á°ú¸¦ Wroldº¯È¯ ¸ÅÆ®¸¯½º·Î °ªÀ¸·Î º¯È¯½ÃÄѼ­ Àû¿ë½ÃÄÑ ÁÖ´Â ¹æ½ÄÀ¸·Î »ç¿ëÇÏ¸é µÇ´Âµ¥,
½ºÇÉ(ȸÀü)µµ °¡Áö±â ¶§¹®¿¡ ¹°Ã¼ÀÇ Æ¯¼ºÀ» ³ªÅ¸³»´Â Ư¼ºÄ¡ ¼³Á¤¿¡ ÁÖÀÇ°¡ ÇÊ¿äÇÏ´Ù.
-.¼³Á¤ °ª¿¡ µû¶ó °úµµÇÏ°Ô Æ¢±âµµ ÇÏ°í, °íÁ¤¹°À» ¶Õ°í Áö³ª°¡±â ¶§¹®¿¡ Å×½ºÆ®°¡ ÇÊ¿ä
¢¹ dx9_tokamak_chain¿¡ º¸´Â ¹Ù¿Í °°ÀÌ, °üÀýó·³ »ç¿ëÇÒ ¼ö ÀÖ´Â joint¿¡ ´ëÇÑ ¼³Á¤µµ ÀÖ°í,
º¯¼öµéÀ» º¸¸é ÆÄƼŬÀ» ó¸®ÇÏ´Â ºÎºÐµµ ÀÖÁö¸¸ ¿©±â¿¡ °üÇÑ Á¤º¸´Â tutorial¿¡¼­ ãÀ» ¼ö ¾øÁö¸¸, Âü°í·Î tokamakȨ¿¡ Forum¿¡ ¿©±â¼­ ´Ù·çÁö ¾Ê´Â ºÎºÐ¿¡ °üÇÑ ³»¿ëÀÌ ÀÖ´Ù.


{_r} ¸Þ¸ðÀåÀ¸·Î °¡±â

November, 2024
 12
3456789
10111213141516
17181920212223
24252627282930

¿À´ÃÀÇ ½ÇÆд Áö³­³¯ÀÇ ÇãºñÇÑ ½Ã°£µéÀÇ º¹¼ö´Ù(³ªÆú·¹¿Ë)

BoardMacro
WinInet_´Ù¿î·Îµå/¾÷·Îµå_ÁøÇàÁ¤º¸
µüÁö_±Û·Î¹ú°ÔÀÓ»ê¾÷Trend_2012
Ã¥°¥ÇÇ_Games
last modified 2005-01-20 06:17:19
°íÄ¡±â|ã±â|ÂÊ Áö¿ì±â|ºñ½ÁÇÑ ÂÊ Valid XHTML 1.0! Valid CSS! powerd by MoniWiki
0.2028 sec