Ejemplo n.º 1
0
Vec3f calcMinGeometryBounds(GeometryUnrecPtr geo)
{
    if(geo == NULL ||
       geo->getPositions() == NULL ||
       geo->getPositions()->size() == 0)
    {
        return Vec3f();
    }

    GeoVectorProperty* Positions(geo->getPositions());

    Pnt3f Min(Positions->getValue<Pnt3f>(0)), 
        Max(Positions->getValue<Pnt3f>(0));


    for(UInt32 i(1) ; i<Positions->size(); ++i)
    {
        Min[0] = osgMin(Min[0], Positions->getValue<Pnt3f>(i)[0]);
        Min[1] = osgMin(Min[1], Positions->getValue<Pnt3f>(i)[1]);
        Min[2] = osgMin(Min[2], Positions->getValue<Pnt3f>(i)[2]);

        Max[0] = osgMax(Max[0], Positions->getValue<Pnt3f>(i)[0]);
        Max[1] = osgMax(Max[1], Positions->getValue<Pnt3f>(i)[1]);
        Max[2] = osgMax(Max[2], Positions->getValue<Pnt3f>(i)[2]);
    }

    return Max-Min;
}
Ejemplo n.º 2
0
Joints Joints::Positions(const std::vector< double >& positions, const std::vector< std::string >& names)
{
    Joints result = Positions(positions);
    if (result.elements.size() != names.size())
        throw std::runtime_error("the position and names vectors differ");
    result.names = names;
    return result;
}
Ejemplo n.º 3
0
int main()
{
	GameManager* gm = GameManager::getInstance();								//init GameManager
	gm->setArea(20,20);															//set map Area, set lenth and width

	Rover* rover1 = new Rover(Positions(0,0), 'N', "MMMMRMMMRMMMRLMMMR");		//init Rover object
	Rover* rover2 = new Rover(Positions(3,3), 'E', "MMRMRMMRRMRMLM");
	
	gm->addRover(rover1);														//add to GameManager, Unified handling   
	gm->addRover(rover2);

	printf("\n");
	gm->commandRoversMove();													//togethor move by command  

	delete gm;
	getchar();
	return 0;
}
// Called by Rocket when it wants to render geometry that it does not wish to optimise.
void RocketSDL2Renderer::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
{
    // SDL uses shaders that we need to disable here  
    glUseProgramObjectARB(0);
    glPushMatrix();
    glTranslatef(translation.x, translation.y, 0);
 
    std::vector<Rocket::Core::Vector2f> Positions(num_vertices);
    std::vector<Rocket::Core::Colourb> Colors(num_vertices);
    std::vector<Rocket::Core::Vector2f> TexCoords(num_vertices);
    float texw, texh;
 
    SDL_Texture* sdl_texture = NULL;
    if(texture)
    {
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        sdl_texture = (SDL_Texture *) texture;
        SDL_GL_BindTexture(sdl_texture, &texw, &texh);
    }
 
    for(int  i = 0; i < num_vertices; i++) {
        Positions[i] = vertices[i].position;
        Colors[i] = vertices[i].colour;
        if (sdl_texture) {
            TexCoords[i].x = vertices[i].tex_coord.x * texw;
            TexCoords[i].y = vertices[i].tex_coord.y * texh;
        }
        else TexCoords[i] = vertices[i].tex_coord;
    };
 
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, &Positions[0]);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, &Colors[0]);
    glTexCoordPointer(2, GL_FLOAT, 0, &TexCoords[0]);
 
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
 
    if (sdl_texture) {
        SDL_GL_UnbindTexture(sdl_texture);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    }
 
    glColor4f(1.0, 1.0, 1.0, 1.0);
    glPopMatrix();
    /* Reset blending and draw a fake point just outside the screen to let SDL know that it needs to reset its state in case it wants to render a texture */
    glDisable(GL_BLEND);
    SDL_SetRenderDrawBlendMode(mRenderer, SDL_BLENDMODE_NONE);
    SDL_RenderDrawPoint(mRenderer, -1, -1);
}
// Called by Rocket when it wants to render geometry that it does not wish to optimise.
void RocketSFMLRenderer::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
{
    MyWindow->setActive();

    glPushMatrix();
    glTranslatef(translation.x, translation.y, 0);

    std::vector<Rocket::Core::Vector2f> Positions(num_vertices);
    std::vector<Rocket::Core::Colourb> Colors(num_vertices);
    std::vector<Rocket::Core::Vector2f> TexCoords(num_vertices);

    for(int  i = 0; i < num_vertices; i++)
    {
        Positions[i] = vertices[i].position;
        Colors[i] = vertices[i].colour;
        TexCoords[i] = vertices[i].tex_coord;
    };

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    glVertexPointer(2, GL_FLOAT, 0, &Positions[0]);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, &Colors[0]);
    glTexCoordPointer(2, GL_FLOAT, 0, &TexCoords[0]);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    if(texture)
    {
        glEnable(GL_TEXTURE_2D);
        sf::Texture::bind((sf::Texture*)texture, sf::Texture::Normalized);
    }
    else
    {
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        glBindTexture(GL_TEXTURE_2D, 0);
    };

    glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices);

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);

    glColor4f(1, 1, 1, 1);

    glPopMatrix();

}
Ejemplo n.º 6
0
Pnt3f calcGeometryCenter(GeometryUnrecPtr geo)
{
    if(geo == NULL ||
       geo->getPositions() == NULL ||
       geo->getPositions()->size() == 0)
    {
        return Pnt3f();
    }

    GeoVectorProperty* Positions(geo->getPositions());

    Pnt3f Sum;


    for(UInt32 i(1) ; i<Positions->size(); ++i)
    {
        Sum = Sum + Vec3f(Positions->getValue<Pnt3f>(i));
    }

    return Sum * (1.0f/static_cast<Real32>(Positions->size()));
}
Ejemplo n.º 7
0
void CStringExt::BeginMove()
{
	Count();
	Positions();
	m_lMoveIndex=0;
}