我有一个添加广告牌四边形的功能,我可以在其中映射纹理。旋转时,此纹理在3D地球周围移动。我的drawInRect看起来像这样:
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
// Clear the buffer and prepare to draw
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Enable the Earth texture
self.effect.texture2d0.name = _earthInfo.name;
self.effect.texture2d0.target = _earthInfo.target;
// Bind the earth vertex array
glBindVertexArrayOES(_earthVertexArray);
// Render the object with GLKit
[self.effect prepareToDraw];
// Draw elements from the index array and uv / vertex / normal info
glDrawElements(GL_TRIANGLES,Earth_polygoncount*3,GL_UNSIGNED_SHORT,0);
// Draw the SkyBox -- Draw skybox centered on eye position
// _skyboxEffect.center = _eyePosition;
// _skyboxEffect.transform.projectionMatrix = self.effect.transform.projectionMatrix;
// _skyboxEffect.transform.modelviewMatrix = self.effect.transform.modelviewMatrix;
// [_skyboxEffect prepareToDraw];
// [_skyboxEffect draw];
// Turn on Blending before displaying satellites
// so that the satellite image ( which has alpha )
// shows up OK
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
// Now billboard something
[self createBillboardAtLat:35 andLon:-97];
// Now billboard something
[self createBillboardAtLat:0 andLon:0];
// Now billboard something
[self createBillboardAtLat:-65 andLon:-137];
}
在createBillboardAt函数中,我这样画:
// Create a billboard that always faces the camera
- (void)createBillboardAtLat:(float)lat andLon:(float)lon {
... Do stuff ....
// Assign the new matrix to draw with - no translation
self.effect.transform.modelviewMatrix = noTranslationInfo;
// Render the object with GLKit
[self.effect prepareToDraw];
// Draw elements from the index array and uv / vertex / normal info
glDrawElements(GL_TRIANGLES,Billboard_polygoncount*3,GL_UNSIGNED_SHORT,0);
// Restore the original matrix
self.effect.transform.modelviewMatrix = originalMat;
}
我在添加广告牌之前打开混合,但在某些方向上,用于卫星的纹理与Globe完美融合但不能相互融合。请看截图...我做错了什么?
我已经尝试了所有这些选项,但都没有工作 - 只有一颗(最重要的)卫星只能掠过其中一颗卫星 - 而不是两颗卫星。请帮忙!
// Turn on Blending before displaying satellites
// so that the satellite image ( which has alpha )
// shows up OK
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
//glEnable(GL_DEPTH_TEST);
//glDepthFunc(GL_LEQUAL);
//glDepthMask(true);