标签: coordinates

如何在OpenGL索引缓冲区数组中处理多个纹理以与数据着色器一起使用?

我正在尝试实施这篇论文.我已经完成了大部分工作,但是关于向着色器发送任意非几何数据以用于确定和显示几何边缘的部分导致了我的问题.我已经成功地使用我所知道的VBO成功发送了大部分数据.但是,我需要发送大量数据,这需要使用多个纹理坐标.

我已经实现了我认为是设置多组纹理坐标的正确方法的几种变体,并遵循许多论坛海报的说明.到目前为止没有解决方案.

对于上下文,程序正在为模型中的每个唯一边发送4个几乎相同的一组4个顶点,2个法向量,一个浮点和一个整数(存储为浮点数)的副本.我已经列出了这样的数据:

v0 is stored in gl_Vertex (vec3)
v1 is stored in gl_Color (vec3)
v2 is stored in gl_MultiTexCoord0 (vec3)
v3 is stored in gl_MultiTexCoord1 (vec3)
n0 is stored in gl_Normal (vec3)
n1 is stored in gl_SecondaryColor (vec3)
r and i are stored in gl_MultiTexCoord2 (vec2)
Run Code Online (Sandbox Code Playgroud)

4个副本之间的唯一区别是i值,这有助于确定在找到可绘制边缘时如何组织顶点.

如您所见,我需要至少3个纹理坐标.我能够让第一个工作(gl_MultiTexCoord0)很好,但是任何后续纹理坐标,虽然在显卡上,似乎有不可控制的行为,有时工作,但通常不行.

我的渲染函数看起来像这样:

