当前位置: 首页>>代码示例>>C++>>正文


C++ CCCamera类代码示例

本文整理汇总了C++中CCCamera的典型用法代码示例。如果您正苦于以下问题:C++ CCCamera类的具体用法?C++ CCCamera怎么用?C++ CCCamera使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CCCamera类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sqrtf

void CCOrbitCamera::sphericalRadius(float *newRadius, float *zenith, float *azimuth)
{
    float ex, ey, ez, cx, cy, cz, x, y, z;
    float r; // radius
    float s;

    CCCamera* pCamera = m_pTarget->getCamera();
    pCamera->getEyeXYZ(&ex, &ey, &ez);
    pCamera->getCenterXYZ(&cx, &cy, &cz);

    x = ex-cx;
    y = ey-cy;
    z = ez-cz;

    r = sqrtf( powf(x,2) + powf(y,2) + powf(z,2));
    s = sqrtf( powf(x,2) + powf(y,2));
    if( s == 0.0f )
        s = FLT_EPSILON;
    if(r==0.0f)
        r = FLT_EPSILON;

    *zenith = acosf( z/r);
    if( x < 0 )
        *azimuth= (float)M_PI - asinf(y/s);
    else
        *azimuth = asinf(y/s);

    *newRadius = r / CCCamera::getZEye();                
}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:29,代码来源:CCActionCamera.cpp

示例2: CCPointMake

CameraZoomTest::CameraZoomTest()
{
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	
	CCSprite *sprite;
	CCCamera *cam;
	
	// LEFT
	sprite = CCSprite::spriteWithFile(s_pPathGrossini);
	addChild( sprite, 0);		
	sprite->setPosition( CCPointMake(s.width/4*1, s.height/2) );
	cam = sprite->getCamera();
	cam->setEyeXYZ(0, 0, 415);
	
	// CENTER
	sprite = CCSprite::spriteWithFile(s_pPathGrossini);
	addChild( sprite, 0, 40);
	sprite->setPosition(CCPointMake(s.width/4*2, s.height/2));
//		cam = [sprite camera);
//		[cam setEyeX:0 eyeY:0 eyeZ:415/2);
	
	// RIGHT
	sprite = CCSprite::spriteWithFile(s_pPathGrossini);
	addChild( sprite, 0, 20);
	sprite->setPosition(CCPointMake(s.width/4*3, s.height/2));
//		cam = [sprite camera);
//		[cam setEyeX:0 eyeY:0 eyeZ:-485);
//		[cam setCenterX:0 centerY:0 centerZ:0);

	m_z = 0;
	scheduleUpdate();
}
开发者ID:issamux,项目名称:WebGame,代码行数:32,代码来源:CocosNodeTest.cpp

示例3: addChild

CameraZoomTest::CameraZoomTest()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *sprite;
    CCCamera *cam;
    
    // LEFT
    sprite = CCSprite::create(s_pPathGrossini);
    addChild( sprite, 0);        
    sprite->setPosition( ccp(s.width/4*1, s.height/2) );
    cam = sprite->getCamera();
    cam->setEyeXYZ(0, 0, 415/2);
    cam->setCenterXYZ(0, 0, 0);
    
    // CENTER
    sprite = CCSprite::create(s_pPathGrossini);
    addChild( sprite, 0, 40);
    sprite->setPosition(ccp(s.width/4*2, s.height/2));
    
    // RIGHT
    sprite = CCSprite::create(s_pPathGrossini);
    addChild( sprite, 0, 20);
    sprite->setPosition(ccp(s.width/4*3, s.height/2));

    m_z = 0;
    scheduleUpdate();
}
开发者ID:HongXiao,项目名称:Client-source,代码行数:28,代码来源:NodeTest.cpp

