ParallelGraphics Forums
SDK
You are here: [Forums]::[General]::[SDK]

Registration 
Registration
Forgot your password?

Help 
Help
Support

Quick search 

Subscribe to newsletters 

Install Cortona VRML Client for FREE!
Outline 3D
Try RobinZone!
email:  password:
   General - SDK

Subject: MFVec3f.Add Method
Sender: mutafchiev@gmx.de 24.08.07 08:06

Hi,
I have some problem with creation of IndexedFaceSet.
I create a simple triangle.
When I create the Coordinate node with
CreateNodeFromString() there is no problem and the triangle
is created.
I have problem when I create the Coordinate node using
CreateNode() take the "point" field of it and fill the
"point" using MFVec3f.Add.
I dont know what is wrong in this code:

//BEGIN of creation of the IndexedFaceSet
CString IndexedFaceSetID = (L"IndexedFaceSet");
CComPtr<INodeObject> indexedFaceSet;

if(FAILED(m_Engine->CreateNode(L"IndexedFaceSet", CComBSTR(IndexedFaceSetID), &indexedFaceSet))){
        AfxMessageBox(L"IndexedFaceSetNode not created");        
    }    

// get the "coord" field of the "IndexedFaceSetNode"
    CComPtr<ISFNodeObject> m_CoordNode;        
    getField(indexedFaceSet, CComBSTR(L"coord"), (void**)&m_CoordNode, IID_ISFNodeObject);

    // use the m_Coordinate for "coord" field of the IndexedFaceSet
    CComPtr<INodeObject> m_GroundCoordinate;
    if(FAILED(m_Engine->CreateNode(L"Coordinate", CComBSTR("COORD"), &m_GroundCoordinate))){
        AfxMessageBox(L"COORD node not created");
    }
    /*bool success = SUCCEEDED(m_Engine->CreateNodeFromString ( CComBSTR(L"Coordinate {\point [ -2 -2 0, 0 2 0, 2 -2 0]\
            }"), &m_GroundCoordinate ));*/
//if(success)
    //AfxMessageBox(L"Object successifully created");

CComPtr<IMFVec3fObject> points;
getField(m_GroundCoordinate, CComBSTR(L"point"), (void**) &points, IID_IMFVec3fObject);

//HRESULT hresult;
VARIANT varBeforeEnd;
VariantInit( &varBeforeEnd);
varBeforeEnd.vt = VT_ERROR;
varBeforeEnd.lVal = DISP_E_MEMBERNOTFOUND;

VARIANT varVal;
VariantInit( &varVal );
varVal.vt=VT_ARRAY | VT_VARIANT;
varVal.parray=SafeArrayCreateVector(VT_R4, 0, 3);    

    
int vt,fail=0;
long ix;    
float x, y, z;
//1 point
//coordX    
x = -2.;
ix = 0;        
SafeArrayPutElement(varVal.parray, &ix, &x);
//coordY        
y = -2.;
ix = 1;        
SafeArrayPutElement(varVal.parray, &ix, &y);    
//coordZ        
z = 0.;
ix = 2;        
SafeArrayPutElement(varVal.parray, &ix, &z);
points->Add(&varVal, &varBeforeEnd);

//2 point
//coordX    
x = 0.;
ix = 0;        
SafeArrayPutElement(varVal.parray, &ix, &x);
//coordY        
y = 2.;
ix = 1;    
SafeArrayPutElement(varVal.parray, &ix, &y);    
//coordZ        
z = 0.;
ix = 2;    
SafeArrayPutElement(varVal.parray, &ix, &z);    
points->Add(&varVal, &varBeforeEnd);

//3 point
//coordX    
x = -2.;
ix = 0;    
SafeArrayPutElement(varVal.parray, &ix, &x);
//coordY        
y = -2.;
ix = 1;
SafeArrayPutElement(varVal.parray, &ix, &y);    
//coordZ        
z = 0.;
ix = 2;    
SafeArrayPutElement(varVal.parray, &ix, &z);    
points->Add(&varVal, &varBeforeEnd);

// use the m_Coordinate for "coord" field of the IndexedFaceSet
    if(FAILED(m_CoordNode->put_Value(m_GroundCoordinate))){
        AfxMessageBox(L"putValue m_Coordinate failed");                
    }    

 


MFVec3f.Add Method / mutafchiev@gmx.de / 24.08.07 08:06

Messages in thread: 1


© 1998-2007 ParallelGraphics. All rights reserved. Terms of use.