void PigmentBlendMap::Post(bool& rHasFilter) { for(Vector::const_iterator i = Blend_Map_Entries.begin(); i != Blend_Map_Entries.end(); i++) { Post_Pigment(i->Vals, &rHasFilter); } }
void Post_Tnormal (TNORMAL *Tnormal) { int i; BLEND_MAP *Map; if (Tnormal != NULL) { if (Tnormal->Flags & POST_DONE) { return; } if (Tnormal->Type == NO_PATTERN) { throw POV_EXCEPTION_STRING("No normal type given."); } Tnormal->Flags |= POST_DONE; if ((Map = Tnormal->Blend_Map) != NULL) { for (i = 0; i < Map->Number_Of_Entries; i++) { switch (Map->Type) { case PIGMENT_TYPE: Post_Pigment(Map->Blend_Map_Entries[i].Vals.Pigment); break; case NORMAL_TYPE: Map->Blend_Map_Entries[i].Vals.Tnormal->Flags |= (Tnormal->Flags & DONT_SCALE_BUMPS_FLAG); Post_Tnormal(Map->Blend_Map_Entries[i].Vals.Tnormal); break; case TEXTURE_TYPE: Post_Textures(Map->Blend_Map_Entries[i].Vals.Texture); break; case SLOPE_TYPE: case COLOUR_TYPE: case PATTERN_TYPE: break; default: throw POV_EXCEPTION_STRING("Unknown pattern type in Post_Tnormal."); } } } } }
int Post_Pigment(PIGMENT *Pigment) { int i, Has_Filter; BLEND_MAP *Map; if (Pigment == NULL) { throw POV_EXCEPTION_STRING("Missing pigment"); } if (Pigment->Flags & POST_DONE) { return(Pigment->Flags & HAS_FILTER); } if (Pigment->Type == NO_PATTERN) { Pigment->Type = PLAIN_PATTERN; Pigment->colour.clear() ; ;// TODO MESSAGE Warning(150, "No pigment type given."); } Pigment->Flags |= POST_DONE; switch (Pigment->Type) { case PLAIN_PATTERN: Destroy_Warps (Pigment->Warps); Pigment->Warps = NULL; break; case NO_PATTERN: case BITMAP_PATTERN: break; default: if (Pigment->Blend_Map == NULL) { switch (Pigment->Type) { // NB: The const default blend maps are marked so that they will not be modified nor destroyed later. case BOZO_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Bozo_Default_Map); break; case BRICK_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Brick_Default_Map); break; case WOOD_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Wood_Default_Map); break; case MANDEL_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Mandel_Default_Map);break; case RADIAL_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Radial_Default_Map);break; case AGATE_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Agate_Default_Map); break; case MARBLE_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Marble_Default_Map);break; case HEXAGON_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Hex_Default_Map); break; case SQUARE_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Square_Default_Map);break; case TRIANGULAR_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Triangular_Default_Map);break; case CUBIC_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Cubic_Default_Map); break; // JN2007: Cubic pattern case CHECKER_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Check_Default_Map); break; case AVERAGE_PATTERN: break;// TODO MESSAGE Error("Missing pigment_map in average pigment"); break; case OBJECT_PATTERN: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Check_Default_Map); break; default: Pigment->Blend_Map = const_cast<BLEND_MAP *>(&Gray_Default_Map); break; } } break; } /* Now we test wether this pigment is opaque or not. [DB 8/94] */ Has_Filter = false; if ((fabs(Pigment->colour[pFILTER]) > EPSILON) || (fabs(Pigment->colour[pTRANSM]) > EPSILON)) { Has_Filter = true; } if ((Pigment->Type == BITMAP_PATTERN) && (Pigment->Vals.image != NULL)) { // bitmaps are transparent if they are used only once, or the image is not opaque Has_Filter |= (Pigment->Vals.image->Once_Flag) || !is_image_opaque(Pigment->Vals.image); } if ((Map = Pigment->Blend_Map) != NULL) { if ((Map->Type == PIGMENT_TYPE) || (Map->Type == DENSITY_TYPE)) { for (i = 0; i < Map->Number_Of_Entries; i++) { Has_Filter |= Post_Pigment(Map->Blend_Map_Entries[i].Vals.Pigment); } } else { for (i = 0; i < Map->Number_Of_Entries; i++) { Has_Filter |= fabs(Map->Blend_Map_Entries[i].Vals.colour[pFILTER])>EPSILON; Has_Filter |= fabs(Map->Blend_Map_Entries[i].Vals.colour[pTRANSM])>EPSILON; } } } if (Has_Filter) { Pigment->Flags |= HAS_FILTER; } if (Pigment->Next != NULL) { Post_Pigment(reinterpret_cast<PIGMENT *>(Pigment->Next)); } return(Has_Filter); }
int Post_Pigment(PIGMENT *Pigment) { int i, Has_Filter; BLEND_MAP *Map; if (Pigment == NULL) { Error("Missing pigment"); } if (Pigment->Flags & POST_DONE) { return(Pigment->Flags & HAS_FILTER); } if (Pigment->Type == NO_PATTERN) { Pigment->Type = PLAIN_PATTERN; Make_Colour(Pigment->Colour, 0.0, 0.0, 0.0) ; Warning(150, "No pigment type given."); } Pigment->Flags |= POST_DONE; switch (Pigment->Type) { case PLAIN_PATTERN: Destroy_Warps (Pigment->Warps); Pigment->Warps = NULL; break; case NO_PATTERN: case BITMAP_PATTERN: break; default: if (Pigment->Blend_Map == NULL) { switch (Pigment->Type) { case BOZO_PATTERN: Pigment->Blend_Map = &Bozo_Default_Map; break; case BRICK_PATTERN: Pigment->Blend_Map = &Brick_Default_Map; break; case WOOD_PATTERN: Pigment->Blend_Map = &Wood_Default_Map; break; case MANDEL_PATTERN: Pigment->Blend_Map = &Mandel_Default_Map;break; case RADIAL_PATTERN: Pigment->Blend_Map = &Radial_Default_Map;break; case AGATE_PATTERN: Pigment->Blend_Map = &Agate_Default_Map; break; case MARBLE_PATTERN: Pigment->Blend_Map = &Marble_Default_Map;break; case HEXAGON_PATTERN: Pigment->Blend_Map = &Hex_Default_Map; break; case CHECKER_PATTERN: Pigment->Blend_Map = &Check_Default_Map; break; case AVERAGE_PATTERN: Error("Missing pigment_map in average pigment"); break; case OBJECT_PATTERN: Pigment->Blend_Map = &Check_Default_Map; break; default: Pigment->Blend_Map = &Gray_Default_Map; break; } } break; } /* Now we test wether this pigment is opaque or not. [DB 8/94] */ Has_Filter = false; if ((fabs(Pigment->Colour[pFILTER]) > EPSILON) || (fabs(Pigment->Colour[pTRANSM]) > EPSILON)) { Has_Filter = true; } if ((Map = Pigment->Blend_Map) != NULL) { if ((Map->Type == PIGMENT_TYPE) || (Map->Type == DENSITY_TYPE)) { for (i = 0; i < Map->Number_Of_Entries; i++) { Has_Filter |= Post_Pigment(Map->Blend_Map_Entries[i].Vals.Pigment); } } else { for (i = 0; i < Map->Number_Of_Entries; i++) { Has_Filter |= fabs(Map->Blend_Map_Entries[i].Vals.Colour[pFILTER])>EPSILON; Has_Filter |= fabs(Map->Blend_Map_Entries[i].Vals.Colour[pTRANSM])>EPSILON; } } } if (Has_Filter) { Pigment->Flags |= HAS_FILTER; } if (Pigment->Next != NULL) { Post_Pigment((PIGMENT *)Pigment->Next); } return(Has_Filter); }
FUNCTION_PTR Parser::Parse_DeclareFunction(int *token_id, const char *fn_name, bool is_local) { FUNCTION_PTR ptr = (FUNCTION_PTR)POV_MALLOC(sizeof(FUNCTION), "Function ID"); ExprNode *expression = NULL; FunctionCode function; // default type is float function *token_id = FUNCT_ID_TOKEN; FNCode f(this, &function, is_local, fn_name); f.Parameter(); Parse_Begin(); Get_Token(); if(Token.Token_Id == INTERNAL_TOKEN) { GET(LEFT_PAREN_TOKEN); Get_Token(); if(Token.Function_Id != FLOAT_TOKEN) Expectation_Error("internal function identifier"); expression = FNSyntax_GetTrapExpression((unsigned int)(Token.Token_Float)); function.flags = FN_INLINE_FLAG; GET(RIGHT_PAREN_TOKEN); } else if(Token.Token_Id == TRANSFORM_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for transform functions are not allowed."); expression = FNSyntax_GetTrapExpression(1); // 1 refers to POVFPU_TrapSTable[1] = f_transform [trf] function.private_copy_method = (FNCODE_PRIVATE_COPY_METHOD)Copy_Transform; function.private_destroy_method = (FNCODE_PRIVATE_DESTROY_METHOD)Destroy_Transform; function.private_data = reinterpret_cast<void *>(Parse_Transform_Block()); function.return_size = 3; // returns a 3d vector!!! // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } else if(Token.Token_Id == SPLINE_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for spline functions are not allowed."); Experimental_Flag |= EF_SPLINE; expression = FNSyntax_GetTrapExpression(2); // 2 refers to POVFPU_TrapSTable[2] = f_spline [trf] function.private_copy_method = (FNCODE_PRIVATE_COPY_METHOD)Copy_Spline; function.private_destroy_method = (FNCODE_PRIVATE_DESTROY_METHOD)Destroy_Spline; Parse_Begin(); function.private_data = reinterpret_cast<void *>(Parse_Spline()); Parse_End(); function.return_size = (reinterpret_cast<SPLINE *>(function.private_data))->Terms; // returns a 2d, 3d, 4d or 5d vector!!! // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } else if(Token.Token_Id == PIGMENT_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for pigment functions are not allowed."); expression = FNSyntax_GetTrapExpression(0); // 0 refers to POVFPU_TrapSTable[0] = f_pigment [trf] function.private_copy_method = (FNCODE_PRIVATE_COPY_METHOD)Copy_Pigment; function.private_destroy_method = (FNCODE_PRIVATE_DESTROY_METHOD)Destroy_Pigment; Parse_Begin(); function.private_data = reinterpret_cast<void *>(Create_Pigment()); Parse_Pigment(reinterpret_cast<PIGMENT **>(&function.private_data)); Parse_End(); Post_Pigment(reinterpret_cast<PIGMENT *>(function.private_data)); function.return_size = 5; // returns a color!!! // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } else if(Token.Token_Id == PATTERN_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for pattern functions are not allowed."); expression = FNSyntax_GetTrapExpression(77); // 77 refers to POVFPU_TrapTable[77] = f_pattern [trf] function.private_copy_method = (FNCODE_PRIVATE_COPY_METHOD)Copy_Pigment; function.private_destroy_method = (FNCODE_PRIVATE_DESTROY_METHOD)Destroy_Pigment; Parse_Begin(); function.private_data = reinterpret_cast<void *>(Create_Pigment()); // Yes, this is a pigment! [trf] Parse_PatternFunction(reinterpret_cast<TPATTERN *>(function.private_data)); Parse_End(); Post_Pigment(reinterpret_cast<PIGMENT *>(function.private_data)); } else if(Token.Token_Id == STRING_LITERAL_TOKEN) { f.SetFlag(2, Token.Token_String); Get_Token(); if(Token.Token_Id == COMMA_TOKEN) { Get_Token(); if(Token.Token_Id != STRING_LITERAL_TOKEN) Expectation_Error("valid function expression"); f.SetFlag(1, Token.Token_String); } else { Unget_Token(); expression = FNSyntax_ParseExpression(); } } else { Unget_Token(); expression = FNSyntax_ParseExpression(); } f.Compile(expression); FNSyntax_DeleteExpression(expression); Parse_End(); *ptr = sceneData->functionVM->AddFunction(&function); return ptr; }