Beispiel #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" );
    }
}
Beispiel #2
0
//////////////////////////////////////////////////////////////////////////
// drawLines
void ScnCanvasComponent::drawLines( const MaVec2d* pPoints, BcU32 NoofLines, const RsColour& Colour, BcU32 Layer )
{
	BcU32 NoofVertices = 2 * NoofLines;
	ScnCanvasComponentVertex* pVertices = allocVertices( NoofVertices );
	ScnCanvasComponentVertex* pFirstVertex = pVertices;

	// Only draw if we can allocate vertices.
	if( pVertices != NULL )
	{	
		// Now copy in data.
		BcU32 ABGR = Colour.asABGR();

		for( BcU32 Idx = 0; Idx < NoofVertices; ++Idx )
		{
			pVertices->X_ = pPoints[ Idx ].x();
			pVertices->Y_ = pPoints[ Idx ].y();
			pVertices->Z_ = 0.0f;
			pVertices->W_ = 1.0f;
			pVertices->ABGR_ = ABGR;
			++pVertices;
		}
		
		// Add primitive.		
		addPrimitive( RsTopologyType::LINE_LIST, pFirstVertex, NoofVertices, Layer, BcTrue );
	}
}
//////////////////////////////////////////////////////////////////////////
// drawLines
void ScnDebugRenderComponent::drawLines( const MaVec3d* pPoints, BcU32 NoofLines, const RsColour& Colour, BcU32 Layer )
{
	BcU32 NoofVertices = 2 * NoofLines;
	ScnDebugRenderComponentVertex* pVertices = allocVertices( NoofVertices );
	ScnDebugRenderComponentVertex* pFirstVertex = pVertices;

	// Only draw if we can allocate vertices.
	if( pVertices != NULL )
	{	
		// Now copy in data.
		BcU32 ABGR = Colour.asABGR();

		for( BcU32 Idx = 0; Idx < NoofVertices; ++Idx )
		{
			pVertices->X_ = pPoints[ Idx ].x();
			pVertices->Y_ = pPoints[ Idx ].y();
			pVertices->Z_ = pPoints[ Idx ].z();
			pVertices->ABGR_ = ABGR;
			++pVertices;
		}
		
		// Add primitive.		
		addPrimitive( rsPT_LINESTRIP, pFirstVertex, NoofVertices, Layer, BcTrue );
	}
}
Beispiel #4
0
//////////////////////////////////////////////////////////////////////////
// drawLine3d
void ScnCanvasComponent::drawLine3d( const MaVec3d& PointA, const MaVec3d& PointB, const RsColour& Colour, BcU32 Layer )
{
	ScnCanvasComponentVertex* pVertices = allocVertices( 2 );
	ScnCanvasComponentVertex* pFirstVertex = pVertices;
	
	// Only draw if we can allocate vertices.
	if( pVertices != NULL )
	{
		// Now copy in data.
		BcU32 ABGR = Colour.asABGR();
		
		pVertices->X_ = PointA.x();
		pVertices->Y_ = PointA.y();
		pVertices->Z_ = PointA.z();
		pVertices->ABGR_ = ABGR;
		++pVertices;
		pVertices->X_ = PointB.x();
		pVertices->Y_ = PointB.y();
		pVertices->Z_ = PointB.z();
		pVertices->ABGR_ = ABGR;

		// Add primitive.	
		addPrimitive( rsPT_LINELIST, pFirstVertex, 2, Layer, BcTrue );
	}
}
Beispiel #5
0
CCModel3DS::CCModel3DS(const char *file,
                       const char *texture1, const CCResourceType resourceType,
                       const bool mipmap, const bool alwaysResident, const char *texture2)
{
    primitive3ds = new CCPrimitive3DS();
    primitive3ds->load( file );
    primitive3ds->setTexture( texture1, resourceType, NULL, mipmap, false, alwaysResident );
    if( texture2 != NULL )
    {
        //primitive3ds->textureInfo->secondaryIndex = gEngine->textureManager->assignTextureIndex( texture2, resourceType, mipmap, false, alwaysResident );
    }
    addPrimitive( primitive3ds );
}
Beispiel #6
0
//////////////////////////////////////////////////////////////////////////
// drawBox
void ScnCanvasComponent::drawBox( const MaVec2d& CornerA, const MaVec2d& CornerB, const RsColour& Colour, BcU32 Layer )
{
	ScnCanvasComponentVertex* pVertices = allocVertices( 4 );
	ScnCanvasComponentVertex* pFirstVertex = pVertices;
	
	// Only draw if we can allocate vertices.
	if( pVertices != NULL )
	{
		// Now copy in data.
		BcU32 ABGR = Colour.asABGR();
		
		pVertices->X_ = CornerA.x();
		pVertices->Y_ = CornerA.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = 0.0f;
		pVertices->V_ = 0.0f;
		pVertices->ABGR_ = ABGR;
		++pVertices;

		pVertices->X_ = CornerB.x();
		pVertices->Y_ = CornerA.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = 1.0f;
		pVertices->V_ = 0.0f;
		pVertices->ABGR_ = ABGR;
		++pVertices;

		pVertices->X_ = CornerA.x();
		pVertices->Y_ = CornerB.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = 0.0f;
		pVertices->V_ = 1.0f;
		pVertices->ABGR_ = ABGR;
		++pVertices;

		pVertices->X_ = CornerB.x();
		pVertices->Y_ = CornerB.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = 1.0f;
		pVertices->V_ = 1.0f;
		pVertices->ABGR_ = ABGR;
		
		// Add primitive.	
		addPrimitive( RsTopologyType::TRIANGLE_STRIP, pFirstVertex, 4, Layer, BcTrue );
	}
}
Beispiel #7
0
CCModelObj::CCModelObj(const char *file, 
                       const char *texture1, const CCResourceType resourceType, 
                       const bool alwaysResident, const bool mipmap, const char *texture2)
{
    primitive = new CCPrimitiveObj();
    primitive->load( file );
    
    primitive->setTexture( texture1, resourceType, alwaysResident, mipmap );
    if( texture2 != NULL )
    {
        primitive->textureInfo->secondaryIndex = gEngine->textureManager->assignTextureIndex( texture2, resourceType, alwaysResident, mipmap );
    }
    addPrimitive( primitive );
}
//////////////////////////////////////////////////////////////////////////
// drawLine
void ScnDebugRenderComponent::drawLine( const MaVec3d& PointA, const MaVec3d& PointB, const RsColour& Colour, BcU32 Layer )
{
	ScnDebugRenderComponentVertex* pVertices = allocVertices( 2 );
	ScnDebugRenderComponentVertex* pFirstVertex = pVertices;
	
	// Only draw if we can allocate vertices.
	if( pVertices != NULL )
	{
		// Now copy in data.
		BcU32 ABGR = Colour.asABGR();
		
		pVertices->X_ = PointA.x();
		pVertices->Y_ = PointA.y();
		pVertices->Z_ = PointA.z();
		pVertices->ABGR_ = ABGR;
		++pVertices;
		pVertices->X_ = PointB.x();
		pVertices->Y_ = PointB.y();
		pVertices->Z_ = PointB.z();
		pVertices->ABGR_ = ABGR;

		// Quickly check last primitive.
		BcBool AddNewPrimitive = BcTrue;
		if( LastPrimitiveSection_ != BcErrorCode )
		{
			ScnDebugRenderComponentPrimitiveSection& PrimitiveSection = PrimitiveSectionList_[ LastPrimitiveSection_ ];

			// If the last primitive was the same type as ours we can append to it.
			// NOTE: Need more checks here later.
			if( PrimitiveSection.Type_ == rsPT_LINELIST &&
				PrimitiveSection.Layer_ == Layer &&
				PrimitiveSection.MaterialComponent_ == MaterialComponent_ )
			{
				PrimitiveSection.NoofVertices_ += 2;
				
				AddNewPrimitive = BcFalse;
			}
		}
		
		// Add primitive.
		if( AddNewPrimitive == BcTrue )
		{
			addPrimitive( rsPT_LINELIST, pFirstVertex, 2, Layer, BcTrue );
		}
	}
}
void DataProcessor::finishParsing(CS123SceneNode cNode, Matrix4x4 oldTM){
    Matrix4x4 transmat = oldTM*calcTransMat(cNode.transformations);
    std::vector<CS123ScenePrimitive*> primVect = cNode.primitives;
    std::vector<CS123ScenePrimitive*>::const_iterator j;

    for(j = primVect.begin(); j!=primVect.end(); j++){
        CS123ScenePrimitive cprim = **j;
        addPrimitive(cprim, transmat);
    }

    //do the same to all the children
    std::vector<CS123SceneNode*> childVect = cNode.children;

    for(int k = 0; k<childVect.size(); k++){
        finishParsing(*childVect.at(k), transmat);
    }

}
Beispiel #10
0
 void SceneCache::initDefault() {
     Color errorColor = Color::Magenta;
     ColorTexturePtr errorCTexture(new ConstantTexture<Color>(errorColor));
     addColorTexture(mErrorCode, errorCTexture);
     FloatTexturePtr errorFTexture(new ConstantTexture<float>(0.5f));
     addFloatTexture(mErrorCode, errorFTexture); 
     MaterialPtr errorMaterial(new LambertMaterial(errorCTexture));
     addMaterial(mErrorCode, errorMaterial);
     Geometry* errorGeometry = new Sphere(1.0f);
     errorGeometry->init();
     addGeometry(mErrorCode, errorGeometry);
     ParamSet modelParams;
     modelParams.setString("geometry", mErrorCode);
     modelParams.setString("material", mErrorCode);
     const Primitive* errorPrimitive = 
         ModelPrimitiveCreator().create(modelParams, *this);
     addPrimitive(mErrorCode, errorPrimitive);
     addAreaLight(mErrorCode, NULL);
 }
