Beispiel #1
0
PawnEntity::PawnEntity(PawnColor color)
{
	setColor(color);
	initAnimations();
	createCrosshair();
	health = 100;
}
void AppConfig::initCache()
{
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(BACKGROUND_PLIST);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(GLOBAL_PLIST);
	setGlobalBatchNode(CCSpriteBatchNode::create(GLOBAL_IMAGE));
	initAnimations();
	initParticleBatchNodes();
}
Beispiel #3
0
Model::Model(Engine* engine, core::Program* program,
             const std::string& shapePath) :
	IFocusable(engine),
	Programmable(program),
#ifdef FILLWAVE_MODEL_LOADER_ASSIMP
	mAnimator(nullptr),
	mActiveAnimation(FILLWAVE_DO_NOT_ANIMATE),
#endif /* FILLWAVE_MODEL_LOADER_ASSIMP */
	mLights(engine->getLightSystem()) {

#ifdef FILLWAVE_MODEL_LOADER_ASSIMP
	const aiScene* scene = engine->getModelFromFile(shapePath);

	if (scene) {
		initAnimations(scene);
		initShadowing(engine);
		initUniformsCache();
		loadNodes(scene->mRootNode, scene, engine, this);
	} else {
		FLOG_FATAL("Model: %s could not be read", shapePath.c_str());
	}
#else
	std::vector<tinyobj::shape_t> shapes;
	std::vector<tinyobj::material_t> materials;
	tinyobj::attrib_t attrib;
	std::string err;
	if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &err, shapePath.c_str())) {
		FLOG_FATAL("Model: %s could not be read", shapePath.c_str());
	}
	if (!err.empty()) { // `err` may contain warning message.
		FLOG_WARNING("%s", err.c_str());
	}

	initShadowing(engine);
	for (GLuint i = 0; i < shapes.size(); i++) {
		if (shapes[i].mesh.material_ids.empty()) {
			FLOG_FATAL("No materials available");
		}

		int materialId = shapes[i].mesh.material_ids[0];
		if (materialId != -1) {
			attach(loadMesh(shapes[i], attrib,
			                Material(materials[materialId]),
			                engine->storeTexture(materials[materialId].diffuse_texname),
			                engine->storeTexture(materials[materialId].bump_texname),
			                engine->storeTexture(materials[materialId].specular_texname),
			                engine));
			continue;
		}
		attach(loadMesh(shapes[i], attrib,
		                Material(),
		                nullptr,
		                nullptr,
		                nullptr,
		                engine));
	}
