Esempio n. 1
0
void CCModelText::setText(const char *text, const float height, const char *font)
{
    if( primitive == NULL )
    {
        translate( 0.0f, 0.0f, CC_SMALLFLOAT );
        setColour( CCColour( 0.0f ), true );
        primitive = new CCPrimitiveText( text );
        addPrimitive( primitive );
    }
    else
    {
        primitive->setText( text );
    }

    if( height != -1.0f )
    {
        setHeight( height );
    }

    if( font != NULL )
    {
        setFont( font );
    }
    else
    {
        setFont( "HelveticaNeueLight" );
    }
}
Esempio n. 2
0
TileSocialProfile::TileSocialProfile(CCSceneBase *scene, const float size, const char *userSeed) :
    TileSocial( scene, size, size )
{
    drawOrder = 200;

    fbInfoDownloadedCallback = NULL;
    photosDownloadedCallback = NULL;
    
    rotationSpeed = 180.0f;

    taggedPhotosRefreshing = false;
    
    // Set a default profile photo
    CCModelBase *f7u12Model = new CCModelBase();
    model->addModel( f7u12Model );
    f7u12Photo = new CCPrimitiveSquare();
    f7u12Photo->setupZFacing( collisionBounds.x - borderWidth, collisionBounds.y - borderWidth );
    f7u12Photo->setTexture( GetDefaultProfilePhoto(), Resource_Packaged );
    f7u12Model->addPrimitive( f7u12Photo );
    f7u12Model->setColour( CCColour( 1.0f ) );
    f7u12ColourInterpolator.setup( f7u12Model->getColour(), *f7u12Model->getColour() );
    f7u12ColourInterpolator.setDuration( 0.25f );

    // Provisionally set the userID to be the userSeed value
    // Which will be confirmed by the FBApi
    setUserID( userSeed );
    
    scaleInterpolator.clear();
    DELETE_POINTER( scale );
}
void CCTile3DButton::construct(CCSceneBase *scene)
{
    AddFlag( collideableType, collision_ui );

    if( scene != NULL )
    {
        setScene( scene );
    }
    
    renderDepth = false;
    setTransparent();
    
    model = new CCModelBase();
    
    baseModel = new CCModelBase();
    model->addModel( baseModel );
    setBaseColour( CCColour() );
    colourInterpolator.setDuration( 0.5f );
    baseSquare = NULL;
    
    textModel = new CCModelText( this );
    
    if( scale == NULL )
    {
        CCVector3FillPtr( &scale, 0.0f, 0.0f, 1.0f );
    }
    scaleInterpolator.setup( scale, 1.0f );

    CCUpdateCollisions( this );
}
CCTile3DScrollBar::CCTile3DScrollBar(CCSceneBase *scene) :
    CCTile3DButton( scene, 0.0f, 0.0f, NULL )
{
    // Draw on top of other objects
    drawOrder = 202;
    setBaseColour( CCColour( 0.25f, 0.0f ) );
}
Esempio n. 5
0
void CCRenderer::setupOpenGL()
{
    if( usingOpenGL2 )
    {
        // Use shader program
        currentShader = shaders.list[0];
        currentShader->use();

        currentShader->enableAttributeArray( ATTRIB_VERTEX );
        currentShader->enableAttributeArray( ATTRIB_TEXCOORD );
        DEBUG_OPENGL();
    }
    else
    {
#ifdef IOS
        // GL_TEXTURE_2D is not a valid argument to glEnable in OpenGL ES 2.0
        glEnable( GL_TEXTURE_2D );
        glEnableClientState( GL_VERTEX_ARRAY );
        glEnableClientState( GL_TEXTURE_COORD_ARRAY );
        glDisableClientState( GL_COLOR_ARRAY );
        DEBUG_OPENGL();

        CCSetColour( CCColour() );
#endif
    }

#ifndef DXRENDERER
    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
    DEBUG_OPENGL();
#endif

    CCSetDepthRead( true );
    CCSetDepthWrite( true );
#ifndef DXRENDERER
    glDepthFunc( GL_LEQUAL );
    DEBUG_OPENGL();

    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    glEnable( GL_SCISSOR_TEST );
    DEBUG_OPENGL();
#endif
    GLEnable( GL_BLEND );
    DEBUG_OPENGL();

#ifndef DXRENDERER
#ifndef Q_OS_SYMBIAN
    glClearDepthf( 1.0f );
    DEBUG_OPENGL();
#endif

    glLineWidth( LINE_WIDTH );
    DEBUG_OPENGL();
#endif

    // Enable back face culling
    CCSetCulling( true );
    CCSetBackCulling();
}
Esempio n. 6
0
TileSocial::TileSocial(CCSceneBase *scene, const float width, const float height, const char *text) :
    CCTile3DButton( scene )
{
    drawOrder = 200;
    
    borderWidth = 1.0f;
    backgroundSquare = new CCPrimitiveSquare();
    model->addPrimitive( backgroundSquare );
    model->setColour( CCColour( 1.0f, 0.5f ) );
    model->setOutline( CCColourInt( 232 ) );
    
    setupBase( width, height );
    textModel->setColour( CCColour() );
    
    if( text != NULL )
    {
        textModel->setText( text, collisionBoundsLength.y );
    }
    
    rotationSpeed = 180.0f;
}
Esempio n. 7
0
// Called after our constructor is called
void SceneSample1::setup()
{
    // Set our virtual camera width to be 320
    // This means that the width of the view will be 320
    camera->setCameraWidth( 320.0f );
    
    // Background
    {
        CCTile3DButton *tile = new CCTile3DButton( this );  // Pass in this scene
        tile->setupTextured( 640.0f,                        // Specify the width of the tile
                             "Resources/background.png" );  // Texture to load
        
        // Add the tile to our list of touchable tiles, to allow for user interaction
        addTile( tile );
    }
    
    // Create a tile
    CCTile3DButton *tileHelloWorld = NULL;
    {
        CCTile3DButton *tile = new CCTile3DButton( this );
        tile->setupText( "Hello World",                     // Tell it to say 'Hello World'
                         64.0f,                             // Specify the height of the text
                         true );                            // Request the text to be centered

        // Set the colour of the text model to be black
        tile->setTextColour( CCColour( 1.0f ), true );

        addTile( tile );
        
        tileHelloWorld = tile;
    }
    
    // Create a tile with an image
    {
        CCTile3DButton *tile = new CCTile3DButton( this );
        tile->setupTextured( 128.0f, "Resources/f7u12_derp.png" );
        
        addTile( tile );
        
        // Position it underneath our hello world tile
        tile->positionTileBelow( tileHelloWorld );
    }

    // refresh the scene range
    refreshCameraView();
}
Esempio n. 8
0
TileSocialPhoto::TileSocialPhoto(CCSceneBase *scene, const float inSize, 
                                 const char *inID, 
                                 const char *inThumbnailURL, 
                                 const char *inPhotoURL) :
    TileSocial( scene, size, size )
{
    drawOrder = 200;

    setBaseColour( CCColour( 0.5f, CC_SMALLFLOAT ) );
    colourInterpolator.setDuration( 0.5f );

    photoID = inID;
    photoThumbnail = inThumbnailURL;
    photoHD = inPhotoURL;

    size = inSize;
    
    //useThumbnail();
}
void CCTile3DButton::construct(CCSceneBase *scene)
{
    AddFlag( collideableType, collision_ui );

    if( scene != NULL )
    {
        setScene( scene );
    }
    
    renderDepth = false;
    setTransparent();
    
    model = new CCModelBase();
    
    baseModel = new CCModelBase();
    model->addModel( baseModel );
    setBaseColour( CCColour() );
    colourInterpolator.setDuration( 0.5f );
    baseSquare = NULL;
    
    textModel = new CCModelText( this );
    
    allowTouchRotation( false );
    touchRotationMagnitude = 0.0f;
    touchRotationSpeed = 1.0f;
    
    if( scale == NULL )
    {
        CCVector3FillPtr( &scale, 0.0f, 0.0f, 1.0f );
    }
    scaleInterpolator.setup( scale, 1.0f );

    allowTouchMovement( false );

    touchDepressInterpolator.setDuration( 0.125f );
    setTouchDepressRange( 1.0f );
    touchDepressDepth = 3.0f;

    CCUpdateCollisions( this );
}
Esempio n. 10
0
void CCPathFinderNetwork::view()
{
    if( nodes.length > 0 && connectingNodes == false )
    {
		gEngine->textureManager->setTextureIndex( 1 );

        const CCColour nodeColour = CCColour( 1.0f, 0.0f, 0.0f, 1.0f );
        const CCColour pathColour = CCColour( 1.0f, 1.0f, 1.0f, 1.0f );

        CCSetColour( nodeColour );

        for( int i=0; i<nodes.length; ++i )
        {
            const PathNode *node = nodes.list[i];
            GLPushMatrix();
            GLTranslatef( node->point.x, node->point.y, node->point.z );
            CCRenderCube( true );
            GLPopMatrix();
        }

        static CCVector3 start, end;
		{
            GLVertexPointer( 3, GL_FLOAT, sizeof( PathNode ), &nodes.list[0]->point, nodes.length );
#ifndef DXRENDERER
            GLDrawArrays( GL_POINTS, 0, nodes.length );
#endif

            for( int i=0; i<nodes.length; ++i )
            {
                const PathNode *node = nodes.list[i];
                const CCList<PathNode::PathConnection> &connections = node->connections;
                for( int j=0; j<connections.length; ++j )
                {
                    const PathNode::PathConnection *connection = connections.list[j];
                    start.set( node->point.x, 2.0f, node->point.z );
                    end.set( connection->node->point.x, 2.0f, connection->node->point.z );
                    CCRenderLine( start, end );
                }
            }
        }

        if( pathingFrom != NULL )
        {
            CCRenderer::CCSetDepthRead( false );

            CCSetColour( pathColour );

            const PathNode *currentNode = pathingFrom;
            for( int i=0; i<path.endDirection; ++i )
            {
                const int connectionIndex = path.directions[i];
                const CCList<PathNode::PathConnection> &connections = currentNode->connections;
                if( connectionIndex < connections.length )
                {
                    const PathNode::PathConnection *connection = connections.list[connectionIndex];
                    const PathNode *toNode = connection->node;
                    ASSERT( toNode != NULL );
                    start.set( currentNode->point.x, 5.0f, currentNode->point.z );
                    end.set( toNode->point.x, 5.0f, toNode->point.z );
                    CCRenderLine( start, end );
                    currentNode = toNode;
                }
            }

            CCRenderer::CCSetDepthRead( true );
        }
    }
}
Esempio n. 11
0
	}
	else
	{
		static const GLubyte faces[] = 
		{
			0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1,
		};
		static const uint numberOfFaces = sizeof( faces ) / sizeof( GLubyte );
		glDrawElements( GL_TRIANGLE_STRIP, numberOfFaces, GL_UNSIGNED_BYTE, faces );
	}
}


