我需要将纬度和经度值转换为三维空间中的一个点.我现在已经尝试了大约2个小时,但是我没有得到正确的结果.
在等距离长方圆柱坐标来自openflights.org.我已经尝试了几种cos和罪的组合,但结果看起来永远不像我们心爱的小地球.
在下文中,您可以看到应用Wikipedia建议的转换结果.我想人们可以从背景中猜出是什么c4d.Vector.
def llarToWorld(latit, longit, altid, rad):
x = math.sin(longit) * math.cos(latit)
z = math.sin(longit) * math.sin(latit)
y = math.cos(longit)
v = c4d.Vector(x, y, z)
v = v * altid + v * rad
return v
Run Code Online (Sandbox Code Playgroud)

红色:X,绿色:Y,蓝色:Z
人们确实可以识别出北美和南美,特别是墨西哥湾周围的土地.然而,它看起来有点挤压,有点在错误的地方..
结果看起来有点旋转,我想,我尝试了交换纬度和经度.但结果有点尴尬.
def llarToWorld(latit, longit, altid, rad):
temp = latit
latit = longit
longit = temp
x = math.sin(longit) * math.cos(latit)
z = math.sin(longit) * math.sin(latit)
y = math.cos(longit)
v …Run Code Online (Sandbox Code Playgroud) 我试图在我的opengl应用程序中实现常规映射,但我无法让它工作.
为了获得切线和bitangent(在其他地方称为binormals?)向量,我为网格中的每个三角形运行此函数:
void getTangent(const glm::vec3 &v0, const glm::vec3 &v1, const glm::vec3 &v2,
const glm::vec2 &uv0, const glm::vec2 &uv1, const glm::vec2 &uv2,
std::vector<glm::vec3> &vTangents, std::vector<glm::vec3> &vBiangents)
{
// Edges of the triangle : postion delta
glm::vec3 deltaPos1 = v1-v0;
glm::vec3 deltaPos2 = v2-v0;
// UV delta
glm::vec2 deltaUV1 = uv1-uv0;
glm::vec2 deltaUV2 = uv2-uv0;
float r = 1.0f / (deltaUV1.x * deltaUV2.y - deltaUV1.y * deltaUV2.x);
glm::vec3 tangent = (deltaPos1 * deltaUV2.y - deltaPos2 * deltaUV1.y)*r;
glm::vec3 …Run Code Online (Sandbox Code Playgroud) 我正在研究用六边形网格制作的行星.不需要杆 - 使这更容易一些.有没有更好的方法将圆柱体变成具有均匀六边形/三角形的球体?
这是所需的步骤:
对于第2步,我只是使用Sin和Cos将顶点移动到圆形.对于第3步,现在我只是使用:vertices[i] = vertices[i].normalized * radius;
图像可视化当前的问题.
请注意,电极是故意切断的.红色部分显示六边形网格的样子.我必须保持它们的大小和方向大致相同,因为它们用于游戏和视觉元素.每个十六进制都有一个邻居列表,基本上就像一个图形.
我一直试图在太阳系的openGL(使用JOGL)中实现3D动画到目前为止我有5个不同大小的行星,但我似乎有的问题是我无法在球体上添加地球纹理的地图可以任何人帮助我如何完成它?
这是我在Display方法中到目前为止的代码:
@Override
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
GLU glu = new GLU();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
//make sure we are in model_view mode
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(10,20,20,0,3,0,0, 20, 0);
//gl.glMatrixMode(GL2.GL_PROJECTION);
//glu.gluPerspective(45,1,1,25);
//render ground plane
gl.glPushMatrix();
gl.glTranslatef(-10.75f, 3.0f, -1.0f);
gl.glColor3f(0.3f, 0.5f, 1f);
GLUquadric earth = glu.gluNewQuadric();
glu.gluQuadricDrawStyle(earth, GLU.GLU_FILL);
glu.gluQuadricNormals(earth, GLU.GLU_FLAT);
glu.gluQuadricOrientation(earth, GLU.GLU_OUTSIDE);
final float radius = 3.378f;
final int slices = 89;
final int stacks = 16;
glu.gluSphere(earth, radius, slices, stacks);
glu.gluDeleteQuadric(earth);
Texture earths;
try {
earths = TextureIO.newTexture(new File("earth.png"), …Run Code Online (Sandbox Code Playgroud)