Esempio n. 1
0
void TopicGraph::ConstructScene()
{
    //InitailIze ExtraInformation
    LoadNodes("GraphData/TopicGraph/Nodes.txt");
    LoadEdges("GraphData/TopicGraph/Edges.txt");
    LoadDocumentContents("GraphData/TopicGraph/DocumentContent.txt");

    this->mHighestDegree = GetHighestDegree();
    //add to scene
    ConstructOriginGraph();
    UpDateStrategy("Circular");

    for (int i = 0; i < mEdgeSize; ++i)
    {
        int *index = mEdges[i]->GetNodeIndex();
        QPointF source = mNodes[index[0]]->scenePos();
        QPointF target = mNodes[index[1]]->scenePos();

        mEdges[i]->setLine(QLineF(source, target));
        mEdges[i]->SetEdgeToolTip();
        mEdges[i]->SetMultiColorMode();
        this->addItem(mEdges[i]);
    }
    for (int i = 0; i < mNodeSize; ++i)
    {
        this->addItem(mNodes[i]);
        mNodes[i]->SetNodeToolTip();
        mNodes[i]->SetMultiColorMode();
       // qDebug() << mNodes[i]->mNodeId;
    }
}
RTREE_TEMPLATE
void RTREE_QUAL::SplitNode(Node* a_node, const Branch* a_branch, Node** a_newNode) {
    ASSERT(a_node);
    ASSERT(a_branch);

    // Could just use local here, but member or external is faster since it is reused
    PartitionVars localVars;
    PartitionVars* parVars = &localVars;

    // Load all the branches into a buffer, initialize old node
    GetBranches(a_node, a_branch, parVars);

    // Find partition
    ChoosePartition(parVars, MINNODES);

    // Create a new node to hold (about) half of the branches
    *a_newNode = AllocNode();
    (*a_newNode)->m_level = a_node->m_level;

    // Put branches from buffer into 2 nodes according to the chosen partition
    a_node->m_count = 0;
    LoadNodes(a_node, *a_newNode, parVars);

    ASSERT((a_node->m_count + (*a_newNode)->m_count) == parVars->m_total);
}
Esempio n. 3
0
bool BleBox::StartHardware()
{
	if (LoadNodes())
	{
		m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&BleBox::Do_Work, this)));
		m_bIsStarted = true;
		sOnConnected(this);
		return (m_thread != NULL);
	}
	return false;
}
Esempio n. 4
0
Import::Import(const char* pathName, Interface* ip, ImpInterface* impip)
{
    // set the path for textures
    char* ptr = NULL;
    sprintf (m_path, "%s", pathName);
    for (int i = 0; m_path[i]; i ++) {
        if ((m_path[i] == '\\') || (m_path[i] == '/') ) {
            ptr = &m_path[i];
        }
    }
    *ptr = 0;


    m_ip = ip;
    m_impip = impip;
    m_succes = TRUE;
    MaterialCache materialCache (NewDefaultMultiMtl());

    SetSceneParameters();

    dFloat scale;
    scale = float (GetMasterScale(UNITS_METERS));
    dMatrix scaleMatrix (GetIdentityMatrix());
    scaleMatrix[0][0] = 1.0f / scale;
    scaleMatrix[1][1] = 1.0f / scale;
    scaleMatrix[2][2] = 1.0f / scale;
    dMatrix globalRotation (scaleMatrix * dPitchMatrix(3.14159265f * 0.5f) * dRollMatrix(3.14159265f * 0.5f));

    NewtonWorld* newton = NewtonCreate();
    dScene scene (newton);

    scene.Deserialize (pathName);
//	dScene::Iterator iter (scene);
//	for (iter.Begin(); iter; iter ++) {
//		dScene::dTreeNode* node = iter.GetNode();
//		dNodeInfo* info = scene.GetInfoFromNode(node);
//		if (info->GetTypeId() == dMeshNodeInfo::GetRttiType()) {
//			dMeshNodeInfo* mesh = (dMeshNodeInfo*) scene.GetInfoFromNode(node);
//			mesh->ConvertToTriangles();
//		}
//	}
    scene.BakeTransform (globalRotation);

    GeometryCache geometryCache;
    MaxNodeChache maxNodeCache;

    LoadMaterials (scene, materialCache);
    LoadGeometries (scene, geometryCache, materialCache);
    LoadNodes (scene, geometryCache, materialCache.m_multiMat, maxNodeCache);
    ApplyModifiers (scene, maxNodeCache);

    scene.CleanUp();
    NewtonDestroy(newton);
}
Esempio n. 5
0
void RBTerrain::Load(const char *name)
{
	RUDE_REPORT("Loading terrain %s\n", name);
	
	LoadMesh(name);
	LoadPhysicsMesh(0.0f);
	
	LoadMaterials();
	
	RudePhysicsMesh *obj = (RudePhysicsMesh *) GetPhysicsObject();
	btRigidBody *rb = obj->GetRigidBody();

	rb->setFriction(50.0f);
	rb->setRestitution(0.99f);
	rb->setCollisionFlags(rb->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
	rb->setCollisionFlags(rb->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT);
	
	obj->SetNotifyOnContact(true);
	obj->SetContactCallback(RBTerrainContactCallback);
	

	LoadNodes();
	
	m_holeTexture = RudeTextureManager::GetInstance()->LoadTextureFromPNGFile("hole");
	RUDE_ASSERT(m_holeTexture, "Could not load hole texture");
	
	
	btDiscreteDynamicsWorld *world = RudePhysics::GetInstance()->GetWorld();
	
	
	btVector3 p0 = m_hole;
	p0.setY(m_hole.y() - 1000);
	btVector3 p1 = m_hole;
	p1.setY(m_hole.y() + 1000);
	
	btCollisionWorld::ClosestRayResultCallback cb(p0, p1);
	
	world->rayTest(p0, p1, cb);
	
	RUDE_ASSERT(cb.hasHit(), "Could not position hole.. is it over terrain? (%f %f %f)", m_hole.x(), m_hole.y(), m_hole.z());
	
	RUDE_REPORT("  Hole %f %f %f -> %f %f %f\n", m_hole.x(), m_hole.y(), m_hole.z(), cb.m_hitPointWorld.x(), cb.m_hitPointWorld.y(), cb.m_hitPointWorld.z());
	
	m_hole = cb.m_hitPointWorld;
	
	m_decorator.Load(name);
}
Esempio n. 6
0
void CKademlia::Connect()
{
	if(m_pKadHandler)
		return;

	m_pKadHandler = new CKadHandler(m_pSocket, this);
	m_pRootZone = new CRoutingRoot(m_pKadKey, this);
	m_pFirewallHandler = new CFirewallHandler(m_pSocket, this);
	LoadNodes();
	m_uLastSave = GetCurTick();

	m_pLookupManager = new CLookupManager(this);
	m_pPayloadIndex = new CPayloadIndex(this);

	m_pKadEngine = new CKadEngine(this);

	LogLine(LOG_INFO, L"Neo Kad Started");
}
Esempio n. 7
0
void dxModel::Load(const char * filename, bool fullpath)
{
    Free();

	FS_Change(FS_LOADING);

    loading_percent = 0;

    StrPool_Clear();

    DX_SAFE_FREE(mod_base); //free old map

    char fullfilename[MAX_PATH];

	if (fullpath)
	{
		static char temp[MAX_PATH];
		static char dirname[MAX_PATH];
		Str_ExtractDirName(filename, temp);
		Str_ExtractDirName(temp, dirname);

		Str_ExtractDirName(dirname, temp);

		strcat_s(temp, "\\valve");

		sysvar.basedir = dirname;
		sysvar.basedir_valve = temp;
		strcpy_s(fullfilename, filename);
	}
	else
	{
		sysvar.basedir = default_basedir;
		sysvar.basedir = default_basedir;
		sprintf_s(fullfilename, MAX_PATH, "%s\\maps\\%s.bsp", sysvar.basedir, filename);
	}
    

    FILE * f = NULL;
    fopen_s(&f, fullfilename, "rb");

    if (!f)
    {
        Sys_Error("could not open file %s", fullfilename);
    }

    fseek(f, 0, SEEK_END);
    long filesize = ftell(f);
    fseek(f, 0, SEEK_SET);

    mod_base = (char*)DX_MEM_ALLOC(filesize);
    if (!mod_base)
    {
        fclose(f);
        Sys_Error("could not alloc memory");
    }

    fread(mod_base, 1, filesize, f);
    fclose(f);

    dheader_s * header = (dheader_s*)mod_base;

    int v = Swap_LittleLong(header->version);
    if (v != BSPVERSION)
    {
        Sys_Error("bad bsp version");
    }

    for (int i = 0; i < HEADER_LUMPS; i++)
    {
        header->lumps[i].fileofs = Swap_LittleLong(header->lumps[i].fileofs);
        header->lumps[i].filelen = Swap_LittleLong(header->lumps[i].filelen);
    }

    UpdateLoadingPercent(6);

    //load entities first, we need wad file list
    LoadEntities(&header->lumps[LUMP_ENTITIES]);         UpdateLoadingPercent(12);
    LoadVertexes(&header->lumps[LUMP_VERTEXES]);         UpdateLoadingPercent(18);
    LoadEdges(&header->lumps[LUMP_EDGES]);               UpdateLoadingPercent(24);
    LoadSurfedges(&header->lumps[LUMP_SURFEDGES]);       UpdateLoadingPercent(30);
    LoadTextures(&header->lumps[LUMP_TEXTURES]);         UpdateLoadingPercent(36);
    LoadLighting(&header->lumps[LUMP_LIGHTING]);         UpdateLoadingPercent(42);
    LoadPlanes(&header->lumps[LUMP_PLANES]);             UpdateLoadingPercent(48);
    LoadTexinfo(&header->lumps[LUMP_TEXINFO]);           UpdateLoadingPercent(54);
    LoadFaces(&header->lumps[LUMP_FACES]);               UpdateLoadingPercent(60);
    LoadMarksurfaces(&header->lumps[LUMP_MARKSURFACES]); UpdateLoadingPercent(66);
    LoadVisibility(&header->lumps[LUMP_VISIBILITY]);     UpdateLoadingPercent(72);
    LoadLeafs(&header->lumps[LUMP_LEAFS]);               UpdateLoadingPercent(78);
    LoadNodes(&header->lumps[LUMP_NODES]);               UpdateLoadingPercent(84);
    LoadClipnodes(&header->lumps[LUMP_CLIPNODES]);       UpdateLoadingPercent(90);
    LoadSubmodels(&header->lumps[LUMP_MODELS]);          UpdateLoadingPercent(100);
    LoadSky();

    DX_SAFE_FREE(mod_base);

    visleafs = numleafs;
    if (numsubmodels > 0)
    {
        visleafs = submodels[0].visleafs;
    }

    InitViewer();

    loaded = true;

	FS_Change(FS_DEMO);
}
Esempio n. 8
0
File: map.c Progetto: fielder/fenton
int
Map_Load (const char *name)
{
	int direxists;

	map_error = NULL;
	memset (&loadmap, 0, sizeof(loadmap));

	if (Data_IsDir(name, &direxists) && direxists)
	{
		loaddir = name;
		Get = GetFromDir;
	}
	else
	{
		/* no directory with the map name; try a pak */

		const char *ext = ".pak";
		char path[2048];

		if (strlen(name) > (sizeof(path) - strlen(ext) - 1))
			return Error("map name too long");
		strcpy (path, name);
		strcat (path, ext);
		if ((loadpak = Pak_Open(path)) == NULL)
			return Error("unable to open \"%s\"", path);

		Get = GetFromPak;
	}

	if (!LoadPlanes())
		goto failed;
	if (!LoadVertices())
		goto failed;
	if (!LoadEdges())
		goto failed;
	if (!LoadEdgeLoops())
		goto failed;
	if (!LoadSurfaces())
		goto failed;
	if (!LoadPortals())
		goto failed;
	if (!LoadNodes())
		goto failed;
	if (!LoadLeafs())
		goto failed;
	if (!LoadTextures())
		goto failed;

	/* success; get rid of current map & switch over */

	Map_Unload ();
	map = loadmap;
	memset (&loadmap, 0, sizeof(loadmap));

	Get = NULL;
	loadpak = Pak_Close (loadpak);
	loaddir = NULL;

	return 1;

failed:
	/* failure; keep the currently-loaded map running */

	FreeMap (&loadmap);

	Get = NULL;
	loadpak = Pak_Close (loadpak);
	loaddir = NULL;

	return 0;
}
Esempio n. 9
0
void BleBox::ReloadNodes()
{
	UnloadNodes();
	LoadNodes();
}
Esempio n. 10
0
Bool BSPRooFileLoad(char *fname, room_type *room)
{
   int i, temp;
   BYTE byte;
   WORD num_nodes, num_walls, num_sectors, num_sidedefs;
   int node_pos, wall_pos, sidedef_pos, sector_pos, offset_adjust;
   file_node f;

   if (!MappedFileOpenCopy(fname, &f))
      return False;

   // Check magic number and version
   for (i = 0; i < 4; i++)
      if (CliMappedFileRead(&f, &byte, 1) != 1 || byte != room_magic[i])
      { MappedFileClose(&f); debug(("%s is not a roo file\n", fname)); return False; }

   security = 0;

   if (CliMappedFileRead(&f, &room_version, 4) != 4 || room_version < ROO_VERSION)
   { 
      MappedFileClose(&f); 
      debug(("Bad roo version %d; expecting %d\n", room_version, ROO_VERSION)); 
      return False; 
   }
   
   security += room_version;

   if (CliMappedFileRead(&f, &room->security, 4) != 4)
   { MappedFileClose(&f); return False; }   

   // Read pointer to main info in file, and go there
   if (CliMappedFileRead(&f, &temp, 4) != 4)
   { MappedFileClose(&f); return False; }
   MappedFileGoto(&f, temp);

   // Read size of room
   if (CliMappedFileRead(&f, &room->width, 4) != 4)
   { MappedFileClose(&f); return False; }

   offset_adjust = 0;
   room->cols = room->width >> LOG_FINENESS;

   if (CliMappedFileRead(&f, &room->height, 4) != 4)
   { MappedFileClose(&f); return False; }
   room->rows = room->height >> LOG_FINENESS;

   // Read pointers to file sections
   if (CliMappedFileRead(&f, &node_pos, 4) != 4) { MappedFileClose(&f); return False; }
   if (CliMappedFileRead(&f, &wall_pos, 4) != 4) { MappedFileClose(&f); return False; }
   if (CliMappedFileRead(&f, &temp, 4) != 4) { MappedFileClose(&f); return False; }
   if (CliMappedFileRead(&f, &sidedef_pos, 4) != 4) { MappedFileClose(&f); return False; }
   if (CliMappedFileRead(&f, &sector_pos, 4) != 4) { MappedFileClose(&f); return False; }
   node_pos += offset_adjust;
   wall_pos += offset_adjust;
   sidedef_pos += offset_adjust;
   sector_pos += offset_adjust;

   // Read nodes
   MappedFileGoto(&f, node_pos);
   if (CliMappedFileRead(&f, &num_nodes, 2) != 2) { MappedFileClose(&f); return False; }
   if (LoadNodes(&f, room, num_nodes) == False) 
   { 
      debug(("Failure loading %d nodes\n", num_nodes));
      MappedFileClose(&f); 
      return False; 
   }

   // Read walls
   MappedFileGoto(&f, wall_pos);
   if (CliMappedFileRead(&f, &num_walls, 2) != 2) { MappedFileClose(&f); return False; }
   if (LoadWalls(&f, room, num_walls) == False) 
   { 
      debug(("Failure loading %d walls\n", num_walls));
      MappedFileClose(&f); 
      return False; 
   }

   // Read sidedefs
   MappedFileGoto(&f, sidedef_pos);
   if (CliMappedFileRead(&f, &num_sidedefs, 2) != 2) { MappedFileClose(&f); return False; }
   if (LoadSidedefs(&f, room, num_sidedefs) == False) 
   { 
      debug(("Failure loading %d sidedefs\n", num_sidedefs));
      MappedFileClose(&f); 
      return False; 
   }

   // Read sectors
   MappedFileGoto(&f, sector_pos);
   if (CliMappedFileRead(&f, &num_sectors, 2) != 2) { MappedFileClose(&f); return False; }
   if (LoadSectors(&f, room, num_sectors) == False)
   { 
      debug(("Failure loading %d sectors\n", num_sectors));
      MappedFileClose(&f); 
      return False; 
   }
   
   MappedFileClose(&f);

   if (num_nodes == 0)
   {
      debug(("LoadRoom found room with no nodes!\n"));
      room->tree = NULL;
   }
   else room->tree = &room->nodes[0];

   if (RoomSwizzle(room, room->tree, num_nodes, num_walls, num_sidedefs, num_sectors) ==  False)
   {
      debug(("RoomSwizzle failed\n")); 
      BSPRoomFree(room);
      return False; 
   }

   security ^= 0x89ab786c;
   if (security != room->security)
   {
      debug(("Room security mismatch (got %d, expecting %d)!\n", security, room->security));
      BSPRoomFree(room);
      return False;
   }

   room->num_nodes    = num_nodes;
   room->num_walls    = num_walls;
   room->num_sectors  = num_sectors;
   room->num_sidedefs = num_sidedefs;

//   BSPDumpTree(room->tree, 0);
//   D3DGeometryBuild(room);
   gD3DRedrawAll |= D3DRENDER_REDRAW_ALL;
   SandstormInit();
	playerOldPos.x = 0;
	playerOldPos.y = 0;
	playerOldPos.z = 0;

   CacheReport();

   return True;
}