コード例 #1
0
        bool
CLxSceneSelection::Get (
        CLxUser_ChannelRead	&evalChan)
{
        CLxUser_Scene		 scene;

        Get (scene);
        return scene.GetChannels (evalChan, srv_sel.GetTime ());
}
コード例 #2
0
OpenVDBItem* OpenVDBCreateFromFile::Alloc (
    VDBVoxelChannels	*creationInfo,
    bool			&isValid)
{
    CLxUser_Scene		 scene;
    CLxUser_ChannelRead	 readChan;
    CLxUser_Item		 fxItem;
    CLxItemType		 iType_Scene(LXsITYPE_SCENE);

    scene.from (this->m_item);
    scene.GetChannels (readChan, creationInfo->time); // Time is needed to get deformed meshes
    scene.GetItem(iType_Scene, fxItem);

    string filename, pattern;
    unsigned startDigit;
    // FPS is no need to cache, since its modification requires a restart of modo anyway.
    unsigned frame = readChan.FValue(fxItem, LXsICHAN_SCENE_FPS) * creationInfo->time;

    // Pattern has to be detected no earlier than here, since file names can be changed in different ways.
    if (VDBSeqFindInFilename (startDigit, pattern, creationInfo->cv_fileName)) {

        bool fileExist = false;

        // Loop used for skipping missed sequence files, if a frame is lacking, use the latest frame instead.
        for (int i = frame; i >= 0; i--) {

            GetCurrentFileName (i, startDigit, pattern, filename);

            // test if the file exists;
            ifstream f(filename.c_str ());
            if (f.good ()) {
                f.close ();
                fileExist = true;
                break;
            }
        }
        // when detection fails, we change back to use non-sequential file name;
        if (!fileExist)
            filename = creationInfo->cv_fileName;
    }
    else
        filename = creationInfo->cv_fileName;

    // never create invalid OpenVDBItems
    OpenVDBItem *vdb = NULL;
    ifstream f(filename.c_str ());
    if (f.good ()) {
        f.close ();
        vdb = new OpenVDBItem (filename, isValid);
        vdb->setOptFeatureNames (creationInfo->cv_featureNameList);
    }

    return vdb;
}
コード例 #3
0
        bool
CLxSceneSelection::Get (
        CLxUser_ChannelRead	&actChan,
        const char		*action)
{
        CLxUser_Scene		 scene;

        Get (scene);
        if (!action)
                action = LXs_ACTIONLAYER_EDIT;

        return scene.GetChannels (actChan, action, srv_sel.GetTime ());
}
コード例 #4
0
VoxelItemKey
OpenVDBCreateFromMesh::GenKey (
    const VDBVoxelChannels	*creationInfo)
{
    VoxelItemKey keys;
    unsigned key = VDBVoxelFNV::ComputeHashCode (*creationInfo, false);
    keys.base = key;

    /*
    *	Compute hash key by considering all triangles in the mesh.
    *	This is quite expensive, so it is only enabled with cache mode: Full.
    */

    if (creationInfo->mesh != NULL) {

        CLxUser_Mesh		 mesh;
        CLxUser_MeshFilter	 mfilt;
        CLxUser_Scene		 scene;
        CLxUser_ChannelRead	 readChan;
        CLxLoc_Point		 pointAccessor;
        unsigned		 index;

        if (this->m_srcitem.ChannelLookup (LXsICHAN_MESH_MESH, &index) == LXe_OK) {
            scene.from (this->m_srcitem);
            scene.GetChannels (readChan, creationInfo->time); // Time is needed to get deformed meshes
            if (readChan.Object (this->m_srcitem, index, mfilt)) {
                if (mfilt.GetMesh (mesh)) {

                    mesh.GetPoints (pointAccessor);
                    unsigned numPoints = mesh.NPoints ();
                    keys.mesh = VDBVoxelFNV::ComputeHashCode (pointAccessor, numPoints);
                }
            }

        }

    }
    return keys;
}
コード例 #5
0
	bool
CParticleAttachCommand::SetSource (
	CLxUser_Item		&item,
	CLxUser_Item		&source)
{
		CLxUser_Scene		 scene;
		CLxUser_ItemGraph	 graph;
		CLxUser_Item		 old;

		if (!scene.from (item) || !graph.from (scene, GRAPH_VOXELITEM))
			return false;

		while (graph.Reverse (item)) {
			graph.Reverse (item, 0, old);
			graph.DeleteLink (old, item);
		}

		if (source.test ()) {
			graph.AddLink (source, item);
			return true;
		}

		return false;
	}
