Oculus SDK - Spherical projection using DirectX
Hi,
I am trying to create a basic sphere with a texture map on it using the Oculus SDK 0.4.2 along with the direct to rift functionality for DK2. I am using the OculusTinyRoom example as the starter code. I have no prior experience in Direct3D and I am finding it hard to figure out how to get this done.
Currently, this is what I was able to do.
When I went through the OculusTinyRoom code, they were using slabs as a basic primitive to construct other geometry, hence I created a sphere using Slabs with this code :
But unfortunately the sphere is not smooth as expected because my slabs are are quite small enough. I also came across the createdirect3dSphere() function that can create a sphere. But I have no idea where to call it. Also once I get the sphere, how do I texture it using a spherical projection. Does direct3d have any built in function calls that can do this ?
I was trying to see if VRPlayer has any source code that can help, but did not find any. I would exactly like to simulate the VR video player (only the spherical projection of over/under input image part) but with DK2 direct to rift support.
Any information on this would be very helpful.
Thank you very much !
I am trying to create a basic sphere with a texture map on it using the Oculus SDK 0.4.2 along with the direct to rift functionality for DK2. I am using the OculusTinyRoom example as the starter code. I have no prior experience in Direct3D and I am finding it hard to figure out how to get this done.
Currently, this is what I was able to do.
When I went through the OculusTinyRoom code, they were using slabs as a basic primitive to construct other geometry, hence I created a sphere using Slabs with this code :
Slab SphereSlabs [2628] ;
void createSphereSlabs ()
{
//Slab SphereSlabs[200];//*b = new Slab[100];
float val = 3.14285/ 180;
int i = 0;
float rad = 3.0;
for(float p= 0; p <= 360; p=p +5)
{
for(float t= 0;t < 180; t=t +5)
{
Slab a ;
a.x1 = rad * sin(t *val) * cos(p *val);
a.y1 = rad * sin(t *val) * sin(p *val);
a.z1 = rad * cos(t *val);
a.x2 = rad * sin((t +5)* val) * cos ((p+ 5)*val );
a.y2 = rad * sin((t +5)* val) * sin ((p+ 5)*val ) ;
a.z2 = rad * cos((t +5)* val);
a.c = Color( 0,0 ,0) ;
SphereSlabs[i ] = a;
i++;
}
}
int totali = i;
But unfortunately the sphere is not smooth as expected because my slabs are are quite small enough. I also came across the createdirect3dSphere() function that can create a sphere. But I have no idea where to call it. Also once I get the sphere, how do I texture it using a spherical projection. Does direct3d have any built in function calls that can do this ?
I was trying to see if VRPlayer has any source code that can help, but did not find any. I would exactly like to simulate the VR video player (only the spherical projection of over/under input image part) but with DK2 direct to rift support.
Any information on this would be very helpful.
Thank you very much !