void Mesh::RenderLineEdgesGPU()
{
    // Enable client state
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    // Turn on edge shader
    edgeProgram.Activate();

    // Link buffers
    // v0
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, edgeMeshHandles[0]);
    glVertexPointer(3, GL_FLOAT, 0, …
Run Code Online (Sandbox Code Playgroud)

opengl textures glsl coordinates

4
推荐指数
1
解决办法
8137
查看次数

Matlab:将全局坐标转换为图形坐标

如果我得到坐标

coords = get(0,'PointerLocation');
Run Code Online (Sandbox Code Playgroud)

如何将它们转换为通过点获得的积分ginput

即,我想从中得到相同的值

coords = get(0,'PointerLocation');
coords=someConversion(coords);
Run Code Online (Sandbox Code Playgroud)

正如我本来打电话的那样

coords=ginput(1);
Run Code Online (Sandbox Code Playgroud)

然后在与前一位代码相同的位置点击图中的鼠标.

matlab coordinates

4
推荐指数
1
解决办法
5712
查看次数

如何在三维空间中找到移动目标的拦截坐标?

假设我有一艘宇宙飞船(source); 小行星(target)就在附近.

我知道,在3D空间(XYZ向量):

  • 我的船的位置(sourcePos)和速度(sourceVel).
  • 小行星的位置(targetPos)和速度(targetVel).

(例如sourcePos= [30,20,10]; sourceVel= [30,20,10]; targetPos= [600,400,200]; targetVel= [300,200,100]`)

我也知道:

  • 船的速度恒定的.
  • 小行星的速度恒定的.
  • 我的船的抛射速度(projSpd)是恒定的.
  • 射击后我的船的弹丸轨迹线性的(/直的).

(例如projSpd= 2000.00)

如何计算我需要射击的拦截坐标以击中小行星?


笔记:

这个问题是基于这个Yahoo - Answers页面.

我也在谷歌搜索类似的问题,在这里搜索SO,但大多数答案都是针对2D空间的,而对于3D的少数答案,解释和伪代码都没有解释什么是做什么和/或为什么,所以我不能真正理解将它们成功应用于我的代码.以下是我访问过的一些页面:

Danik Games Devlog,Blitz3D论坛主题 …

math 3d position prediction coordinates

4
推荐指数
1
解决办法
6847
查看次数

iOS应用程序中的iOS坐标系统

我刚开始使用我的第一个Mac App,但我意识到坐标系是"翻转"(x = 0,y = 0在左下角).我在UI编程方面遇到了很多麻烦,因为我已经习惯了iOS坐标系统.

我现在的问题是: 我可以永久地翻转我的应用程序/窗口的坐标系统,这样我也不必翻转我的所有子视图.

多数民众赞成我的应用程序: 我的应用程序窗口包含一个NSScrollView,其中包含从最近到旧的帖子.当我添加我的第一篇文章时,我希望它位于scrollView的顶部.

我希望有人有同样的问题,可以帮助我.谢谢

macos objective-c coordinates coordinate-systems ios

4
推荐指数
1
解决办法
569
查看次数

在android中的2个视图之间的碰撞

我在android中有2个视图,它们是可拖动的.我想检测它们之间的碰撞.目前我正在使用此代码来检测碰撞,但我认为它不起作用.请建议需要检查碰撞的内容.

public boolean onTouch(View view, MotionEvent event) {
    final int X = (int) event.getRawX();
    final int Y = (int) event.getRawY();
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) view
                .getLayoutParams();

        _xDelta = X - lParams.leftMargin;
        _yDelta = Y - lParams.topMargin;
        break;
    case MotionEvent.ACTION_UP:
        break;
    case MotionEvent.ACTION_POINTER_DOWN:
        break;
    case MotionEvent.ACTION_POINTER_UP:
        break;
    case MotionEvent.ACTION_MOVE:
        RelativeLayout.LayoutParams ParamsA = (RelativeLayout.LayoutParams) view
                .getLayoutParams();
        ParamsA.leftMargin = X - _xDelta;
        ParamsA.topMargin = Y - _yDelta;
        ParamsA.rightMargin = -250;
        ParamsA.bottomMargin = -250;

        for (int i …
Run Code Online (Sandbox Code Playgroud)

java android drag-and-drop collision-detection coordinates

4
推荐指数
1
解决办法
2372
查看次数

Android-仅在地图中显示确定区域中包含的标记

我的应用程序带有地图。在此地图中,我在设备的当前位置放置了一个标记。我还围绕标记添加了一个圆圈,如下所示:

    Circle circle = mMap.addCircle(new CircleOptions()
                        .center(latLng)
                        .radius(400)     //The radius of the circle, specified in meters. It should be zero or greater.
                        .strokeColor(Color.rgb(0, 136, 255))
                        .fillColor(Color.argb(20, 0, 136, 255)));
Run Code Online (Sandbox Code Playgroud)

结果是这样的:
这是结果的示例

我有一个数据库,其中某些位置的特征是经度和纬度。

我将在地图中设置标记,仅针对先前添加的圆内的位置。
我如何理解该区域中包括哪些?

请帮助我,谢谢!

java maps android google-maps coordinates

4
推荐指数
2
解决办法
3164
查看次数

如何使用Python在网格中创建10个随机x,y坐标

我需要创建一个8x8网格,并在网格上的随机位置分配10个硬币.我面临的问题是randint函数有时会产生相同的随机坐标,因此只生成9或8个硬币并放在网格上.我怎样才能确保不会发生这种情况?干杯:)这是我的代码到目前为止:

from random import randint

grid = []
#Create a 8x8 grid
for row in range(8):
    grid.append([])
    for col in range(8):
        grid[row].append("0")

#create 10 random treasure chests
    #problem is that it might generate the same co-ordinates and therefore not enough coins
for coins in range(10):
    c_x = randint(0, len(grid)-1)
    c_y = randint(0, len(grid[0])-1)
    while c_x == 7 and c_y == 0:
           c_x = randint(0, len(grid)-1)
           c_y = randint(0, len(grid[0])-1)
    else:
        grid[c_x][c_y] = "C"

for row in grid:
print(" ".join(row))
Run Code Online (Sandbox Code Playgroud)

我已经包含了一段时间/其他 …

python random coordinates

4
推荐指数
2
解决办法
4663
查看次数

用numpy在边界框中查找点

我有多个存储在二维numpy数组中的点云文件中的数百万个xyz坐标:[[x1, y1, z1], [x2, y2, z2],..., [xn, yn, zn]]

我想过滤由4个坐标([[x1, y1], [x2, y2]]即矩形的左下角和右上角坐标)描述的特定边界框内的所有点。

我已经找到了以下代码来用numpy过滤坐标,这几乎是我想要的。唯一的区别是(如果我做对了)我的二维数组也具有z坐标。

import random
import numpy as np

points = [(random.random(), random.random()) for i in range(100)]

bx1, bx2 = sorted([random.random(), random.random()])
by1, by2 = sorted([random.random(), random.random()])

pts = np.array(points)
ll = np.array([bx1, by1])  # lower-left
ur = np.array([bx2, by2])  # upper-right

inidx = np.all(np.logical_and(ll <= pts, pts <= ur), axis=1)
inbox = pts[inidx]
outbox = pts[np.logical_not(inidx)]
Run Code Online (Sandbox Code Playgroud)

我如何修改上面的代码以使其与xyz坐标一起工作,并通过由两个xy坐标描述的边界框进行过滤?

python numpy coordinates point-clouds

4
推荐指数
2
解决办法
3798
查看次数

列表对子列表的理解?

使用Python 3.0,我将如何创建100个索引的列表,如下所示:

grid_Sys = [['A0'],['A1'],['A2']....['A9'],['B0'],...[J9]]
Run Code Online (Sandbox Code Playgroud)

我理解如何通过使用ord()和chr()函数来增加字母的顺序.但是,我不明白在切换之前如何进行10索引chr(ord('A')+1) = B.

从本质上讲,我想达到一个可以做到这样的事情:

grid_Sys = [['A0','brown']...
Run Code Online (Sandbox Code Playgroud)

但是,这只是一个随机颜色的简单附加选项.

python list-comprehension list coordinates

4
推荐指数
1
解决办法
188
查看次数

生成具有最小距离的随机x和y坐标

R中是否有一种方法可以生成它们之间的最小距离的随机坐标?

例如,我想避免

x <- c(0,3.9,4.1,8)
y <- c(1,4.1,3.9,7)
plot(x~y)
Run Code Online (Sandbox Code Playgroud)

r spatial coordinates

4
推荐指数
1
解决办法
1560
查看次数