http://laurent.horus.free.fr/Horus.zip
http://laurent.horus.free.fr/Horus.txt
http://laurent.horus.free.fr/horus.jpg
Images and animation synthesis throught chaotic patterns in gravitationnal falling of objects.
/////////////////////////////////////////////////////////////////////
int n;
int cc=0;
float dt;
int EXIT=0;
float TIMESPENT=0.0f;
struct IMAGE_DATAS im;
GESTION_PRESENTATION GP;
PRESENT Page;
int LEVEL_HIGHLIGHT=GLOW;
float K=0.05f;
bool res=true;
Initialise();
Load(filename);
/////////////////////////////////////////////////////////////////////
CPhysicObject *objs[2048];
int tags_objs[2048];
int nobjs=0;
CObject3D *objects[2048];
CObject3D *save[2048];
int meshes[5]={0,1,2,7,8};
CPhysic Physique;
CObject3D * objdup[16];
for (n=0;n<128;n++) tags_objs[n]=0;
Physique.Reset();
for (n=0;nInverse2();
objdup[n]->Calculate();
objdup[n]->CalculateSphereFaceOnCoef1();
Physique.AddMesh(objdup[n],0.1f,0.1f, 3);
}
Physique.SetApproximateTimeCollision(false);
Physique.setStaticDeterminationMethod(1);
Physique.disableScaleTime();
Physique.setNormalStabilization();
Physique.SetIterations(3);
Physique.SetGravity(9.80f);
Physique.enableEvents();
Physique.Init();
/////////////////////////////////////////////////////////////////////
// space-time gravity derivates
float additionnals[60][6]={ // x,y,z rx,ry,rz
{9.9986f,-38.3158f,0.9865f, 0.0000f,0.0000f,0.0000f},
{-8.0014f,-32.3158f,-2.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-32.3158f,-0.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-32.3158f,3.9865f, 0.0000f,0.0000f,0.0000f},
{-5.0014f,-35.3158f,-5.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-35.3158f,1.9865f, 0.0000f,0.0000f,0.0000f},
{-8.0014f,-32.3158f,-7.0135f, 0.0000f,0.0000f,0.0000f},
{-2.0014f,-32.3158f,-10.0135f, 0.0000f,0.0000f,0.0000f},
{10.9986f,-33.3158f,-13.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-35.3158f,-14.0135f, 0.0000f,0.0000f,0.0000f},
{9.9986f,-38.3158f,-9.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-33.3158f,-12.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-38.3158f,4.9865f, 0.0000f,0.0000f,0.0000f},
{-5.0014f,-32.3158f,-0.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-33.3158f,-6.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-32.3158f,-5.0135f, 0.0000f,0.0000f,0.0000f},
{2.9986f,-35.3158f,-8.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-38.3158f,-3.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-38.3158f,-15.0135f, 0.0000f,0.0000f,0.0000f},
{10.9986f,-32.3158f,-4.0135f, 0.0000f,0.0000f,0.0000f},
{9.9986f,-17.3158f,0.9865f, 0.0000f,0.0000f,0.0000f},
{-8.0014f,-11.3158f,-2.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-11.3158f,-0.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-11.3158f,3.9865f, 0.0000f,0.0000f,0.0000f},
{-5.0014f,-14.3158f,-5.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-14.3158f,1.9865f, 0.0000f,0.0000f,0.0000f},
{-8.0014f,-11.3158f,-7.0135f, 0.0000f,0.0000f,0.0000f},
{-2.0014f,-11.3158f,-10.0135f, 0.0000f,0.0000f,0.0000f},
{10.9986f,-12.3158f,-13.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-14.3158f,-14.0135f, 0.0000f,0.0000f,0.0000f},
{9.9986f,-17.3158f,-9.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-12.3158f,-12.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-17.3158f,4.9865f, 0.0000f,0.0000f,0.0000f},
{-5.0014f,-11.3158f,-0.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-12.3158f,-6.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-11.3158f,-5.0135f, 0.0000f,0.0000f,0.0000f},
{2.9986f,-14.3158f,-8.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-17.3158f,-3.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-17.3158f,-15.0135f, 0.0000f,0.0000f,0.0000f},
{10.9986f,-11.3158f,-4.0135f, 0.0000f,0.0000f,0.0000f},
{9.9986f,-27.3158f,0.9865f, 0.0000f,0.0000f,0.0000f},
{-8.0014f,-21.3158f,-2.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-21.3158f,-0.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-21.3158f,3.9865f, 0.0000f,0.0000f,0.0000f},
{-5.0014f,-24.3158f,-5.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-24.3158f,1.9865f, 0.0000f,0.0000f,0.0000f},
{-8.0014f,-21.3158f,-7.0135f, 0.0000f,0.0000f,0.0000f},
{-2.0014f,-21.3158f,-10.0135f, 0.0000f,0.0000f,0.0000f},
{10.9986f,-22.3158f,-13.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-24.3158f,-14.0135f, 0.0000f,0.0000f,0.0000f},
{9.9986f,-27.3158f,-9.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-22.3158f,-12.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-27.3158f,4.9865f, 0.0000f,0.0000f,0.0000f},
{-5.0014f,-21.3158f,-0.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-22.3158f,-6.0135f, 0.0000f,0.0000f,0.0000f},
{-0.0014f,-21.3158f,-5.0135f, 0.0000f,0.0000f,0.0000f},
{2.9986f,-24.3158f,-8.0135f, 0.0000f,0.0000f,0.0000f},
{3.9986f,-27.3158f,-3.0135f, 0.0000f,0.0000f,0.0000f},
{6.9986f,-27.3158f,-15.0135f, 0.0000f,0.0000f,0.0000f},
{10.9986f,-21.3158f,-4.0135f, 0.0000f,0.0000f,0.0000f},
};
Render.FreeTexture(0);
READ_PNG("data/sida/phong1.png",&im,ALPHA1);
Render.CreateTexture(0,im.X,im.ptrImageDATAS,im.X,NO_ALPHA);
free(im.ptrImageDATAS);
READ_PNG("data/sida/rond.png",&im,ALPHA1);
for (n=0;nDuplicate2();
int nt=0;
for (int nn=0;nnnFaces;nn++)
{
Scene.WorldObjectsAdded[n]->Faces[nn].nT=nt;
}
Scene.CreateVertexBufferAdded(n,0);
}
for (n=0;nCoo.Init(additionnals[n][0],additionnals[n][1],additionnals[n][2]);
Scene.WorldObjectsAdded[n]->Rot.Init(0,0,0);
}
for (n=0;nDuplicate2();
objs[n]=new CPhysicObject;
AddObj(objs[n],&Physique,objects[n]);
objs[n]->Pos=objects[n]->Coo;
}
Scene.SetShadowVolumeLength(10.0f);
/////////////////////////////////////////////////////////////////////
READ_PNG("data/sida/phong1.png",&im,ALPHA1);
Render.CreateTexture(2000,im.X,im.ptrImageDATAS,im.X,NO_ALPHA);
free(im.ptrImageDATAS);
/////////////////////////////////////////////////////////////////////
TimeInit();
int TAG=0;
float accu_dt=0.0f;
while (GetTimer()<74)
{
if (GetTimer()>=70) INCREMENT_FADE=-1;
if (TabKeys[KEY_RETURN]) INCREMENT_FADE=-1;
if (!ReadEvents()) EXIT=1;
else
{
if (cc==0) ANIM_Play();
if (Render.BEGIN())
{
Render.ClearVideoAndZBuffer();
Render.SetProjection();
/////////////////////////////////////////////////////////////////////
if (TabKeys[KEY_ESCAPE]) goto _abort;
if (TabKeys[KEY_SPACE])
{
while (TabKeys[KEY_SPACE])
{
if (!ReadEvents()) EXIT=1;
Sleep(10);
}
}
/////////////////////////////////////////////////////////////////////
if (TAG_ANIM_CAMERA==0)
{
SetCamera();
SetFocus();
if (TAG_ATTACH_CAMERA>=0)
Camera=Scene.WorldObjectsAdded[TAG_ATTACH_CAMERA]->Coo;
if (TAG_ATTACH_TARGET>=0)
Target=Scene.WorldObjectsAdded[TAG_ATTACH_TARGET]->Coo;
}
MVIEW.Id();
MVIEW.View(Camera,(Target-Camera),0);
Render.LoadViewMatrix(MVIEW);
Scene.SetCamera(Camera,Target);
for (n=0;nTag2=1;
}
for (n=0;nTag2=1;
}
/////////////////////////////////////////////////////////////////////
for (n=0;nOutput=PROPRIETES_MATRICES;
Scene.WorldObjectsAdded[n]->M=objs[n]->ActualMatrix();
Scene.WorldObjectsAdded[n]->MR=objs[n]->ActualOrientationMatrix();
Scene.toggle_visibility_on_added[n]=1;
}
else Scene.toggle_visibility_on_added[n]=0;
}
Render.ClearVideoAndZBuffer();
Render.SetProjection();
Render.LoadViewMatrix(MVIEW);
Scene.SetCamera(Camera,Target);
Render.SetParams(API3D_ZBUFFER,ON);
Render.SetParams(API3D_BLEND,OFF);
InitGlow();
Render.LoadViewMatrix(MVIEW);
Scene.SetCamera(Camera,Target);
Scene.SetSurface(SECONDARY2);
Scene.DECAL_NT=0;
Scene.SetInverseCulling(false);
Scene.Draw(Camera,Target,Render.GetWidth(),Render.GetHeight(),0,false,false,false,false,0);
Render.SetTexture(2010);
Render.SetParams(API3D_BLEND,BLEND_COLOR);
Render.Quad(0,0,Render.GetWidth(),Render.GetHeight(),0,0,1,1,1,1,1,0.5f);
/////////////////////////////////////////////////////////////////////
Glow(GLOW,0.2f,1.0f);
/////////////////////////////////////////////////////////////////////
int w=Render.SCREEN_X;
int h=Render.SCREEN_Y;
Render.SetParams(API3D_BLEND,ON);
Render.SetTexture(2009);
Render.Quad(0,0,Render.SCREEN_X,Render.SCREEN_Y,0,0,1,1,1,1,1);
Render.SetParams(API3D_BLEND,OFF);
BordsNoirs();
if (EXITPROG_FROM_SCRIPT) EXIT=1;
dt=LEVELEDIT_TIME_DT=TimeGet();
Fade(dt);
Render.END();
Render.FlipDoubleBuffer();
}
/////////////////////////////////////////////////////////////////////
// applying physics
// be carefull : using LCP, must be considered with the law of beauty
// http://laurent.horus.free.fr/beauty.pdf
if (cc==0)
{
if (TAG==0)
{
accu_dt+=dt*0.7f;
float _K=3;
while (accu_dt>_K)
{
accu_dt-=_K;
Physique.SetTimeInterval(0.035f);
Physique.CalculateScene();
}
}
TIMESPENT+=dt;
}
/////////////////////////////////////////////////////////////////////
}
}
goto _skip;
_abort:
res=false;
_skip:
Physique.Reset();
for (n=0;nFree();
delete objdup[n];
}
Scene.Clean();