Classes/Material/MaterialLesson9.cpp
bool MaterialLesson9::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(MaterialLesson9::menuCloseCallback, this));
    
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label

    // add "MathLesson1" splash screen"
    
    //create Sprite3D
    std::string filename = "res/Material/plane.c3t";
    auto sprite = Sprite3D::create(filename);
    sprite->setPosition(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y);
    sprite->setScale(2);
    sprite->setRotation3D(Vec3(-70, 0, 0));
    addChild(sprite);
    
    auto material = Material::createWithFilename("res/Material/simpleShadow.material");
    auto _state = material->getTechniqueByIndex(0)->getPassByIndex(0)->getGLProgramState();
    _state->setUniformMat4("u_model_matrix",sprite->getNodeToWorldTransform());
    sprite->setMaterial(material);
    
    scheduleUpdate();
    
    _sprite = sprite;
    
    return true;
}
// on "init" you need to initialize your instance
on "init" you need to initialize your instance
on " init " you need to initialize your instance
bool MaterialLesson9::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(MaterialLesson9::menuCloseCallback, this));
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);
    std::string filename = "res/Material/plane.c3t";
    auto sprite = Sprite3D::create(filename);
    sprite->setPosition(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y);
    sprite->setScale(2);
    sprite->setRotation3D(Vec3(-70, 0, 0));
    addChild(sprite);
    auto material = Material::createWithFilename("res/Material/simpleShadow.material");
    auto _state = material->getTechniqueByIndex(0)->getPassByIndex(0)->getGLProgramState();
    _state->setUniformMat4("u_model_matrix",sprite->getNodeToWorldTransform());
    sprite->setMaterial(material);
    scheduleUpdate();
    _sprite = sprite;
    return true;
}
bool MaterialLesson9 :: init ( ) { if ( ! Layer :: init ( ) ) { return false ; } Size visibleSize = Director :: getInstance ( ) -> getVisibleSize ( ) ; Vec2 origin = Director :: getInstance ( ) -> getVisibleOrigin ( ) ; auto closeItem = MenuItemImage :: create ( " " , " " , CC_CALLBACK_1 ( MaterialLesson9 :: menuCloseCallback , this ) ) ; closeItem -> setPosition ( Vec2 ( origin . x + visibleSize . width - closeItem -> getContentSize ( ) . width / 2 , origin . y + closeItem -> getContentSize ( ) . height / 2 ) ) ; auto menu = Menu :: create ( closeItem , NULL ) ; menu -> setPosition ( Vec2 :: ZERO ) ; this -> addChild ( menu , 1 ) ; std :: string filename = " " ; auto sprite = Sprite3D :: create ( filename ) ; sprite -> setPosition ( visibleSize . width / 2 + origin . x , visibleSize . height / 2 + origin . y ) ; sprite -> setScale ( 2 ) ; sprite -> setRotation3D ( Vec3 ( -70 , 0 , 0 ) ) ; addChild ( sprite ) ; auto material = Material :: createWithFilename ( " " ) ; auto _state = material -> getTechniqueByIndex ( 0 ) -> getPassByIndex ( 0 ) -> getGLProgramState ( ) ; _state -> setUniformMat4 ( " " , sprite -> getNodeToWorldTransform ( ) ) ; sprite -> setMaterial ( material ) ; scheduleUpdate ( ) ; _sprite = sprite ; return true ; }
on "init" you need to initialize your instance
on " init " you need to initialize your instance
////////////////////////////// // 1. super init first ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program //    you may modify it. // add a "close" icon to exit the progress. it's an autorelease object // create menu, it's an autorelease object ///////////////////////////// // 3. add your codes below... // add a label shows "Hello World" // create and initialize a label // add "MathLesson1" splash screen" //create Sprite3D