コード例 #6
0
OpenVDBItem* OpenVDBCreateFromMesh::Alloc (
    VDBVoxelChannels	*creationInfo,
    bool			&isValid)
{
    CLxUser_Mesh		 mesh;
    CLxUser_MeshFilter	 mfilt;
    CLxUser_Scene		 scene;
    CLxUser_ChannelRead	 readChan;
    CLxLoc_Point		 pointAccessor;
    CLxLoc_Polygon		 polygonAccessor;
    CTriangleList		 tri;
    CSourceFinder		 src;
    unsigned		 index;

    if (this->m_srcitem.ChannelLookup (LXsICHAN_MESH_MESH, &index) == LXe_OK) {
        scene.from (this->m_srcitem);
        scene.GetChannels (readChan, creationInfo->time); // Time is needed to get deformed meshes
        if (readChan.Object (this->m_srcitem, index, mfilt)) {
            if (mfilt.GetMesh (mesh)) {

                mesh.GetPoints (pointAccessor);
                mesh.GetPolygons (polygonAccessor);
                unsigned numPolygons = mesh.NPolygons ();
                unsigned numPoints = mesh.NPoints ();

                /*
                *	read polygons, then generate triangles for each of them.
                *	push back to the triangles buffer.
                */

                for (unsigned i = 0; i < numPolygons; i++) {
                    unsigned numTriangles;
                    polygonAccessor.SelectByIndex (i);
                    polygonAccessor.GenerateTriangles (&numTriangles);

                    for (unsigned k = 0; k < numTriangles; k++) {
                        LXtPointID pointID [3];
                        unsigned   index [3];
                        polygonAccessor.TriangleByIndex (k, &pointID[0], &pointID[1], &pointID[2]);

                        for (unsigned j = 0; j < 3; j++) {
                            pointAccessor.Select (pointID[j]);
                            pointAccessor.Index (&index[j]);
                        }
                        tri.triangles.push_back (Vec3I (index[0], index[1], index[2]));
                    }
                }

                for (unsigned i = 0; i < numPoints; i++) {
                    LXtFVector xyz;
                    pointAccessor.SelectByIndex (i);
                    pointAccessor.Pos (xyz);

                    tri.points.push_back (Vec3s(xyz[0], xyz[1], xyz[2]));
                }

                return new OpenVDBItem (tri, creationInfo->voxelSize, creationInfo->cv_halfWidth, isValid);
            }
        }
    }

    return NULL;
}
コード例 #7
0
	void 
CCommandLoadFile::cmd_Execute (
	unsigned	 flags)
{
	CLxUser_ItemPacketTranslation	 itemPkt;
	CLxUser_SelectionService	 srv_sel;
	CLxUser_ChannelWrite		 chanWrite;
	CLxUser_ChannelWrite		 chanWriteEdit;
	CLxSceneSelection		 scene_sel;
	CLxUser_Scene			 scene;
	CLxUser_Item			 item;
	CLxUser_ItemGraph		 graph;
	LXtID4				 selID_item;
	std::string			 filename = "";
	std::string			 currentFeature;
	void				*pkt;

	/*
	*	Use selection system to get current VDBVoxelItem
	*	for executing the command.
	*/

	selID_item = srv_sel.LookupType (LXsSELTYP_ITEM);
	pkt = srv_sel.Recent (selID_item);
	scene_sel.Get (scene);
	itemPkt.autoInit ();
	itemPkt.GetItem (pkt, item);

	if (pkt != NULL) {
		attr_GetString (ARGi_FILENAME, filename);
		chanWrite.setupFrom (scene);
		if (filename != "") {

			/*	
			*	Update schematic graph link
			*/

			CLxUser_Scene		 scene;
			CLxUser_ItemGraph	 graph;
			CLxUser_Item		 old;

			if (scene.from (item) && graph.from (scene, GRAPH_VOXELITEM))
				while (graph.Reverse (item)) {
					graph.Reverse (item, 0, old);
					graph.DeleteLink (old, item);
				}

			/*
			*	Read only a small part of data from a VDB file for loading feature list.
			*	no voxel data is stored.
			*/

			OpenVDBItemPreLoader itemPreLoader (filename);
			chanWrite.Set (item, CN_DATA_FILE_NAME, filename.c_str());
			chanWrite.Set (item, CN_FILE_NAME, filename.c_str());
			
			std::string featureList;
			currentFeature = itemPreLoader.getFeatureNameList (featureList);
			chanWrite.Set (item, FEATURE_NAME_LIST, featureList.c_str());

			chanWriteEdit.from (item);
			chanWriteEdit.Set (item, CURRENT_FEATURE, currentFeature.c_str());
		}
			
	}
}