示例4: startWithTarget

	//
	// CameraAction
	//
	void CCActionCamera::startWithTarget(CCNode *pTarget)
	{
		CCActionInterval::startWithTarget(pTarget);
		
		CCCamera *camera = pTarget->getCamera();
		camera->getCenterXYZ(&m_fCenterXOrig, &m_fCenterYOrig, &m_fCenterZOrig);
		camera->getEyeXYZ(&m_fEyeXOrig, &m_fEyeYOrig, &m_fEyeZOrig);
		camera->getUpXYZ(&m_fUpXOrig, &m_fUpYOrig, &m_fUpZOrig);
	}
开发者ID:9re,项目名称:cocos2d-x,代码行数:12,代码来源:CCActionCamera.cpp

示例5: ccp

bool Recipe72::init()
{
    if ( !RecipeBase::init() )
    {
        return false;
    }
        
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Thonburi", 34);
    pLabel->setColor(ccBLACK);
    
    // ask director the window size
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    
    // position the label on the center of the screen
    pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
    
    // add the label as a child to this layer
    this->addChild(pLabel, 1);
    
    // add "HelloWorld" splash screen"
    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
    
    // position the sprite on the center of the screen
    pSprite->setPosition( ccp(size.width/2, size.height/2) );
    
    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);
    
    /*
     float x=0, y=0, z=0;
     this->getCamera()->getCenterXYZ(&x, &y, &z);
     this->getCamera()->setCenterXYZ(x, y+0.0000001, z);
     */
    /*
     float x=0, y=0, z=0;
     this->getCamera()->getEyeXYZ(&x, &y, &z);
     this->getCamera()->setEyeXYZ(x, y, 200);
     */
    //this->scheduleUpdate();
    
    //CCDirector::sharedDirector()->setDepthTest(false);
    
    CCCamera* pCamera = this->getCamera();
    pCamera->setEyeXYZ(10.0f, 20.0f, 20.0f);
    pCamera->setCenterXYZ(0, 0, 0);
    pCamera->setUpXYZ(0.0f, 1.0f, 0.0f);
    
    return true;
}
开发者ID:DPigpen,项目名称:cocos2dx_recipe,代码行数:49,代码来源:Recipe72.cpp

示例6: update

void CameraZoomTest::update(ccTime dt)
{
	CCNode *sprite;
	CCCamera *cam;
	
	m_z += dt * 100;
	
	sprite = getChildByTag(20);
	cam = sprite->getCamera();
	cam->setEyeXYZ(0, 0, m_z);
	
	sprite = getChildByTag(40);
	cam = sprite->getCamera();
	cam->setEyeXYZ(0, 0, m_z);	
}
开发者ID:issamux,项目名称:WebGame,代码行数:15,代码来源:CocosNodeTest.cpp

示例7: glLineWidth

void 
CPrimitiveScene::draw()
{    
    CCCamera* pCamera = CCDirector::sharedDirector()->getRunningScene()->getCamera();
    pCamera->setEyeXYZ(0,0,10);
    pCamera->setCenterXYZ(-50.0f, -50.0f, 0);

    // open yellow poly
    ccDrawColor4B(255, 255, 0, 255);
    glLineWidth(10);
    ccVertex3F vertices[] = { vertex3(0,0,0), vertex3(50,50,0), vertex3(100,50,0), vertex3(100,100,0), vertex3(50,100,0.1) };
        
    s_pShader->use();
    s_pShader->setUniformForModelViewProjectionMatrix();
    s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);

    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );


    int numberOfPoints = 5;
    // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
    ccVertex3F* newPoli = new ccVertex3F[numberOfPoints];

    // iPhone and 32-bit machines optimization
    if( sizeof(CCPoint) == sizeof(ccVertex3F) )
    {
        glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, vertices);
    }
    else
    {
        // Mac on 64-bit
        for( unsigned int i=0; i<numberOfPoints;i++)
        {
            newPoli[i] = vertex3( vertices[i].x, vertices[i].y, vertices[i].z );
        }
        glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, newPoli);
    }    

    glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) numberOfPoints);

    CC_SAFE_DELETE_ARRAY(newPoli);
    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:valkidy,项目名称:homedefence,代码行数:43,代码来源:CTMXObjectSchedule.cpp


注:本文中的CCCamera类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。