【发布时间】:2019-06-17 03:41:24
【问题描述】:
我正在 PyOpenGL 中制作 RPG,我想检查相机是否指向某个距离内的对象(由顶点构成)。我该怎么做?
我尝试在对象的顶点上使用 range() 来检查相机是否在范围内。但它没有用。
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
import math,sys
def touched(tar_x,tar_y,tar_z,tar_w,tar_h,tar_d,tar_x1,tar_y1,tar_z1,tar_w1,tar_h1,tar_d1):
for i in range(tar_x1,tar_x1 + tar_w1):
for j in range(tar_y1,tar_y1 + tar_h1):
for k in range(tar_z1,tar_z1 + tar_d1)
if (tar_x < i < tar_x + tar_w) and (tar_y < j < tar_y + tar_h) and (tar_z < k < tar_z + tar_d):
return True
return False
#[...]
while True:
#[...]
if touched(int(person.x),int(person.y),int(person.z),10,5,5,int(camera_pos[0]),int(camera_pos[1]),int(camera_pos[2]),1,1,1): #
print("yes!") #
【问题讨论】:
标签: python-3.x opengl pygame pyopengl