本文整理汇总了C++中LSystem::AddRule方法的典型用法代码示例。如果您正苦于以下问题:C++ LSystem::AddRule方法的具体用法?C++ LSystem::AddRule怎么用?C++ LSystem::AddRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LSystem
的用法示例。
在下文中一共展示了LSystem::AddRule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//Initializes stuff
void init()
{
#if 1
GLfloat mat_ambient[] = {0.8,0.15,0.05,1.0};
GLfloat mat_specular[] = {0.8,0.15,0.04,1.0};
GLfloat mat_shininess[] = {10.0};
GLfloat light_position[] = {10.0,10.0,1.0,1.0 };
GLfloat model_ambient[] = {0.8,0.15,0.04,1.0 };
GLfloat mat_diffuse[] = {0.8,0.15,0.05,1.0 };
#endif
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glClearColor(0, 0, 0, 0);
#if 1
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient);
#endif
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_BLEND);
g_log_set_handler ("parse", (GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
parse_log_handler, NULL);
g_log_set_handler ("parse_command", (GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
parse_command_log_handler, NULL);
g_log_set_handler ("Rule",
(GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
Rule_log_handler, NULL);
g_log_set_handler ("Function",
(GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
Function_log_handler, NULL);
g_log_set_handler ("lsys",
(GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
lsys_log_handler, NULL);
lsys.AddFunction_SpaceTransform("rz", 0x4, 0x0, 0x0); // create a rotation function around z
lsys.AddFunction_SpaceTransform("ry", 0x2, 0x0, 0x0); // create a rotation function around y
//lsys.AddFunction_SpaceTransform("G", 0x0, 0x2, 0x0); // create a translation function along x
lsys.AddFunction_Primitive("F", PRIMITIVE_LINE, 0.1, 0.5, 0.1); // create a line function
lsys.AddFunction_Primitive("G", PRIMITIVE_CYLINDER, 0.160, 0.047, 0.02); // create a line function
lsys.PrintFunctionSet();
lsys.SetResult(0, "F(1)");
//lsys.AddRule("F(t),*,*,[]:<0.5> G(t) [ rz(25) F(t) ] [ rz(-25) F(t) ] G(t) F(t) <> G(t) [ rz(5) F(t) ] [ rz(-5) F(t) ] G(t) F(t)");
/*lsys.AddRule("F(t),*,*,[]:<0.3> G(t) [ ry(60) rz(45) F(t*0.75) ] [ ry(-60) rz(15) F(t*0.75) ] [ ry(-180) rz(25) F(t*0.75) ] <> G(t) [ ry(60) rz(25) F(t*0.75) ] [ ry(-60) rz(25) F(t*0.75) ] [ ry(-180) rz(25) F(t*0.75) ] ");*/
lsys.AddRule("F(t),*,*,[]:<0.4> G(t) [ ry(40) rz(45) F(t*0.75) ] [ ry(100) rz(15) F(t*0.75) ] [ ry(180) rz(25) F(t*0.75) ][ry(-90) rz(45) F(t*0.5)] <> G(t) [ ry(60) rz(25) F(t*0.75) ] [ ry(120) rz(25) F(t*0.75) ] [ ry(-60) rz(25) F(t*0.75) ] [ry(-120) rz(25) F(t*0.3)]");
lsys.AddRule("G(t),*,*,[]:<> G(t*1.1)");
}
示例2: init
//Initializes stuff
void init()
{
#if 1
GLfloat mat_ambient[] = {0.8,0.15,0.05,1.0};
GLfloat mat_specular[] = {0.8,0.15,0.04,1.0};
GLfloat mat_shininess[] = {10.0};
GLfloat light_position[] = {10.0,10.0,1.0,1.0 };
GLfloat model_ambient[] = {0.8,0.15,0.04,1.0 };
GLfloat mat_diffuse[] = {0.8,0.15,0.05,1.0 };
#endif
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glClearColor(1, 1, 1, 0);
#if 1
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient);
#endif
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_BLEND);
g_log_set_handler ("parse", (GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
parse_log_handler, NULL);
g_log_set_handler ("parse_command", (GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
parse_command_log_handler, NULL);
g_log_set_handler ("Rule",
(GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
Rule_log_handler, NULL);
g_log_set_handler ("Function",
(GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
Function_log_handler, NULL);
g_log_set_handler ("lsys",
(GLogLevelFlags)(G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE),
lsys_log_handler, NULL);
lsys.AddFunction_SpaceTransform("rx", 0x1, 0x0, 0x0); // create a rotation function around z
//lsys.AddFunction_SpaceTransform("ry", 0x2, 0x0, 0x0); // create a rotation function around y
//lsys.AddFunction_SpaceTransform("G", 0x0, 0x2, 0x0); // create a translation function along x
lsys.AddFunction_Primitive("F", PRIMITIVE_LINE, 0.160, 0.848, 0.01); // create a line function
lsys.AddFunction_Primitive("X", PRIMITIVE_LINE, 0.160, 0.048, 0.01);
lsys.AddFunction_Primitive("G", PRIMITIVE_LINE, 0.160, 0.047, 0.02); // create a line function
lsys.AddFunction_Primitive("H", PRIMITIVE_NOTHING, 0.860, 0.048, 0.01);
lsys.AddFunction_Primitive("K", PRIMITIVE_NOTHING, 0.160, 0.048, 0.01);
lsys.PrintFunctionSet();
lsys.SetResult(0, "X(1)");
//lsys.AddRule("F(t),*,*,[]:<0.5> G(t) [ rz(25) F(t) ] [ rz(-25) F(t) ] G(t) F(t) <> G(t) [ rz(5) F(t) ] [ rz(-5) F(t) ] G(t) F(t)");
//lsys.AddRule("F(t),*,*,[]:<0.1> G(t) [ ry(60) rz(45) F(t*0.5) ] [ ry(-60) rz(15) F(t*0.5) ] [ ry(-180) rz(25) F(t*0.5) ] <> G(t) [ ry(60) rz(25) F(t*0.5) ] [ ry(-60) rz(25) F(t*0.5) ] [ ry(-180) rz(25) F(t*0.5) ] ");
/*lsys.AddRule("F(t),*,*,[]:<0.1> G(t) [ ry(60) rz(45) F(t*0.5) ] [ ry(-60) rz(15) F(t*0.5) ] [ ry(-180) rz(25) F(t*0.5) ] <> G(t) [ ry(60) rz(25) F(t*0.5) ] [ ry(120) rz(25) F(t*0.5) ] [ ry(180) rz(25) F(t*0.5) ] ");*/
//lsys.AddRule("X(t),*,*,[]:<> F(t*0.5) rx(-22.5) [[X(t*0.5)] rx(22.5)] rx(22.5) F(t*0.5) [rx(22.5) F(t*0.5) X(t*0.5)] rx(-22.5) X(t*0.5)");
//lsys.AddRule("F(t),*,*,[]: <0.5> X(t) [rx(50) F(t*0.75)] [rx(-10) F(t*0.75)] <> X(t) [rx(-50) F(t*0.75)] [rx(10) F(t*0.75)]");
/*lsys.AddRule("F(t),*,*,[t>1]:<> G(t)[rx(45) F(t*0.75)]");
lsys.AddRule("F(t),*,*,[t<=1]:<> G(t)[rx(-45) F(t*0.75)]");
lsys.AddRule("G(t),*,*,[]: <> G(t*1.1)");*/
lsys.AddRule("X(t),*,*,[]:<>G(1) [rx(85) X(t)] [rx(-85) X(t)]");
lsys.AddRule("G(t),*,*,[]:<>G(t*1.456)");
//lsys.AddRule("H(t),*,*,[]:<>F(t)");
//lsys.AddRule("G(t),*,*,[t<=0]:<> X(1) [rx(45) F(6)] X(1) rx(3) H(0)");
//lsys.AddRule("X(t),*,*,[]:<> X(t*1.15)");
//lsys.AddRule("H(t),*,*,[t<=0]:<> X(1) [rx(-45) K(6)] X(1) rx(3) G(0)");
//lsys.AddRule("K(t),*,*,[t>0]:<> K(t-1) H(t-1)");
/*lsys.AddRule("F(t),*,*,[t>0]:<> F(t-.1)");
lsys.AddRule("F(t),*,*,[t<=0]:<> X(.1) [rx(45) F(.6)] X(.1) rx(3) K(0)");
lsys.AddRule("X(t),*,*,[]:<> X(t*1.15)");
lsys.AddRule("K(t),*,*,[t<=0]:<> X(.1) [rx(-45) K(.6)] X(.1) rx(3) F(0)");
lsys.AddRule("K(t),*,*,[t>0]:<> K(t-.1) ");*/
//lsys.AddRule("G(t),*,*,[]:<> G(t*1.1)");
}