// Shader functions
//-----------------
static CCColour currentColour = CCColour();

void CCSetColour(const CCColour &colour)
{
    if( currentColour.equals( colour ) == false )
    {
        currentColour = colour;
        GLColor4f( currentColour.red, currentColour.green, currentColour.blue, currentColour.alpha );
	}
}


const CCColour& CCGetColour()
{
    return currentColour;
}
Esempio n. 12
0
void CCEngine::renderLoop()
{	
#if defined PROFILEON
    CCProfiler profile( "CCEngine::render()" );
#endif
    
    // Tell the texture manager we're rendering a new frame
    gEngine->textureManager->prepareRender();
    {
        CCList<CCSceneCollideable> &collideables = collisionManager.collideables;
        for( int i=0; i<collideables.length; ++i )
        {
            collideables.list[i]->visible = false;
        }
    }
    CCTile3DFrameBuffer::ResetRenderFlag();
    
	for( int cameraIndex=0; cameraIndex<cameras.length; ++cameraIndex )
    {
		CCCameraBase *currentCamera = CCCameraBase::currentCamera = cameras.list[cameraIndex];
		if( currentCamera->isEnabled() == false )
		{
			continue;
		}
        
        if( currentCamera->getFrameBufferId() != -1 )
        {
            continue;
        }


#if defined PROFILEON
		CCProfiler profile( "CCEngine::render()::camera" );
#endif

        currentCamera->setViewport();
		
		// 2D Background
        if( false )
		{	
			CCMatrix matrix;
			CCMatrixLoadIdentity( matrix );
			CCMatrixRotate( matrix, CCViewManager::GetOrientation().current, 0.0f, 0.0f, 1.0f );
			CCMatrixOrtho( matrix, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f );
			GLSetPushMatrix( matrix );
			
			for( int i=0; i<scenes.length; ++i )
			{
				scenes.list[i]->render2DBackground( cameraIndex );
			}
		}
		
		// 3D Rendering
		GLEnableDepth();
        extern bool gUseProjectionMatrix; 
		gUseProjectionMatrix = true;
		{	
			currentCamera->update();
			
			for( uint pass=render_background; pass<render_finished; ++pass )
			{
#if defined PROFILEON
				CCProfiler profile( "CCEngine::render()::pass" );
#endif

				// Render all the non-collideables
				GLDisableBlend();
				for( int i=0; i<scenes.length; ++i )
				{
					scenes.list[i]->render( currentCamera, pass, false );
				}
				
				// Render all the visible collideables
				{
#if defined PROFILEON
					CCProfiler profile( "CCOctreeRenderVisibleObjects( false )" );
#endif
					CCOctreeRenderVisibleObjects( currentCamera, pass, false );
				}
				
				GLEnableBlend();
				
				if( pass == render_main )
				{	
					if( CCHasFlag( gEngine->renderFlags, render_collisionTrees ) )
					{
						CCOctreeRender( collisionManager.tree );
					}
                    
                    if( CCHasFlag( gEngine->renderFlags, render_pathFinder ) )
					{
						collisionManager.pathFinderNetwork.view();
					}
				}
				
				if( pass == render_main )
				{
					// Keep it disabled for the rest of the renders
					GLDisableDepth();
				}
				
				for( int i=0; i<scenes.length; ++i )
				{
					scenes.list[i]->render( currentCamera, pass, true );
				}
				
				// Render all the visible collideables
				{

#if defined PROFILEON
					CCProfiler profile( "CCOctreeRenderVisibleObjects( true )" );
#endif
					CCOctreeRenderVisibleObjects( currentCamera, pass, true );
				}
			}
		}
		gUseProjectionMatrix = false;
		
		// 2D Rendering
        if( false )
		{
			CCMatrix matrix;
			CCMatrixLoadIdentity( matrix );
			CCMatrixRotate( matrix, CCViewManager::GetOrientation().current, 0.0f, 0.0f, 1.0f );
			CCMatrixOrtho( matrix, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f );
			GLSetPushMatrix( matrix );
			
            for( int i=0; i<scenes.length; ++i )
            {
                scenes.list[i]->render2DForeground( cameraIndex );
            }
			
#ifdef DEBUGON
			if( CCHasFlag( gEngine->renderFlags, render_fontPage ) )
			{
				CCSetColour( CCColour() );
				textureManager->fontPages.list[0]->view();
			}
#endif
		}
		
		currentCamera = NULL;
	}
}