xtitus
27-07-2014 01:23:34
I'm working on generating tree trunks using the ogre procedural library. It's been working great with the exception of me getting stuck on adjusting widths of the extrusions... I'm putting in a quick code snippet of my test case.
I'm basically trying to have a path extruded with a circle and set radius. I'm trying to use the Track object to set adjustments in width, as tree branches get smaller as they come away from the trunk. From what I read in the documentation and code snippets, you can use a Track to adjust the scale of the width at key frames along the path. My incoming data set for a branch will be a series of pairs (position and radius of width). I've marked the numSeg to 1, so only my points are generated. The radius pairs are then added as key frames matching the indexes of the positions. I marked the scales larger differences in this test as you should clearly see the difference. However, in the attached screenshot, you'll see I end up with a large disc end cap, and the rest of the tube is all the same size.
Anyone have any thoughts? Hoping the library maintainers might be able to chime in as I'm probably doing something wrong. There's just not that many examples of using the Track object. Thanks!
std::vector<Ogre::Vector3>& positions;
std::vector<Ogre::Real>& radii;
positions.push_back(Ogre::Vector3(0,0,0));
radii.push_back(5);
positions.push_back(Ogre::Vector3(10,0,0));
radii.push_back(4);
positions.push_back(Ogre::Vector3(20,0,0));
radii.push_back(3);
positions.push_back(Ogre::Vector3(30,0,0));
radii.push_back(2);
positions.push_back(Ogre::Vector3(40,0,0));
radii.push_back(1);
Procedural::CatmullRomSpline3 curve = Procedural::CatmullRomSpline3();
curve.setNumSeg(1);
for(int i=0; i<positions.size(); i++)
curve.addPoint(positions);
Procedural::Path p = curve.realizePath();
Procedural::Shape s = Procedural::CircleShape().setRadius(1).realizeShape();
Procedural::Track track = Procedural::Track(Procedural::Track::AM_POINT);
for(int i=0; i<radii.size(); i++)
track.addKeyFrame(i, radii);
Procedural::Extruder().setExtrusionPath(&p).setShapeToExtrude(&s).setScaleTrack(&track).setCapped(true).setUTile(5).setVTile(2).realizeMesh("extrudedMesh");
I'm basically trying to have a path extruded with a circle and set radius. I'm trying to use the Track object to set adjustments in width, as tree branches get smaller as they come away from the trunk. From what I read in the documentation and code snippets, you can use a Track to adjust the scale of the width at key frames along the path. My incoming data set for a branch will be a series of pairs (position and radius of width). I've marked the numSeg to 1, so only my points are generated. The radius pairs are then added as key frames matching the indexes of the positions. I marked the scales larger differences in this test as you should clearly see the difference. However, in the attached screenshot, you'll see I end up with a large disc end cap, and the rest of the tube is all the same size.
Anyone have any thoughts? Hoping the library maintainers might be able to chime in as I'm probably doing something wrong. There's just not that many examples of using the Track object. Thanks!