#endif
}
Beispiel #4
0
IceProjectile::IceProjectile(std::string image, float height, float damage, DamageType damageType, float flightSpeed, float slowMultiplicatorBy,
		float slowDuration, std::string info, int numOfSlowedTargets, float rangeOfSlow) :
		Projectile(image, height, damage, damageType, flightSpeed) {
	initAnimations(); //loading the pictures and set the animations
	_slowMultiplicatorBy = slowMultiplicatorBy;
	_slowDuration = slowDuration;
	_projectileInfo = info;
	_numOfSlowedTargets = numOfSlowedTargets;
	_rangeOfSlow = rangeOfSlow;
}
Beispiel #5
0
Sheep::Sheep(int addCost, float runSpeed, float hitPoints, Attack* attack, Armour* armour, std::list<Skill*> skills, float mana,
		float manaRegPerSeconds) :
		MoveAbleUnit(addCost, "sheep_walk0001.png", 40, runSpeed, hitPoints, attack, armour, skills, mana, manaRegPerSeconds) {
	initAnimations(); //loading the pictures and set the animations

	_normalButtonImage = "pSheep0.png";
	_selectedButtonImage = "pSheep1.png";
	_disabledButtonImage = "pSheep2.png";
	_unitName = "Sheep";
	_attackEffectSound = "sound_attack_sheep";
}
Beispiel #6
0
Troll::Troll(int addCost, float runSpeed, float hitPoints, Attack* attack, Armour* armour, std::list<Skill*> skills, float mana,
		float manaRegPerSeconds) :
		MoveAbleUnit(addCost, "troll_attack0001.png", 100, runSpeed, hitPoints, attack, armour, skills, mana, manaRegPerSeconds) {
	initAnimations(); //loading the pictures and set the animations
	_hitBox = BW_Rect(40, 90);

	_normalButtonImage = "pTroll0.png";
	_selectedButtonImage = "pTroll1.png";
	_disabledButtonImage = "pTroll2.png";
	_unitName = "Troll";
	_attackEffectSound = "sound_attack_sword";
}
Beispiel #7
0
FlareAntlion::FlareAntlion(int addCost, float runSpeed, float hitPoints, Attack* attack, Armour* armour, std::list<Skill*> skills,
		float mana, float manaRegPerSeconds) :
		MoveAbleUnit(addCost, "flare_antlion_attack0001.png", 80, runSpeed, hitPoints, attack, armour, skills, mana, manaRegPerSeconds) {
	initAnimations(); //loading the pictures and set the animations
	_hitBox = BW_Rect(30, 70);

	_normalButtonImage = "pFlareAntlion1.png";
	_selectedButtonImage = "pFlareAntlion2.png";
	_disabledButtonImage = "pFlareAntlion3.png";
	_unitName = "Antlion";
	_attackEffectSound = "sound_attack_antlion";
}
Beispiel #8
0
Tank::Tank(int addCost, float runSpeed, float hitPoints, Attack* attack, Armour* armour, std::list<Skill*> skills, float mana,
		float manaRegPerSeconds) :
		MoveAbleUnit(addCost, "tank_fires0001.png", 150, runSpeed, hitPoints, attack, armour, skills, mana, manaRegPerSeconds) {
	initAnimations(); //loading the pictures and set the animations
	_hitBox = BW_Rect(30, 70);

	_normalButtonImage = "pTank1.png";
	_selectedButtonImage = "pTank2.png";
	_disabledButtonImage = "pTank3.png";
	_unitName = "Tank";
	_attackEffectSound = "sound_attack_explosion";
}
Beispiel #9
0
BotanicMage::BotanicMage(int addCost, float runSpeed, float hitPoints, Attack* attack, Armour* armour, std::list<Skill*> skills, float mana,
		float manaRegPerSeconds) :
		MoveAbleUnit(addCost, "botanic_mage_attack00001.png", 80, runSpeed, hitPoints, attack, armour, skills, mana, manaRegPerSeconds) {
	initAnimations(); //loading the pictures and set the animations
	_hitBox = BW_Rect(15, 70);

	_normalButtonImage = "pBotanicMage0.png";
	_selectedButtonImage = "pBotanicMage1.png";
	_disabledButtonImage = "pBotanicMage2.png";
	_unitName = "Mage";
	_attackEffectSound = "sound_attack_spell";
}
Beispiel #10
0
void Scene::init() 
{
	// Enables lighting computations
	if(this->lightingEnabled)
		glEnable(GL_LIGHTING);

	// Sets up some lighting parameters
	glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, this->lightingDoubleSided);
	glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, this->lightingLocal);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Light::background_ambient);  // Define ambient light

	//Define shading
	glShadeModel(this->shadeModel);

	//Define cullface
	if(this->cullface)
	{
		glEnable(GL_CULL_FACE);
		glCullFace(this->cullfaceMode);
	}
	else
		glDisable(GL_CULL_FACE);

	//Define cullorder
	glFrontFace(this->cullorder);

	cout << "CAMERAS: " << endl;
	for(unsigned int i = 0;i<this->scene_cameras.size();i++)
		cout << i << endl;

	//this->activateCamera(0);

	// cout lights
	cout << "LIGHTS: " << endl;
	std::list<CGFlight *>::iterator it = scene_lights.begin();
	for(;it!=scene_lights.end();++it)
	{
		cout << ((Light *)(*it))->getID() << endl;
	}

	// Defines a default normal
	glNormal3f(0,0,1);
	//createDisplayLists(this->rootNode);
	initAnimations();

	//start socket
	if (socket->socketConnect())
		this->gameState = PLACEPIECE;
	else
		throw "Prolog not running!";
	//glutFullScreen();
}
Beispiel #11
0
Panda *Panda::create()
{
    auto panda = new Panda();
    if(panda&&panda->initWithSpriteFrameName("taopaoxiongmao00000.png"))
    {
        panda->autorelease();
        panda->setAnchorPoint(Point::ANCHOR_MIDDLE_BOTTOM);
        panda->initAnimations();
        panda->runAction(RepeatForever::create(Animate::create(AnimationCache::getInstance()->getAnimation("taopaoxiongmao"))));
        panda->setDisplayFrameWithAnimationName("taopaoxiongmao", 1);
        return panda;
    }
    CC_SAFE_FREE(panda);
    return nullptr;
}
Beispiel #12
0
////////////////////////////////////////////////////////////////////////////////
// CTOR / DTOR                                                                //
////////////////////////////////////////////////////////////////////////////////
Bomb::Bomb() :
    //HouseKeeping
    //m_turnInfo - Set in reset.
    m_state(Bomb::State::Dead),
    m_hitBox(Lore::Rectangle::Empty()),
    //Sprite / Animation
    //m_aliveAnimation     - Initialized in InitAnimations
    //m_explodingAnimation - Initialized in InitAnimations
    m_pCurrentAnimation(nullptr),
    //Movement / Bounds
    m_pos            (Lore::Vector2::Zero()),
    m_speed          (Lore::Vector2::Zero()),
    m_maxY           (0),
    //Callback
    m_reachTargetCallback     (nullptr),
    m_explodedFinishedCallback(nullptr)
{
    setOnReachTargetCallback(ReachTargetCallback());
    initAnimations();
    initTimers    ();
}
Beispiel #13
0
void init(int argc, char *argv[])
{
    OSG::osgInit(argc, argv);

    g = new GlobalVars;

    int glutWinId = setupGLUT(&argc, argv);

    g->win = OSG::GLUTWindow::create();
    g->win->setGlutId(glutWinId);
    g->win->init();

    g->mgr = OSG::SimpleSceneManager::create();
    g->mgr->setWindow(g->win);

    g->rootN = OSG::makeCoredNode<OSG::Group>();
    g->mgr->setRoot(g->rootN);
    g->mgr->getHeadlight()->setDiffuse (0.7f, 0.7f, 0.5f, 1.f);
    g->mgr->getHeadlight()->setAmbient (0.3f, 0.3f, 0.3f, 1.f);
    g->mgr->getHeadlight()->setSpecular(0.3f, 0.3f, 0.3f, 1.f);

    g->charState     = CharIdle;
    g->prevCharState = CharIdle;

    g->angle      = 0.f;
    g->angleVel   = idleAngleVel;
    g->renderMode = OSG::SkinnedGeometry::RMSkinnedCPU;

    loadCharacter ();
    loadTextures  ();
    initAnimations();

    loadBackground();
    initFloor     ();
    initShader    ();

    g->mgr->showAll();
}
Bubble::Bubble(NotificationEntity *entity)
    : DBlurEffectWidget(nullptr)
    , m_entity(entity)
    , m_icon(new AppIcon(this))
    , m_body(new AppBody(this))
    , m_actionButton(new ActionButton(this))
    , m_quitTimer(new QTimer(this))

