Ejemplo n.º 1
0
void Item::Respawn( Event * )
{
	if ( _missingSkin )
	{
		ChangeSkin( _missingSkin, false );
	}
	else
	{
		showModel();
	}
	
	// allow it to be touched again
	setSolidType( SOLID_TRIGGER );
	
	// play respawn sound
	if ( playrespawn )
	{
		Sound( "snd_itemspawn" );
	}
	
	setOrigin();
	
	if ( animate->HasAnim( "respawn" ) )
		animate->RandomAnimate( "respawn", EV_Item_RespawnDone );
	
	look_at_me = true;
	has_been_looked_at = false;
}
Ejemplo n.º 2
0
void keyboardCallback(unsigned char key, int x, int y)
{
    switch (key)
    {
        case 27: // ESC
            quitApp();
            break;

        case '\t': // TAB
            wireframeMode = !wireframeMode;
            break;

        case '\r': // ENTER
            orthoProj = !orthoProj;
            updateProjection();
            break;

        case ' ': // SPACE
            showBox = !showBox;
            break;

        default:
            if (key >= '1' && key <= '9')
                showModel(static_cast<size_t>(key - '1'));
            break;
    }
}
Ejemplo n.º 3
0
/*
============
PlaceItem

Puts an item back in the world
============
*/
void Item::PlaceItem( void )
{
	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( gpm->hasProperty(getArchetype(), "noautopickup") )
	{
		setContents( CONTENTS_USABLE );
		setSolidType( SOLID_BBOX );
	}
	else
	{
		setSolidType( SOLID_TRIGGER );
	}
	
	setMoveType( MOVETYPE_TOSS );
	showModel();
	
	groundentity = NULL;
}
Ejemplo n.º 4
0
Archivo: model.c Proyecto: Younday/AI1
int checkAllModels(int modelSize) {
  /* return 1 if KB entails INFER, otherwise 0 */
  inferred = 0;
  int i,j;
  int cnt = 0;
  while (cnt < pow(2,modelSize)) {
    i = cnt;
    j = 1;
    while (i != 0) {
      model[modelSize-j] = i%2;
      i = i/2;
      j++;
    }
    if (evaluateExpressionSet(inferSize, infer)) {
      return inferred = 1;
    }
    cnt++;
  }
  showModel(modelSize);
  return inferred;
}
Ejemplo n.º 5
0
Archivo: model.c Proyecto: Younday/AI1
void evaluateRandomModel(int modelSize) {
  int i;
  /* make a random assignment/model */
  for (i=0; i < modelSize; i++) {
    model[i] = random()%2;  /* 0 or 1 (False or True) */
  }

  /* print model */
  printf("Random chosen model: ");
  showModel(modelSize);

  /* evaluate KB */
  printf("  KB evaluates to ");
  showBoolean(evaluateExpressionSet(kbSize, kb));
  printf("\n");

  /* evaluate INFER */
  printf("  INFER evaluates to ");
  showBoolean(evaluateExpressionSet(inferSize, infer));
  printf("\n");
}
Ejemplo n.º 6
0
void PresentAction::activate(EntityMapping::ChangeContext& context) {

	if (mEntity.hasAttr("present")) {
		auto& element = mEntity.valueOfAttr("present");
		if (element.isString()) {
			auto& present = element.String();

			//If it's not an entity map it's either a mesh or a model.
			// Check if there's a model created already, if not we'll assume it's a mesh and create a model using that mesh
			if (!boost::ends_with(present, ".entitymap")) {
				if (!Model::ModelDefinitionManager::getSingleton().hasDefinition(present)) {
					//We'll automatically create a model which shows just the specified mesh.
					auto modelDef = std::make_shared<Model::ModelDefinition>();
					modelDef->setOrigin(present);
					//Create a single submodel definition using the mesh
					modelDef->createSubModelDefinition(present);
					Model::ModelDefinitionManager::getSingleton().addDefinition(present, std::move(modelDef));
				}
				showModel(present);
			}
		}
	}

}
Ejemplo n.º 7
0
void initScene()
{
    // generate texture
    texture = std::unique_ptr<Texture>(new Texture());
    texture->genImageMask(16, 16, false);

    // setup scene
    viewTransform.SetPosition({ 0, 0, -3 });

    //addModelPlane(); // reference model to check that UV-coords are correct
    addModelCuboid();
    addModelEllipsoid();
    addModelCone();
    addModelCylinder();
    addModelPipe();
    addModelTorus();
    addModelSpiral();
    addModelTorusKnot();
    //addModelCurve();
    //addModelBezierPatch();
    //addModelTeapot();
    //...

    for (auto it = models.begin(); it != models.end();)
    {
        #ifdef ENABLE_PRESENTATION
        // setup model for presentation
        it->turn(0, Gs::Deg2Rad(20.0f));
        it->turn(Gs::Deg2Rad(40.0f), 0);
        #endif

        // check for unused vertices in all models
        auto n = countUnusedVertices(it->mesh);
        if (n > 0)
            std::cout << it->name << " has " << n << " unused vertices" << std::endl;
        else if (n < 0)
        {
            std::cout << it->name << " has " << (-n) << " invalid vertices -> model removed from list" << std::endl;
            it = models.erase(it);
            continue;
        }

        // compute tangent vectors
        const auto& verts = it->mesh.vertices;
        auto numVerts = verts.size();
        it->tangents[0].resize(numVerts);
        it->tangents[1].resize(numVerts);

        Gs::Vector3 tangent, bitangent, normal;

        for (const auto& indices : it->mesh.triangles)
        {
            Gm::Triangle3 coords(
                verts[indices.a].position,
                verts[indices.b].position,
                verts[indices.c].position
            );

            Gm::Triangle2 texCoords(
                verts[indices.a].texCoord,
                verts[indices.b].texCoord,
                verts[indices.c].texCoord
            );

            Gm::ComputeTangentSpace(coords, texCoords, tangent, bitangent, normal);

            (it->tangents[0])[indices.a] = tangent;
            (it->tangents[1])[indices.a] = bitangent;

            (it->tangents[0])[indices.b] = tangent;
            (it->tangents[1])[indices.b] = bitangent;

            (it->tangents[0])[indices.c] = tangent;
            (it->tangents[1])[indices.c] = bitangent;
        }

        #ifdef WRITE_MODELS_TO_FILE
        // write model to file
        it->writeObjFile("mesh/" + it->name + ".obj");
        #endif

        ++it;
    }

    // show first model
    std::cout << std::endl;
    showModel(models.size() - 1);
}
Ejemplo n.º 8
0
void ModelViewer::setViewerWidget(ViewerWidget* widget) {
    viewerWidget = widget;
    mainSplit->addWidget(viewerWidget);
    showModel(viewing);
}