我一直在尝试用OpenGL ES创建自己的球体,我按照这里描述的数学运算http://www.math.montana.edu/frankw/ccp/multiworld/multipleIVP/spherical/learn.htm
然而,当我绘制球体(只是顶点)时,只绘制了一半球体.你能指点一下我在下面给出的代码中的确切问题:
public class Sphere {
static private FloatBuffer sphereVertex;
static private FloatBuffer sphereNormal;
static float sphere_parms[]=new float[3];
double mRaduis;
double mStep;
float mVertices[];
private static double DEG = Math.PI/180;
int mPoints;
/**
* The value of step will define the size of each facet as well as the number of facets
*
* @param radius
* @param step
*/
public Sphere( float radius, double step) {
this.mRaduis = radius;
this.mStep = step;
sphereVertex = FloatBuffer.allocate(40000);
mPoints = …Run Code Online (Sandbox Code Playgroud) 看看这个例子:https : //github.com/googlesamples/android-architecture-components/tree/master/GithubBrowserSample 我已经在我的一个副项目中实现了相同的模式,但是我在测试工作时遇到了困难正如预期的那样。
我正在尝试测试我的存储库类之一。该测试检查存储库是否从 api 获取数据以及观察者的值是否发生变化。
这是测试类
@RunWith(JUnit4.class)
public class TimelineRepositoryTest {
private SharedPreferences sharedPreferences;
private DatabaseDao databaseDao;
private ApiService apiService;
private TimelineRepository timelineRepository;
@Rule
public InstantTaskExecutorRule instantExecutorRule = new InstantTaskExecutorRule();
@Before
public void setup() {
sharedPreferences = mock(SharedPreferences.class);
databaseDao = mock(DatabaseDao.class);
apiService = mock(ApiService.class);
timelineRepository = new TimelineRepository(apiService, sharedPreferences, databaseDao);
timelineRepository.appExecutors = new InstantAppExecutors();
}
@Test
public void fetchTimelineWithForceFetch() {
TimelineResponse timelineResponse = new TimelineResponse();
when(sharedPreferences.getLong(PreferenceUtils.PREFERENCE_LAST_TIMELINE_REFRESH, 0)).thenReturn(0L);
when(apiService.retrieveTimeline()).thenReturn(ApiUtil.successCall(timelineResponse));
MutableLiveData<List<Event>> dbData = new MutableLiveData<>();
when(databaseDao.loadEvents()).thenReturn(dbData);
Observer observer = …Run Code Online (Sandbox Code Playgroud) 我一直在打自己,因为我认为这是一个简单的问题,但不知何故,我找不到解决方案.
我根据触摸移动事件旋转CCSprite关于其锚点.这是我用来旋转精灵的代码.
CGPoint previousLocation = [touch previousLocationInView:[touch view]];
CGPoint newLocation = [touch locationInView:[touch view]];
//preform all the same basic rig on both the current touch and previous touch
CGPoint previousGlLocation = [[CCDirector sharedDirector] convertToGL:previousLocation];
CGPoint newGlLocation = [[CCDirector sharedDirector] convertToGL:newLocation];
CCSprite *handle = (CCSprite*)[_spriteManager getChildByTag:HANDLE_TAG];
CGPoint previousVector = ccpSub(previousGlLocation, handle.position);
CGFloat firstRotateAngle = -ccpToAngle(previousVector);
CGFloat previousTouch = CC_RADIANS_TO_DEGREES(firstRotateAngle);
CGPoint currentVector = ccpSub(newGlLocation, handle.position);
CGFloat rotateAngle = -ccpToAngle(currentVector);
CGFloat currentTouch = CC_RADIANS_TO_DEGREES(rotateAngle);
float rotateAmount = (currentTouch - previousTouch);
handle.rotation += rotateAmount; …Run Code Online (Sandbox Code Playgroud)