{
    m_quitTimer->setInterval(60 * 1000);
    m_quitTimer->setSingleShot(true);

    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
    setAttribute(Qt::WA_TranslucentBackground);

    m_wmHelper = DWindowManagerHelper::instance();

    m_handle = new DPlatformWindowHandle(this);
    m_handle->setTranslucentBackground(true);
    m_handle->setShadowRadius(14);
    m_handle->setShadowOffset(QPoint(0, 4));

    compositeChanged();

    setBlendMode(DBlurEffectWidget::BehindWindowBlend);
    setMaskColor(DBlurEffectWidget::LightColor);

    initUI();
    initAnimations();
    initTimers();

    setEntity(entity);

    connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, this, &Bubble::compositeChanged);
    connect(m_quitTimer, &QTimer::timeout, this, &Bubble::onDelayQuit);
}
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    //Add Window Listener
    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);
    TutorialMouseListener TheTutorialMouseListener;
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TutorialWindow->addMouseListener(&TheTutorialMouseListener);
    TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
	

	//Shader Material
	BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
    ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
    ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);

	//Material Chunk
	MaterialChunkUnrecPtr ShaderMaterialChunk = MaterialChunk::create();
    ShaderMaterialChunk->setAmbient(Color4f(0.4f,0.4f,0.4f,1.0f));
    ShaderMaterialChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,1.0f));
    ShaderMaterialChunk->setSpecular(Color4f(1.0f,1.0f,1.0f,1.0f));

	//Shader Chunk
	SimpleSHLChunkUnrecPtr TheSHLChunk = SimpleSHLChunk::create();
    TheSHLChunk->setVertexProgram(createSHLVertexProg());
    TheSHLChunk->setFragmentProgram(createSHLFragProg());

	//Color Parameter
	ShaderVariableVec4fUnrecPtr Color1Parameter = ShaderVariableVec4f::create();
    Color1Parameter->setName("Color1");
    Color1Parameter->setValue(Vec4f(0.0f,1.0f,0.0f,1.0f));
	
	ShaderVariableVec4fUnrecPtr Color2Parameter = ShaderVariableVec4f::create();
    Color2Parameter->setName("Color2");
    Color2Parameter->setValue(Vec4f(1.0f,1.0f,1.0f,1.0f));


	//Shader Parameter Chunk
	SHLParameterChunkUnrecPtr SHLParameters = SHLParameterChunk::create();
    SHLParameters->getParameters().push_back(Color1Parameter);
    SHLParameters->getParameters().push_back(Color2Parameter);
    SHLParameters->setSHLChunk(TheSHLChunk);

	ChunkMaterialUnrecPtr ShaderMaterial = ChunkMaterial::create();
    ShaderMaterial->addChunk(ShaderMaterialChunk);
    ShaderMaterial->addChunk(TheSHLChunk);
    ShaderMaterial->addChunk(SHLParameters);

	//Torus Node
	GeometryUnrecPtr TorusGeometry = makeTorusGeo(5.0f,20.0f, 32,32);

    TorusGeometry->setMaterial(ShaderMaterial);

	NodeUnrecPtr TorusNode = Node::create();
    TorusNode->setCore(TorusGeometry);


    // Make Main Scene Node
    NodeUnrecPtr scene = Node::create();
    scene->setCore(Group::create());
    scene->addChild(TorusNode);

    mgr->setRoot(scene);

    // Show the whole Scene
    mgr->showAll();

	//Create the Animations
	initAnimations(Color1Parameter, "value");

    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "04ShaderAnimation");

    //Main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
