예제 #1
0
void LightTest::addSprite()
{
    auto s = Director::getInstance()->getWinSize();

    //{
    //    std::string fileName = "Sprite3DTest/plane.c3b";
    //    auto sprite = Sprite3D::create(fileName);
    //    sprite->setRotation3D(Vec3(-90.0, 0.0, 0.0));
    //    sprite->setScale(5.0f);
    //    sprite->setPosition(Vec2(0.0, -50.0));
    //    addChild(sprite);
    //    sprite->setCameraMask(2);
    //}

    {
        std::string fileName = "Sprite3DTest/orc.c3b";
        auto sprite = Sprite3D::create(fileName);
        sprite->setRotation3D(Vec3(0.0, 180.0, 0.0));
        sprite->setPosition(Vec2(0.0, 0.0));
        sprite->setScale(2.0);
        auto sp = Sprite3D::create("Sprite3DTest/axe.c3b");
        sprite->getAttachNode("Bip001 R Hand")->addChild(sp);
        auto animation = Animation3D::create(fileName);
        if (animation)
        {
            auto animate = Animate3D::create(animation);
            sprite->runAction(RepeatForever::create(animate));
        }

        addChild(sprite);
        sprite->setCameraMask(2);
    }

    {
        std::string fileName = "Sprite3DTest/sphere.c3b";
        auto sprite = Sprite3D::create(fileName);
        sprite->setPosition(Vec2(30.0, 0.0));
        addChild(sprite);
        sprite->setCameraMask(2);
    }

    {
        std::string fileName = "Sprite3DTest/sphere.c3b";
        auto sprite = Sprite3D::create(fileName);
        sprite->setScale(0.5f);
        sprite->setPosition(Vec2(-50.0, 0.0));
        addChild(sprite);
        sprite->setCameraMask(2);
    }

    {
        std::string fileName = "Sprite3DTest/sphere.c3b";
        auto sprite = Sprite3D::create(fileName);
        sprite->setScale(0.5f);
        sprite->setPosition(Vec2(-30.0, 10.0));
        addChild(sprite);
        sprite->setCameraMask(2);
    }
}
예제 #2
0
void Sprite3DMirrorTest::addNewSpriteWithCoords(Vec2 p)
{
    std::string fileName = "Sprite3DTest/orc.c3b";
    auto sprite = Sprite3D::create(fileName);
    sprite->setScale(5);
    sprite->setRotation3D(Vec3(0,180,0));
    addChild(sprite);
    sprite->setPosition( Vec2( p.x - 80, p.y) );
    
    //test attach
    auto sp = Sprite3D::create("Sprite3DTest/axe.c3b");
    sprite->getAttachNode("Bip001 R Hand")->addChild(sp);
    
    auto animation = Animation3D::create(fileName);
    if (animation)
    {
        auto animate = Animate3D::create(animation);
        
        sprite->runAction(RepeatForever::create(animate));
    }
    _sprite = sprite;
    _hasWeapon = true;
    
    //create mirror Sprite3D
    sprite = Sprite3D::create(fileName);
    sprite->setScale(5);
    sprite->setScaleX(-5);
    sprite->setCullFace(GL_FRONT);
    sprite->setRotation3D(Vec3(0,180,0));
    addChild(sprite);
    sprite->setPosition( Vec2( p.x + 80, p.y) );
    
    //test attach
    sp = Sprite3D::create("Sprite3DTest/axe.c3b");
    sprite->getAttachNode("Bip001 R Hand")->addChild(sp);
    
    animation = Animation3D::create(fileName);
    if (animation)
    {
        auto animate = Animate3D::create(animation);
        
        sprite->runAction(RepeatForever::create(animate));
    }
    _mirrorSprite = sprite;
}
예제 #3
0
void Sprite3D::createAttachSprite3DNode(NodeData* nodedata,const MaterialDatas& matrialdatas)
{
    for(const auto& it : nodedata->modelNodeDatas)
    {
        if(it && getAttachNode(nodedata->id))
        {
            auto sprite = createSprite3DNode(nodedata,it,matrialdatas);
            if (sprite)
            {
                getAttachNode(nodedata->id)->addChild(sprite);
            } 
        }
    }
    for(const auto& it : nodedata->children)
    {
        createAttachSprite3DNode(it,matrialdatas);
    }
}