コード例 #1
0
        void clipmap_ring::generate_indices()
        {
            unsigned int indices[4];

            ibuf.clear();

            for (int j = 0; j < PHI_STEPS; ++j)
            {
                for (int i = 0; i < THETA_STEPS; ++i)
                {
                    indices[0] = static_cast<unsigned int>( (j+0) * (THETA_STEPS+1) + (i+0) ); // lower left
                    indices[1] = static_cast<unsigned int>( (j+0) * (THETA_STEPS+1) + (i+1) ); // lower right
                    indices[2] = static_cast<unsigned int>( (j+1) * (THETA_STEPS+1) + (i+1) ); // upper right
                    indices[3] = static_cast<unsigned int>( (j+1) * (THETA_STEPS+1) + (i+0) ); // upper left
                    
                    repair_quad(indices);

                    ibuf.append(indices[0]);
                    ibuf.append(indices[1]);
                    ibuf.append(indices[3]);

                    ibuf.append(indices[2]);
                    ibuf.append(indices[3]);
                    ibuf.append(indices[1]);
                }
            }
        } // clipmap_ring::generate_indices()
コード例 #2
0
bool IC_CmdLineParser::parse( WideString& cmdName, array<WideString>& args )
{
    //  cout << "Parsing : [" << cmdLine << "]" << endl;
    static const wchar_t spaceChar = ( wchar_t )' ';
    args.clear();
    cmdName = L"";

    if ( cmdLine.findFirst( spaceChar ) == -1 )
    {
      cmdName = cmdLine;
      return true;
    }

    setQuoted( false );
    setEscaped( false );
    setNameDone( false );
    bShouldAddLast = true;
    resetTmpString();

    for ( s32 x = 0; x < cmdLine.size(); x++ )
    {
      if ( !handleChar( cmdLine[x], cmdName, args ) )
      {
        return false;
      }
    }
    if ( bShouldAddLast )
    {
      shoveTmpString( cmdLine, args );
    }
    return true;
}
コード例 #3
0
ファイル: class.compiler.cpp プロジェクト: vmorgulys/sandbox
 void clear()
 {
  _input_path.clear();
  _binary_path.clear();
  _output_path.clear();
  _core_path.clear();
  _map_path.clear();
  
  _input.clear();
  _output.clear();
  
  _literals.clear();
  _identifiers.clear();
  
  _compiler.clear();
  _tool.clear();
 }
