Jump to content

  • Log In with Google      Sign In   
  • Create Account

Sword7

Member Since 22 Apr 2013
Offline Last Active May 13 2014 08:27 PM

Topics I've Started

Help! iterator problem

30 December 2013 - 08:50 PM

Folks,

 

I am working on my orbital flight simulator in C++ language.  I tried to implement find function call in class StarDatabase but encountered two blocking error messages. With using 'iterator', compiler complained about 'no match for operator ='.  I changed to 'const_iterator' and it worked but complaint 'invalid conversion from const to non const' at return statement.  That's why I want to return non const Star class to the caller to update it.  Does anyone know any solution or working around.

 

Look at my code below.

 

Thanks,

Sword7

std::vector<Star> unsortedStars;
Star *StarDatabase::find(uint32 catalogNumber) const
{
	std::vector<Star>::iterator iter;
	for (iter = unsortedStars.begin(); iter != unsortedStars.end(); iter++) {
		if ((*iter).getCatalogNumber() == catalogNumber)
			return &(*iter);
	}
	return NULL;
}


Quadcube spherical mapping

18 August 2013 - 08:25 PM

Folks,

 

I am getting fimilar with my OpenGL programming since last Spring and successfully wrote a program to display planet Earth by using ECP spherical mapping (slices and rings division).  Only problem is too tight grids near poles.

 

Now I researched about quadcube spherical programming for cubmap images through Internet.  I found some pages but it do not have sample code about that quadecube grids. Without sample code, I did still not know how to implement code to display quadcube sphere through simple vertexes, indices, and texcoords for glDrawElements function call.

 

Does anyone have any sample/example codes for quadcube sphere mapping for cubemaps?

 

Thanks!

 


Sphere texture mapping - distortion strip problem

23 April 2013 - 08:39 PM

Hello folks,

 

I am writing a small program to display planet earth by using glDrawElements and vertex/indices array.

 

It normally displays planet earth but seam strip between alaska and russia land.  I think that it is a problem with texcoords or glDrawElements function call.  I tried different ways but it always display distrotion strip.  Does anyone know any working around to get rid of distrotion strip?

Look at my code below.

 

Thanks!

Sword7

 

    int    thetaExtent = extent;

    int    phiExtent   = extent/2;

    int    theta1      = theta0 + thetaExtent;

    int    phi1        = phi0 + phiExtent;

    double phiStep     = (PI) / phiExtent;

    double thetaStep   = (2 * PI) / thetaExtent;

 
    double *v = vertices;

    double *t = texCoords;
    for (int phi = phi0; phi <= phi1; phi += ri.step) {

        for (int theta = theta0; theta < theta1; theta += ri.step) {

            *v++ = sin(phi * phiStep) * cos(theta * thetaStep);

            *v++ = cos(phi * phiStep);

            *v++ = sin(phi * phiStep) * sin(theta * thetaStep);



            *t++ = 1 - (theta * (1.0 / thetaExtent));

            *t++ = phi * (1.0 / phiExtent);

        }

    }



    uint16 *i = indices;

    for (int p = 0; p < phiExtent; p++) {

        for (int t = 0; t < thetaExtent; t++) {

            *i++ = p * thetaExtent + t;

            *i++ = p * thetaExtent + (t+1);

            *i++ = (p+1) * thetaExtent + (t+1);

            *i++ = (p+1) * thetaExtent + t;

        }

    }

 
    glVertexPointer(3, GL_DOUBLE, 0, vertices);

    glNormalPointer(GL_DOUBLE, 0, vertices);

    glTexCoordPointer(2, GL_DOUBLE, 0, texCoords);



    glDrawElements(GL_QUADS, nIndices, GL_UNSIGNED_SHORT, indices);

Angular Velocity and Quaternion - problems

23 April 2013 - 08:12 PM

Hello folks,

 

I am new to this gamedev.net forum that I searched for and found.  I searched for angular velocity and quaternion on Google but they did not help so much.  I implemented quaternion and angular velocity control (by using keyboard).  When I pitch to 90 degrees down, I tried to yaw right but it rolls right instead.  At zero Z-axis angle, it normally yaw right or left.  I want to rotate at current local axes, not origin axes.   My code implementation is:

 

dr = (angularVelocity * 0.5) * orientation;

orientation += (dr * dt);

orientation.normalize();

 

Where dt = delta time, dr = delta rotation

 

Does anyone have different angular velocity/quaternion formula to yaw, pitch, and roll at current local axes?

 

Thanks,

Sword7


PARTNERS