Ejemplo n.º 1
0
extern "C" RtInt RifGetDeclaration(RtToken name, RifTokenType *tokType,
		RifTokenDetail *tokDetail, RtInt *arrayLen)
{
	try
	{
		CqPrimvarToken tok;
		if(QGetRenderContext())
		{
			// Use the current context dictionary if it exists.
			tok = QGetRenderContext()->tokenDict().parseAndLookup(name);
		}
		else
		{
			// Else just try to parse as an inline declaration.
			tok = CqPrimvarToken(name);
			if(tok.type() == type_invalid)
				return 1; // Couldn't parse as an inline decl.
		}
		*tokType = mapTokType(tok.type());
		*tokDetail = mapTokClass(tok.Class());
		*arrayLen = tok.count();
		return 0;
	}
	catch(XqValidation&)
	{
		return 1;
	}
	catch(...)
	{
		return 1;
	}
}
Ejemplo n.º 2
0
Ri::TypeSpec toTypeSpec(const CqPrimvarToken& tok)
{
    Ri::TypeSpec spec;
    switch(tok.type())
    {
        case type_float:   spec.type = Ri::TypeSpec::Float;   break;
        case type_point:   spec.type = Ri::TypeSpec::Point;   break;
        case type_vector:  spec.type = Ri::TypeSpec::Vector;  break;
        case type_normal:  spec.type = Ri::TypeSpec::Normal;  break;
        case type_hpoint:  spec.type = Ri::TypeSpec::HPoint;  break;
        case type_matrix:  spec.type = Ri::TypeSpec::Matrix;  break;
        case type_color:   spec.type = Ri::TypeSpec::Color;   break;
        case type_integer: spec.type = Ri::TypeSpec::Integer; break;
        case type_string:  spec.type = Ri::TypeSpec::String;  break;
        default:           spec.type = Ri::TypeSpec::Unknown; break;
    }
    switch(tok.Class())
    {
        case class_constant:    spec.iclass = Ri::TypeSpec::Constant; break;
        case class_uniform:     spec.iclass = Ri::TypeSpec::Uniform;  break;
        case class_varying:     spec.iclass = Ri::TypeSpec::Varying;  break;
        case class_vertex:      spec.iclass = Ri::TypeSpec::Vertex;   break;
        case class_facevarying: spec.iclass = Ri::TypeSpec::FaceVarying; break;
        case class_facevertex:  spec.iclass = Ri::TypeSpec::FaceVertex;  break;
        default:                spec.type = Ri::TypeSpec::Unknown;    break;
    }
    spec.arraySize = tok.count();
    return spec;
}