Beispiel #11
0
CCModelObj::CCModelObj(const char *file, const char *texture,
                       const bool moveVerticesToOrigin,
                       const CCResourceType resourceType,
                       const bool mipmap, const bool load)
{
    primitive = new CCPrimitiveObj();
    primitive->load( file );

    if( moveVerticesToOrigin )
    {
        this->moveVerticesToOrigin();
    }

    if( texture != NULL )
    {
        primitive->setTexture( texture, resourceType, mipmap, true, load );
    }
    addPrimitive( primitive );

    // Rotate as front is back and back is front
    rotateY( 180.0f );
}
Beispiel #12
0
//////////////////////////////////////////////////////////////////////////
// drawSprite
void ScnCanvasComponent::drawSprite( const MaVec2d& Position, const MaVec2d& Size, BcU32 TextureIdx, const RsColour& Colour, BcU32 Layer )
{
	ScnCanvasComponentVertex* pVertices = allocVertices( 6 );
	ScnCanvasComponentVertex* pFirstVertex = pVertices;
	
	const MaVec2d CornerA = Position;
	const MaVec2d CornerB = Position + Size;

	const ScnRect Rect = DiffuseTexture_.isValid() ? DiffuseTexture_->getRect( TextureIdx ) : ScnRect();
	
	// Only draw if we can allocate vertices.
	if( pVertices != NULL )
	{
		// Now copy in data.
		BcU32 ABGR = Colour.asABGR();
		
		pVertices->X_ = CornerA.x();
		pVertices->Y_ = CornerA.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = Rect.X_;
		pVertices->V_ = Rect.Y_;
		pVertices->ABGR_ = ABGR;
		++pVertices;
		
		pVertices->X_ = CornerB.x();
		pVertices->Y_ = CornerA.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = Rect.X_ + Rect.W_;
		pVertices->V_ = Rect.Y_;
		pVertices->ABGR_ = ABGR;
		++pVertices;
		
		pVertices->X_ = CornerA.x();
		pVertices->Y_ = CornerB.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = Rect.X_;
		pVertices->V_ = Rect.Y_ + Rect.H_;
		pVertices->ABGR_ = ABGR;
		++pVertices;
		
		pVertices->X_ = CornerA.x();
		pVertices->Y_ = CornerB.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = Rect.X_;
		pVertices->V_ = Rect.Y_ + Rect.H_;
		pVertices->ABGR_ = ABGR;
		++pVertices;

		pVertices->X_ = CornerB.x();
		pVertices->Y_ = CornerA.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = Rect.X_ + Rect.W_;
		pVertices->V_ = Rect.Y_;
		pVertices->ABGR_ = ABGR;
		++pVertices;

		pVertices->X_ = CornerB.x();
		pVertices->Y_ = CornerB.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->U_ = Rect.X_ + Rect.W_;
		pVertices->V_ = Rect.Y_ + Rect.H_;
		pVertices->ABGR_ = ABGR;
		
		// Quickly check last primitive.
		BcBool AddNewPrimitive = BcTrue;
		if( LastPrimitiveSection_ != BcErrorCode )
		{
			ScnCanvasComponentPrimitiveSection& PrimitiveSection = PrimitiveSectionList_[ LastPrimitiveSection_ ];

			// If the last primitive was the same type as ours we can append to it.
			// NOTE: Need more checks here later.
			if( PrimitiveSection.Type_ == RsTopologyType::TRIANGLE_LIST &&
				PrimitiveSection.Layer_ == Layer &&
				PrimitiveSection.MaterialComponent_ == MaterialComponent_ )
			{
				PrimitiveSection.NoofVertices_ += 6;

				// Matrix stack.
				// TODO: Factor into a seperate function.
				if( IsIdentity_ == BcFalse )
				{
					MaMat4d Matrix = getMatrix();

					for( BcU32 Idx = 0; Idx < 6; ++Idx )
					{
						ScnCanvasComponentVertex* pVertex = &pFirstVertex[ Idx ];
						MaVec3d Vertex = MaVec3d( pVertex->X_, pVertex->Y_, pVertex->Z_ ) * Matrix;
						pVertex->X_ = Vertex.x();
						pVertex->Y_ = Vertex.y();
						pVertex->Z_ = Vertex.z();
						pVertex->W_ = 1.0f;
					}
				}
				
				AddNewPrimitive = BcFalse;
			}
		}
		
		// Add primitive.
		if( AddNewPrimitive == BcTrue )
		{
			addPrimitive( RsTopologyType::TRIANGLE_LIST, pFirstVertex, 6, Layer, BcTrue );
		}
	}
}
Beispiel #13
0
//////////////////////////////////////////////////////////////////////////
// drawLine
void ScnCanvasComponent::drawLine( const MaVec2d& PointA, const MaVec2d& PointB, const RsColour& Colour, BcU32 Layer )
{
	ScnCanvasComponentVertex* pVertices = allocVertices( 2 );
	ScnCanvasComponentVertex* pFirstVertex = pVertices;
	
	// Only draw if we can allocate vertices.
	if( pVertices != NULL )
	{
		// Now copy in data.
		BcU32 ABGR = Colour.asABGR();
		
		pVertices->X_ = PointA.x();
		pVertices->Y_ = PointA.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->ABGR_ = ABGR;
		++pVertices;
		pVertices->X_ = PointB.x();
		pVertices->Y_ = PointB.y();
		pVertices->Z_ = 0.0f;
		pVertices->W_ = 1.0f;
		pVertices->ABGR_ = ABGR;

		// Quickly check last primitive.
		BcBool AddNewPrimitive = BcTrue;
		if( LastPrimitiveSection_ != BcErrorCode )
		{
			ScnCanvasComponentPrimitiveSection& PrimitiveSection = PrimitiveSectionList_[ LastPrimitiveSection_ ];

			// If the last primitive was the same type as ours we can append to it.
			// NOTE: Need more checks here later.
			if( PrimitiveSection.Type_ == RsTopologyType::LINE_LIST &&
				PrimitiveSection.Layer_ == Layer &&
				PrimitiveSection.MaterialComponent_ == MaterialComponent_ )
			{
				PrimitiveSection.NoofVertices_ += 2;

				// Matrix stack.
				// TODO: Factor into a seperate function.
				if( IsIdentity_ == BcFalse )
				{
					MaMat4d Matrix = getMatrix();

					for( BcU32 Idx = 0; Idx < 2; ++Idx )
					{
						ScnCanvasComponentVertex* pVertex = &pFirstVertex[ Idx ];
						MaVec3d Vertex = MaVec3d( pVertex->X_, pVertex->Y_, pVertex->Z_ ) * Matrix;
						pVertex->X_ = Vertex.x();
						pVertex->Y_ = Vertex.y();
						pVertex->Z_ = Vertex.z();
						pVertices->W_ = 1.0f;
					}
				}
				
				AddNewPrimitive = BcFalse;
			}
		}
		
		// Add primitive.
		if( AddNewPrimitive == BcTrue )
		{
			addPrimitive( RsTopologyType::LINE_LIST, pFirstVertex, 2, Layer, BcTrue );
		}
	}
}
Beispiel #14
0
int MTGAllCards::load(const char * config_file, const char * set_name, int autoload)
{
    conf_read_mode = 0;
    const int set_id = set_name ? setlist.Add(set_name) : MTGSets::INTERNAL_SET;
    MTGSetInfo *si = setlist.getInfo(set_id);

    int lineNumber = 0;
    std::string contents;
    izfstream file;
    if (!JFileSystem::GetInstance()->openForRead(file, config_file))
        return total_cards;

    string s;

    while (getline(file,s))
    {
        lineNumber++;
        if (!s.size()) continue;
        if (s[s.size() - 1] == '\r')
            s.erase(s.size() - 1); //Handle DOS files
        if (!s.size()) continue;

        if (s.find("#AUTO_DEFINE ") == 0)
        {
            string toAdd = s.substr(13);
            AutoLineMacro::AddMacro(toAdd);
            continue;
        }

        switch (conf_read_mode)
        {
        case MTGAllCards::READ_ANYTHING:
            if (s[0] == '[')
            {
                currentGrade = Constants::GRADE_SUPPORTED; // Default value
                if (s.size() < 2)
                {
                    DebugTrace("FATAL: Card file incorrect");
                }
                else
                {
                    conf_read_mode = ('m' == s[1]) ? MTGAllCards::READ_METADATA : MTGAllCards::READ_CARD; // M for metadata.
                }
            }
            else
            {
                //Global grade for file, to avoid reading the entire file if unnnecessary
                if (s[0] == 'g' && s.size() > 8)
                {
                    int fileGrade = getGrade(s[8]);
                    int maxGrade = options[Options::MAX_GRADE].number;
                    if (!maxGrade) maxGrade = Constants::GRADE_BORDERLINE; //Default setting for grade is borderline?
                    if (fileGrade > maxGrade)
                    {
                        file.close();
                        return total_cards;
                    }
                }
            }
            continue;
        case MTGAllCards::READ_METADATA:
            if (s[0] == '[' && s[1] == '/')
                conf_read_mode = MTGAllCards::READ_ANYTHING;
            else if (si) si->processConfLine(s);
            continue;
        case MTGAllCards::READ_CARD:
            if (s[0] == '[' && s[1] == '/')
            {
                conf_read_mode = MTGAllCards::READ_ANYTHING;
                if (tempPrimitive) tempPrimitive = addPrimitive(tempPrimitive, tempCard);
                if (tempCard)
                {
                    if (tempPrimitive) tempCard->setPrimitive(tempPrimitive);
                    addCardToCollection(tempCard, set_id);
                }
                tempCard = NULL;
                tempPrimitive = NULL;
            }
            else
            {
                if (!processConfLine(s, tempCard, tempPrimitive))
                    DebugTrace("MTGDECK: BAD Line: \n[" << lineNumber << "]: " << s );
            }
            continue;
        }
    }
    file.close();
    return total_cards;
}