コード例 #4
0
ファイル: maplayers.cpp プロジェクト: Redix/teeworlds
void CMapLayers::LoadEnvPoints(const CLayers *pLayers, array<CEnvPoint>& lEnvPoints)
{
	lEnvPoints.clear();

	// get envelope points
	CEnvPoint *pPoints = 0x0;
	{
		int Start, Num;
		pLayers->Map()->GetType(MAPITEMTYPE_ENVPOINTS, &Start, &Num);

		if(!Num)
			return;

		pPoints = (CEnvPoint *)pLayers->Map()->GetItem(Start, 0, 0);
	}

	// get envelopes
	int Start, Num;
	pLayers->Map()->GetType(MAPITEMTYPE_ENVELOPE, &Start, &Num);
	if(!Num)
		return;


	for(int env = 0; env < Num; env++)
	{
		CMapItemEnvelope *pItem = (CMapItemEnvelope *)pLayers->Map()->GetItem(Start+env, 0, 0);

		if(pItem->m_Version >= 3)
		{
			for(int i = 0; i < pItem->m_NumPoints; i++)
				lEnvPoints.add(pPoints[i + pItem->m_StartPoint]);
		}
		else
		{
			// backwards compatibility
			for(int i = 0; i < pItem->m_NumPoints; i++)
			{
				// convert CEnvPoint_v1 -> CEnvPoint
				CEnvPoint_v1 *pEnvPoint_v1 = &((CEnvPoint_v1 *)pPoints)[i + pItem->m_StartPoint];
				CEnvPoint p;

				p.m_Time = pEnvPoint_v1->m_Time;
				p.m_Curvetype = pEnvPoint_v1->m_Curvetype;

				for(int c = 0; c < pItem->m_Channels; c++)
				{
					p.m_aValues[c] = pEnvPoint_v1->m_aValues[c];
					p.m_aInTangentdx[c] = 0;
					p.m_aInTangentdy[c] = 0;
					p.m_aOutTangentdx[c] = 0;
					p.m_aOutTangentdy[c] = 0;
				}

				lEnvPoints.add(p);
			}
		}
	}
}
コード例 #5
0
        void clipmap_ring::generate_vertices()
        {
            // generate vertices (PHI_STEPS rings of THETA_STEPS+1 vertices)
            cbuf.clear();
            vbuf.clear();

            double delta_theta = 2.0 * math::PI / static_cast<double>(THETA_STEPS);

            for (int j = 0; j <= PHI_STEPS; ++j)
            {
                double eye_phi = 0;

                if (level)
                {
                    double exp = static_cast<double>(-j) / static_cast<double>(PHI_STEPS);
                    eye_phi = start_phi * ::pow(2.0, exp);
                }
                else
                {
                    double delta_phi = (start_phi - end_phi) / static_cast<double>(PHI_STEPS);
                    eye_phi = start_phi - delta_phi * static_cast<double>(j);
                }


                for (int i = 0; i <= THETA_STEPS; ++i)
                {
                    double eye_theta = delta_theta * static_cast<double>(i);

                    double eye_x = ::cos(eye_theta) * ::sin(eye_phi);
                    double eye_y = ::sin(eye_theta) * ::sin(eye_phi);
                    double eye_z = ::cos(eye_phi);

                    quaternion eye_point(0, eye_x, eye_y, eye_z);
                    quaternion yrot_point = (roty * eye_point) * roty_conj;
                    quaternion obj_point = (rotz * yrot_point) * rotz_conj;

                    double obj_x = obj_point.x;
                    double obj_y = obj_point.y;
                    double obj_z = obj_point.z;

                    double obj_phi = ::acos(obj_z);
                    double obj_theta = ::atan2(obj_y, obj_x) + (map_offset * math::PI_TIMES_2);
                    if (obj_theta < 0.0)
                        obj_theta += math::PI_TIMES_2;

                    cbuf.append(obj_phi);
                    cbuf.append(obj_theta);

                    float s = static_cast<float>(obj_theta / math::PI_TIMES_2);
                    float t = 1.0f - static_cast<float>(obj_phi / math::PI);

                    float nx = static_cast<float>(obj_x);
                    float ny = static_cast<float>(obj_y);
                    float nz = static_cast<float>(obj_z);

                    float x = parent->get_equatorial_radius() * nx;
                    float y = parent->get_equatorial_radius() * ny;
                    float z = parent->get_polar_radius() * nz;

                    if (hmap)
                    {
                        double hval, alpha;
                        hmap->get_data(s, t, hval, alpha);

                        vector old_vertex(x, y, z);
                        vector normal(nx, ny, nz);

                        gsgl::real_t alt = static_cast<gsgl::real_t>(hval * hmap->get_altitude());

                        vector new_vertex = old_vertex + normal*alt;

                        x = new_vertex[0];
                        y = new_vertex[1];
                        z = new_vertex[2];
                    }

                    vbuf.append(s);
                    vbuf.append(t);
                    vbuf.append(nx);
                    vbuf.append(ny);
                    vbuf.append(nz);
                    vbuf.append(x);
                    vbuf.append(y);
                    vbuf.append(z);
                }
            }
        } // clipmap_ring::generate_vertices()
コード例 #6
0
ファイル: class.storage.cpp プロジェクト: vmorgulys/sandbox
 void clear()
 {
  _array.clear();
 }