成果展示
原来的rgb成像是在上下部位,我看别人的论文显示的都是在左右或者前后部分,也显得比较美观,原来的虽然可以转到,但是不能转360°,所以不能转成把成像部分变到左右位置。
第一幅为原来的,第二幅是修改源码之后的。
修改方法
首先找到hypercube.py文件,这里边包括的是转到和显示的代码,里边有draw_cube,具体是下边的这些代码
# Top Face (note that the texture's corners have to match the quad's)
gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[0]))
gl.glBegin(gl.GL_QUADS)
gl.glTexCoord2f(0.0, 0.0)
gl.glVertex3f(hw, -hh, hz) # Bottom Left Of The Texture and Quad
gl.glTexCoord2f(1.0, 0.0)
gl.glVertex3f(hw, hh, hz) # Bottom Right Of The Texture and Quad
gl.glTexCoord2f(1.0, 1.0)
gl.glVertex3f(
-hw, hh, hz) # Top Right Of The Texture and Quad
gl.glTexCoord2f(0.0, 1.0)
gl.glVertex3f(
-hw, -hh, hz) # Top Left Of The Texture and Quad
gl.glEnd()
# Far Face
gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[3]))
gl.glBegin(gl.GL_QUADS)
gl.glTexCoord2f(0.0, 0.0)
gl.glVertex3f(
-hw, hh, -hz) # Top Left Of The Texture and Quad
gl.glTexCoord2f(1.0, 0.0)
gl.glVertex3f(
-hw, -hh, -hz) # Bottom Left Of The Texture and Quad
gl.glTexCoord2f(1.0, 1.0)
gl.glVertex3f(
-hw, -hh, hz) # Bottom Right Of The Texture and Quad
gl.glTexCoord2f(0.0, 1.0)
gl.glVertex3f(
-hw, hh, hz) # Top Right Of The Texture and Quad
gl.glEnd()
# Near Face
gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[1]))
gl.glBegin(gl.GL_QUADS)
gl.glTexCoord2f(0.0, 0.0)
gl.glVertex3f(
hw, -hh, -hz) # Top Right Of The Texture and Quad
gl.glTexCoord2f(1.0, 0.0)
gl.glVertex3f(
hw, hh, -hz) # Top Left Of The Texture and Quad
gl.glTexCoord2f(1.0, 1.0)
gl.glVertex3f(
hw, hh, hz) # Bottom Left Of The Texture and Quad
gl.glTexCoord2f(0.0, 1.0)
gl.glVertex3f(
hw, -hh, hz) # Bottom Right Of The Texture and Quad
gl.glEnd()
# Right face
gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[2]))
gl.glBegin(gl.GL_QUADS)
gl.glTexCoord2f(0.0, 0.0)
gl.glVertex3f(
hw, hh, -hz) # Bottom Right Of The Texture and Quad
gl.glTexCoord2f(1.0, 0.0)
gl.glVertex3f(
-hw, hh, -hz) # Top Right Of The Texture and Quad
gl.glTexCoord2f(1.0, 1.0)
gl.glVertex3f(
-hw, hh, hz) # Top Left Of The Texture and Quad
gl.glTexCoord2f(0.0, 1.0)
gl.glVertex3f(
hw, hh, hz) # Bottom Left Of The Texture and Quad
gl.glEnd()
# Left Face
gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[4]))
gl.glBegin(gl.GL_QUADS)
gl.glTexCoord2f(0.0, 0.0)
gl.glVertex3f(
-hw, -hh, -hz) # Bottom Left Of The Texture and Quad
gl.glTexCoord2f(1.0, 0.0)
gl.glVertex3f(
hw, -hh, -hz) # Bottom Right Of The Texture and Quad
gl.glTexCoord2f(1.0, 1.0)
gl.glVertex3f(
hw, -hh, hz) # Top Right Of The Texture and Quad
gl.glTexCoord2f(0.0, 1.0)
gl.glVertex3f(
-hw, -hh, hz) # Top Left Of The Texture and Quad
gl.glEnd()
# Bottom Face
gl.glBindTexture(gl.GL_TEXTURE_2D, int(self.textures[0]))
gl.glBegin(gl.GL_QUADS)
gl.glTexCoord2f(0.0, 0.0)
gl.glVertex3f(
hw, -hh, -hz) # Bottom Left Of The Texture and Quad
gl.glTexCoord2f(1.0, 0.0)
gl.glVertex3f(
hw, hh, -hz) # Bottom Right Of The Texture and Quad
gl.glTexCoord2f(1.0, 1.0)
gl.glVertex3f(
-hw, hh, -hz) # Top Right Of The Texture and Quad
gl.glTexCoord2f(0.0, 1.0)
gl.glVertex3f(
-hw, -hh, -hz) # Top Left Of The Texture and Quad
gl.glEnd()
这个就分为上、下、左、右、前、后六部分,想调对应的位置改一下就行。