Java3d 形状与 Antlr
那么如何评估一个非常简单的 antlr 语法,它只能做到这一点。
Box(1,2,4)
Cylinder(1,2)
并构建 java3d 形状,(假设我已经为 java3d 构建了画布,并且拥有在 java 中创建每个元素的代码,
protected static BranchGroup addBox1(Float a, Float b, Float C){
// create branch for display
TransformGroup bodyTransform = new TransformGroup();
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ALLOW_DETACH);
bg.setUserData(shapeId);
// set transformation
bodyTransform = setTransformShape(0,0,0,0,0,0,0);
// create box
Box tmpBox = new Box(a,b,c, Primitive.GENERATE_NORMALS |
Primitive.GENERATE_TEXTURE_COORDS,setAppearance(color));
getCoords(tmpBox);
bodyTransform.addChild(tmpBox);
trFormList.add(bodyTransform);
shapeId++;
//add box to branch
bg.addChild(bodyTransform);
return bg;
}
)
谢谢
Well how to evaluate a very simple antlr grammar that does only this.
Box(1,2,4)
Cylinder(1,2)
and builds java3d shapes, (given I have already built a canvas for java3d and have the code for creating each element in java,
protected static BranchGroup addBox1(Float a, Float b, Float C){
// create branch for display
TransformGroup bodyTransform = new TransformGroup();
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ALLOW_DETACH);
bg.setUserData(shapeId);
// set transformation
bodyTransform = setTransformShape(0,0,0,0,0,0,0);
// create box
Box tmpBox = new Box(a,b,c, Primitive.GENERATE_NORMALS |
Primitive.GENERATE_TEXTURE_COORDS,setAppearance(color));
getCoords(tmpBox);
bodyTransform.addChild(tmpBox);
trFormList.add(bodyTransform);
shapeId++;
//add box to branch
bg.addChild(bodyTransform);
return bg;
}
)
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许是这样的?
Something like this perhaps?