Code:
#include "stdafx.h"
#include "Chat.h"
#include "../Data/enum/_enums.h"
Str i;
Str Anim1="Anim/Kosti/p1_wait.anim",
Anim2="Anim/Kosti/p2_wait.anim",
Anim3="Anim/Kosti/p3_wait.anim";
Flt Frame,gon;
Struct_Chat Chat;
Flt point;
Skeleton *skel;
Vec Pos[4],gon_vec;
Motion Motions;
void UpdateAnim(Game::Animatable *ObjAnimatable,Str PathAnimation,Flt Time)
{
ObjAnimatable->cskel.clear().animate(PathAnimation,Time).updateMatrix(ObjAnimatable->matrix()).updateVelocities(false);
}
void UpdateFrames(Flt Speed)
{
if(Time.time()){ Frame=Frame+Speed;if (Frame>(0.999))Frame=0.000;}
}
Game::ObjMemx<Game::Static> Statics;
Game::ObjMemx<Game::Animatable>ObjAnimatable;
Game::ObjMemx<Game::ObjParticles> ObjParticles;
Game::ObjMemx<Game::Item> ObjItem;
Game::ObjMemx<Game::ObjLightPoint> ObjLightPoint;
void InitPre()
{
App.name("World Manager");
App.flag=APP_MS_EXCLUSIVE|APP_FULL_TOGGLE;
DataPath("../data");
Paks.add("engine.pak");
D.full(true).hpRt(true).hdr(true).volLight(true).sync(true);//.superSample(4);
}
Bool Init()
{
Cam.set(Vec(29,15,-3)).dist=22;
Cam.yaw=0.910;Cam.pitch=-0.650;
Physics.create(CSS_NONE,true,"../Installation/PhysX");
Game::World.init();
Game::World.setObjType(Statics,OBJ_STATIC)
.setObjType(ObjParticles,OBJ_PARTICLES)
.setObjType(ObjLightPoint,OBJ_LIGHT_POINT)
.setObjType(ObjItem,OBJ_ITEM)
.setObjType(ObjAnimatable,OBJ_ANIMATABLE);
Game::World.New("World/worldkosti.world");
Game::World.update(Cam.at);
Gui.kb_lit.zero();
Chat.Init_Chat();
Chat.Chat_Obj.getWindow("window_chat").pos(Vec2( (D.w()-(D.w()*2)+0.057 ) ,D.h()-1.32 ));
Physics.gravity(Vec(0,-40,0));
FREP(5){ObjItem[i].actor.active(false);}
return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
if(Kb.bp(KB_ESC))return false;
CamHandle(3.0f,22,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));
Game::World.update(Cam.at);
Gui.update();
UpdateFrames(0.0035);
if(Kb.bp(KB_S))Renderer.screenShots("C:/scrin/","jpg");
if(Kb.bp(KB_SPACE))
{
Pos[0]=Vec(29.641,17,-2.182);Pos[1]=Vec(29.641,17,-1.574);Pos[2]=Vec(29.021,17,-2.156);Pos[3]=Vec(29.021,17,-1.552);Pos[4]=Vec(28.378,17,-1.870); //устанавливаем стартовые позиции кубиков для броска
FREP(ObjItem.elms())
{
ObjItem[i].matrix(Matrix(ObjItem[i].matrix().rotateXY(Random.f(45),Random.f(45)))); //рандомно крутим матрицу кубика
ObjItem[i].pos(Pos[i]);ObjItem[i].actor.active(true);
// ObjItem[i].actor.mass(10);
ObjItem[i].actor.addImpulse(Vec(0,-2,0));
}
}
// skel=ObjItem[4].skeleton;
//point=skel->findPoint("1")->pos.x;
point=ObjItem[4].skeleton->findPoint("1")->pos.x;
UpdateAnim(&ObjAnimatable[0],Anim1,Frame);
UpdateAnim(&ObjAnimatable[1],Anim2,Frame);
UpdateAnim(&ObjAnimatable[2],Anim3,Frame);
return true;
}
/******************************************************************************/
void Render()
{
Game::World.draw();
}
void Draw()
{
Renderer(Render);
D.text(0,0,S+point);
// D.text(0,0.1,S+Time.fps());
Gui.draw();
}
/******************************************************************************/