/** \brief The constructor.
 *
 *  Loads an airplane model from an xml description. The 3D model
 *  will be added to the specified scenegraph.
 *
 *  \param  xml   XML model description file
 *  \param  graph Pointer to the scenegraph which shall render the model
 */
CRRCAirplaneLaRCSimSSG::CRRCAirplaneLaRCSimSSG(SimpleXMLTransfer* xml, ssgBranch *graph)
  : CRRCAirplaneLaRCSim(xml), initial_trans(NULL), 
    model_trans(NULL), model(NULL),
    shadow(NULL), shadow_trans(NULL)
{
  printf("CRRCAirplaneLaRCSimSSG(xml, branch)\n");
  
  std::string s;      
  s = XMLModelFile::getGraphics(xml)->getString("model");
        
  // plib automatically loads the texture file, but it does not know which directory to use.
  {
    // where is the object file?
    std::string    of  = FileSysTools::getDataPath("objects/" + s);
    // compile and set relative texture path
    std::string    tp  = of.substr(0, of.length()-s.length()-1-7) + "textures";    
    ssgTexturePath(tp.c_str());
    // load model
    model = ssgLoad(of.c_str());
  }

  if (model != NULL)
  {
    // Offset of center of gravity
    CRRCMath::Vector3  pCG;         
    pCG = CRRCMath::Vector3(0, 0, 0);
    if (xml->indexOfChild("CG") >= 0)
    {
      SimpleXMLTransfer* i;
      i = xml->getChild("CG");
      pCG.r[0] = i->attributeAsDouble("x", 0);
      pCG.r[1] = i->attributeAsDouble("y", 0);
      pCG.r[2] = i->attributeAsDouble("z", 0);
      
      if (i->attributeAsInt("units") == 1)
        pCG *= M_TO_FT;
    }
    
    // transform model from SSG coordinates to CRRCsim coordinates
    initial_trans = new ssgTransform();
    model_trans = new ssgTransform();
    graph->addKid(model_trans);
    model_trans->addKid(initial_trans);
    initial_trans->addKid(model);
    
    sgMat4 it = {  {1.0,  0.0,  0.0,  0},
                   {0.0,  0.0, -1.0,  0},
                   {0.0,  1.0,  0.0,  0},
                   {pCG.r[1],  pCG.r[2],  -pCG.r[0],  1.0} };
    
    initial_trans->setTransform(it);

    // add a simple shadow
    shadow = (ssgEntity*)initial_trans->clone(SSG_CLONE_RECURSIVE | SSG_CLONE_GEOMETRY | SSG_CLONE_STATE);
    makeShadow(shadow);
    shadow_trans = new ssgTransform();
    graph->addKid(shadow_trans);
    shadow_trans->addKid(shadow);
    
    // add animations ("real" model only, without shadow)
    initAnimations(xml, model, &Global::inputs, animations);
  }
  else
  {
    std::string msg = "Unable to open airplane model file \"";
    msg += s;
    msg += "\"\nspecified in \"";
    msg += xml->getSourceDescr();
    msg += "\"";

    throw std::runtime_error(msg);
  }

}
Beispiel #17
0
CPlayerSprite::CPlayerSprite(float posX, float posY, float width, float height, CTexture *texture)
: CAnimatedSprite(posX, posY, width, height, texture)
{
	initAnimations();
}
Beispiel #18
0
CPlayerSprite::CPlayerSprite(CVector2f pos, CVector2f dimension, CTexture *texture)
: CAnimatedSprite(pos, dimension, texture)
{
	initAnimations();
}
Beispiel #19
0
CPlayerSprite::CPlayerSprite(CTexture* texture)
: CAnimatedSprite(texture)
{
	initAnimations();
}
Beispiel #20
0
ExplosionEntity::ExplosionEntity()
{
	initAnimations();
	sprite->setOpacity(0);
}
BoardActor::BoardActor(Coordinate3D<int> loc, Player& owner) :
		BoardPiece(loc, -1), owner(owner){
	move_speed = 5;
	destination = Coordinate3D<int>(-1,-1,-1);
	initAnimations();
}
Beispiel #22
0
EnemyBuffBar::EnemyBuffBar(Enemy* enemy) {
	m_enemy = enemy;
	initAnimations();
}