- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个 iOS 应用程序,它使用自定义几何体在 SceneKit 中渲染点云。 This post对我实现这一目标非常有帮助(尽管我将其翻译为 Objective-C),David Rönnqvist 的书《3D Graphics with SceneKit》也是如此(请参阅有关自定义几何图形的章节)。代码工作正常,但我想让点以更大的点大小渲染 - 目前点非常小。
根据 OpenGL 文档,您可以通过调用 glPointSize()
来完成此操作。据我了解,SceneKit 是构建在 OpenGL 之上的,因此我希望有一种方法可以访问此函数或使用 SceneKit 执行等效操作。任何建议将不胜感激!
我的代码如下。我还在 bitbucket 可访问 here 上发布了一个小示例应用程序.
// set the number of points
NSUInteger numPoints = 10000;
// set the max distance points
int randomPosUL = 2;
int scaleFactor = 10000; // because I want decimal points
// but am getting random values using arc4random_uniform
PointcloudVertex pointcloudVertices[numPoints];
for (NSUInteger i = 0; i < numPoints; i++) {
PointcloudVertex vertex;
float x = (float)(arc4random_uniform(randomPosUL * 2 * scaleFactor));
float y = (float)(arc4random_uniform(randomPosUL * 2 * scaleFactor));
float z = (float)(arc4random_uniform(randomPosUL * 2 * scaleFactor));
vertex.x = (x - randomPosUL * scaleFactor) / scaleFactor;
vertex.y = (y - randomPosUL * scaleFactor) / scaleFactor;
vertex.z = (z - randomPosUL * scaleFactor) / scaleFactor;
vertex.r = arc4random_uniform(255) / 255.0;
vertex.g = arc4random_uniform(255) / 255.0;
vertex.b = arc4random_uniform(255) / 255.0;
pointcloudVertices[i] = vertex;
// NSLog(@"adding vertex #%lu with position - x: %.3f y: %.3f z: %.3f | color - r:%.3f g: %.3f b: %.3f",
// (long unsigned)i,
// vertex.x,
// vertex.y,
// vertex.z,
// vertex.r,
// vertex.g,
// vertex.b);
}
// convert array to point cloud data (position and color)
NSData *pointcloudData = [NSData dataWithBytes:&pointcloudVertices length:sizeof(pointcloudVertices)];
// create vertex source
SCNGeometrySource *vertexSource = [SCNGeometrySource geometrySourceWithData:pointcloudData
semantic:SCNGeometrySourceSemanticVertex
vectorCount:numPoints
floatComponents:YES
componentsPerVector:3
bytesPerComponent:sizeof(float)
dataOffset:0
dataStride:sizeof(PointcloudVertex)];
// create color source
SCNGeometrySource *colorSource = [SCNGeometrySource geometrySourceWithData:pointcloudData
semantic:SCNGeometrySourceSemanticColor
vectorCount:numPoints
floatComponents:YES
componentsPerVector:3
bytesPerComponent:sizeof(float)
dataOffset:sizeof(float) * 3
dataStride:sizeof(PointcloudVertex)];
// create element
SCNGeometryElement *element = [SCNGeometryElement geometryElementWithData:nil
primitiveType:SCNGeometryPrimitiveTypePoint
primitiveCount:numPoints
bytesPerIndex:sizeof(int)];
// create geometry
SCNGeometry *pointcloudGeometry = [SCNGeometry geometryWithSources:@[ vertexSource, colorSource ] elements:@[ element]];
// add pointcloud to scene
SCNNode *pointcloudNode = [SCNNode nodeWithGeometry:pointcloudGeometry];
[self.myView.scene.rootNode addChildNode:pointcloudNode];
最佳答案
我自己在 ios 中研究渲染点云,并在 twitter 上找到了一个解决方案,作者是“vade”,我想我将其发布在这里供其他人使用:
专业提示:SceneKit 着色器修改器很有用:
mat.shaderModifiers = @{SCNShaderModifierEntryPointGeometry : @"gl_PointSize = 16.0;"};
关于ios - 使用 SceneKit 和 SCNGeometryPrimitiveTypePoint 制作自定义几何体时如何调用 glPointSize() (或 SceneKit 等效项),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38257339/
我正在尝试编写一个简单的 opengl 程序,该程序使用 glPointSize() 和变量 pointSize 循环增大和缩小屏幕中心的单个点。打印 pointSize 的值并使用调试器单步执行代码
glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_POINT_SMOOTH); glPointSize(20.0); glBegin(GL_POINT); {
我有这个丢分代码。我想增加点数。现在我使用此命令 glPointSize 但没有任何反应。磅值是默认值。它不会增加。 我怎样才能增加点数? glBegin(GL_POINTS); glColor3f
我正在编写一个 iOS 应用程序,它使用自定义几何体在 SceneKit 中渲染点云。 This post对我实现这一目标非常有帮助(尽管我将其翻译为 Objective-C),David Rönnq
我是一名优秀的程序员,十分优秀!