void U2MaxCameraExport::Export(Interface* pIf, INode *pMaxNode, Object *obj)
{

	CameraObject* camObj = (CameraObject*)obj;

	// get camera state
	Interval interval;
	CameraState camState;
	camObj->EvalCameraState(m_animStart, interval, &camState);

	bool bFixedCam = false;
	if(camObj->GetManualClip())
		bFixedCam = true;

	float fFov = camState.fov;
	BOOL bIsOrtho = camState.isOrtho;

	float fInvAspectRatio = 1.0f / pIf->GetRendImageAspect();

	if(bIsOrtho)
	{
		float fWidth = 640.0f / 4.0f;
		float fHeight = 480.0f / 4.0f;
		float fScalar = camObj->GetTDist(0) / 200.0f;
	}
	else 
	{
		// add
	}

	if(bFixedCam)
	{
		float fNearPlane = camState.hither;
		float farPlane = camState.yon;
	}
	else 
	{
		float nearPlane = 1.0f;
		float farPlane = 6000.0f;
	}

	ViewExp* viewport = pIf->GetActiveViewport();
	if(viewport)
	{
		INode* pMaxViewCam = viewport->GetViewCamera();

		if(pMaxNode == pMaxViewCam)
		{
			; 
		}

		pIf->ReleaseViewport(viewport);
	}
	else 
	{
		;
	}
}
void keyboard( unsigned char key, int x, int y )
{
	switch ( key ) {
		case 033: case 'q': case 'Q':
			exit( EXIT_SUCCESS );
			break;
		case 'l':
			camera.removeParent();
			camera.unlockPlane();
			break;
		case 'w':
			camera.setMoveForward(true);
			break;
		case 's':
			camera.setMoveBackward(true);
			break;
		case 'd':
			camera.setMoveRight(true);
			break;
		case 'a':
			camera.setMoveLeft(true);
			break;
		case 'r':
			camera.setMoveUp(true);
			break;
		case 'f':
			camera.setMoveDown(true);
			break;
	}
}
void keyboardUp(unsigned char key, int x, int y)
{
	switch (key)
	{
		case 'w':
			camera.setMoveForward(false);
			break;
		case 's':
			camera.setMoveBackward(false);
			break;
		case 'd':
			camera.setMoveRight(false);
			break;
		case 'a':
			camera.setMoveLeft(false);
			break;
		case 'r':
			camera.setMoveUp(false);
			break;
		case 'f':
			camera.setMoveDown(false);
			break;
		case 'p': case 'P':
			cerr << camera.getPosition() << endl;
			break;
	}
}
void idle()
{
	camera.update();
	train->update();

	delta += 0.2;

	glutPostRedisplay(); 
}
void SphereObject::setRenderState( void )
{	
	// Bind the texture
	GLuint textureID = TextureMan::Find( this->Texture );
	glBindTexture(GL_TEXTURE_2D, textureID);

	CameraObject *cam = CameraMan::GetCurrCamera();

	// set the shader
		// modelViewProj matrix, stock shader.
			Matrix mvp = this->ModelView * cam->getProjMatrix();
			shaderManager.UseStockShader( GLT_SHADER_FLAT,
											&mvp,
											&this->lightColor );

			// set render states
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
			glEnable(GL_CULL_FACE);
};
Beispiel #6
0
void OrbitingViewer::SetUpCamera(CameraObject &camera)
{
    camera.h=h;
    camera.p=p;
    camera.b=0.0;

    double vx,vy,vz;
    camera.GetForwardVector(vx,vy,vz);
    camera.x=focusX-vx*dist;
    camera.y=focusY-vy*dist;
    camera.z=focusZ-vz*dist;
}
Beispiel #7
0
void Exporter::ExportCameraObject(INode* node, int indentLevel)
{
	RSCameraObject *pCO=new RSCameraObject;
	pCO->name=new char[strlen(node->GetName())+1];
	strcpy(pCO->name,node->GetName());

	INode* target = node->GetTarget();
	ExportNodeTM(node, indentLevel,&pCO->tm);

	CameraState cs;
	TimeValue t = GetStaticFrame();
	Interval valid = FOREVER;
	// Get animation range
	Interval animRange = ip->GetAnimRange();
	
	ObjectState os = node->EvalWorldState(t);
	CameraObject *cam = (CameraObject *)os.obj;
	
	cam->EvalCameraState(t,valid,&cs);
	pCO->fov=cs.fov;

#define TARGETFPS	60

	TimeValue start = ip->GetAnimRange().Start();
	TimeValue end = ip->GetAnimRange().End();
	int delta = GetTicksPerFrame() * GetFrameRate() / TARGETFPS;
	Matrix3 tm;

	rsm->m_nCameraFrame=(end-start)/delta+1;
	Matrix3 *m=pCO->am=new Matrix3[rsm->m_nCameraFrame];
	for (t=start; t<=end; t+=delta) {
		tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t));
		*m=tm;
		m++;
	}
	
	rsm->m_CameraList.Add(pCO);

}
// handles glut mouse movement events
void passiveMotion(int x, int y)
{
	// make sure we're not in the center
	if (x != 255 || y != 255)
	{
		vec3 rotation(0);
		rotation.x = -(255 - y);
		rotation.y = -(255 - x);
		camera.rotate(rotation);

		glutWarpPointer(255, 255);
	}
}
void SphereObject::transform( void )
{
	// FIRST you need to match the Original Sphere on to the original Graphics Object
	
	// create temp matrices
		Matrix Trans( TRANS, this->extSphere.cntr[x], this->extSphere.cntr[y],this->extSphere.cntr[z]);

		float scale = 2.0f;
		// since the base model has a radius 0.5, so everything needs to multiplied by 2
		Matrix Scale( SCALE, this->extSphere.rad*scale, this->extSphere.rad*scale, this->extSphere.rad*scale);
	
	// Create the local to world matrix (ie Model)
		Matrix  MapSphere =  Scale * Trans;

	// Now apply the extern object so it moves and rotates the same
	this->World = MapSphere * this->extWorld;

	// Create the ModelView ( LocalToWorld * View)
	// Some pipelines have the project concatenated, others don't
	// Best to keep the separated, you can always join them with a quick multiply
	CameraObject *cam = CameraMan::GetCurrCamera();
	this->ModelView = this->World * cam->getViewMatrix();

};
void display( void )
{
	int i;
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	glUniformMatrix4fv(perspectiveMatLoc, 1, true, Perspective(60, 1.0, 0.01, 100));
	glUniformMatrix4fv( camMatLoc, 1, true, camera.getTransformationMatrix() );

	for (i = 0; i < NUM_LIGHTS; i++) {
		Light[i].setValues();
	}
	glUniform1f(MatProp.shinyid, MatProp.values.shininess);

	world.drawActors();

	glFlush();
}
    void TrackingBruteForce::writeToDebugImage(CameraObject &cameraCurr)
    {
        if(!cameraCurr.hasImage("debugImage"))
            cameraCurr.addImage("debugImage", cameraCurr.getImage("rawImage").clone());
        cv::Mat debugImage = cameraCurr.getImage("debugImage");
        std::string text = "";
        int fontFace = cv::FONT_HERSHEY_PLAIN;
        double fontScale = 1;
        int thickness = 1;
        for(std::vector<Object>::iterator object = cameraCurr.getPotentialObjects().begin(); object != cameraCurr.getPotentialObjects().end(); object++) {
            cv::Point2d pos = object->centerOfMass;
            text = "lifespan: " + std::to_string(object->lifeSpan);
            putText(debugImage, text, pos, fontFace, fontScale, cv::Scalar(0,0,255), thickness, 8);
            cv::rectangle(debugImage, object->boundingBox, cv::Scalar(0,0,255), 2);
            cv::circle(debugImage, object->centerOfMass, 10, cv::Scalar(0,0,100), -1);
        }
        for(std::vector<Object>::iterator object = cameraCurr.getObjects().begin(); object != cameraCurr.getObjects().end(); object++) {
            cv::Point2d pos = object->centerOfMass;
            text = "id: "+std::to_string(object->id);

            if(object->lost) {
                text += ", LOST lifespan: " + std::to_string(object->lifeSpan);
                cv::rectangle(debugImage, object->boundingBox, cv::Scalar(255,0,0), 2);
                cv::circle(debugImage, object->centerOfMass, 10, cv::Scalar(100,0,0), -1);
                putText(debugImage, text, pos, fontFace, fontScale, cv::Scalar(255, 0, 0), thickness, 8);
            } else {
                cv::rectangle(debugImage, object->boundingBox, cv::Scalar(0,255,0), 2);
                cv::circle(debugImage, object->centerOfMass, 10, cv::Scalar(0,100,0), -1);
                putText(debugImage, text, pos, fontFace, fontScale, cv::Scalar(0, 255, 0), thickness, 8);
            }
            cv::line(debugImage, object->centerOfMass, object->centerOfMass+object->velocity*10, cv::Scalar(0,255,0), 3);
            cv::line(debugImage, object->centerOfMass, object->centerOfMass+object->velocityPrediction*10, cv::Scalar(255,0,0), 2);
            cv::circle(debugImage, object->positionPrediction, 6, cv::Scalar(255,0,0), 2);


        }
    }
Beispiel #12
0
void RBExport::ProcessCamera( INode* node )
{
    if (m_pConfig->m_bExportCameras == false)
    {
        return;
    }

    ObjectState os = node->EvalWorldState( m_CurTime );
    Object* pCurObject = os.obj;
    if (!pCurObject) return;

    CameraObject* camObj = (CameraObject*)pCurObject;
    Interval validIvl;
    CameraState cs;

    RefResult res = camObj->EvalCameraState( m_CurTime, validIvl, &cs );
    if ( res != REF_SUCCEED)
    {
        Err( "Error processing camera <%s>", node->GetName() );
        return;
    }

    Info( "Processing camera <%s>", node->GetName() );

    Matrix3 camTM = c_CamFlipTM*node->GetNodeTM( m_CurTime );

    Matrix3 parentTM;
    INode* pParent = node->GetParentNode();
    if (pParent && !pParent->IsRootNode())
    {
        parentTM = pParent->GetNodeTM( m_CurTime );
    }
    else
    {
        parentTM = c_IdentityTM;
    }
    parentTM = c_FlipTM*parentTM;
    camTM = camTM*Inverse( parentTM );

    JCamera* pCamera = new JCamera();
    pCamera->SetWorldTM( Convert( camTM ) );

    float aspect = ((float)m_pInterface->GetRendWidth())/((float)m_pInterface->GetRendHeight());
    float zn     = cs.nearRange;
    float zf     = cs.farRange;
    float fov    = cs.fov;
    if (zn < c_FltEpsilon) zn = 1.0f;

    pCamera->SetOrtho  ( cs.isOrtho == TRUE );
    pCamera->SetZNear  ( zn );
    pCamera->SetZFar   ( zf );
    pCamera->SetAspect ( aspect ); 

    if (cs.isOrtho)
    {
        float vVol = 2.0f * cs.tdist * tan( cs.fov * 0.5f );
        pCamera->SetFOVx( vVol );
    }
    else
    {
        pCamera->SetFOVx( RadToDeg( fov ) );
    }

    pCamera->SetName( node->GetName() );

    //  insert camera as the first node in the model
    m_pModel->AddChild( pCamera, 0 );
} // RBExport::ProcessCamera
Beispiel #13
0
void ComponentDrawCamera::draw (CameraObject* camera)
{
    CameraObject *placeable = checkedCast<CameraObject*>(getOwner());
    if (!placeable)
        return;
        
    _line_material.setBlendEnable(false);
    _line_material.setDepthEnable(true);
    _line_material.setCullMode(DT3GL_CULL_NONE);
    _line_material.setColor(_color);
	_line_material.setShader(ShaderResource::getShader(FilePath("{editorline.shdr}")));


    DrawBatcher b;
    b.batchBegin(&_line_material, placeable->getTransform(), DrawBatcher::BATCH_LINES, DrawBatcher::FMT_V);

    // Can
    for (DTuint i = 0; i < ARRAY_SIZE(can); ++i) {        
        b.vertex( Vector3(THICKNESS, can[i].x, can[i].y) );
        b.vertex( Vector3(-THICKNESS, can[i].x, can[i].y) );
    }

    for (DTuint i = 0; i < ARRAY_SIZE(can)-1; ++i) {        
        b.vertex( Vector3(THICKNESS, can[i].x, can[i].y) );
        b.vertex( Vector3(THICKNESS, can[i+1].x, can[i+1].y) );
        
        b.vertex( Vector3(-THICKNESS, can[i].x, can[i].y) );
        b.vertex( Vector3(-THICKNESS, can[i+1].x, can[i+1].y) );
    }
    
    // Box
    for (DTuint i = 0; i < ARRAY_SIZE(box); ++i) {        
        b.vertex( Vector3(THICKNESS, box[i].x, box[i].y) );
        b.vertex( Vector3(-THICKNESS, box[i].x, box[i].y) );
    }

    for (DTuint i = 0; i < ARRAY_SIZE(box)-1; ++i) {        
        b.vertex( Vector3(THICKNESS, box[i].x, box[i].y) );
        b.vertex( Vector3(THICKNESS, box[i+1].x, box[i+1].y) );
        
        b.vertex( Vector3(-THICKNESS, box[i].x, box[i].y) );
        b.vertex( Vector3(-THICKNESS, box[i+1].x, box[i+1].y) );
    }

    // Side
    for (DTuint i = 0; i < ARRAY_SIZE(side); ++i) {        
        b.vertex( Vector3(THICKNESS, side[i].x, side[i].y) );
        b.vertex( Vector3(SIDE_THICKNESS+THICKNESS, side[i].x, side[i].y) );
    }

    for (DTuint i = 0; i < ARRAY_SIZE(side)-1; ++i) {        
        b.vertex( Vector3(THICKNESS, side[i].x, side[i].y) );
        b.vertex( Vector3(THICKNESS, side[i+1].x, side[i+1].y) );
        
        b.vertex( Vector3(SIDE_THICKNESS+THICKNESS, side[i].x, side[i].y) );
        b.vertex( Vector3(SIDE_THICKNESS+THICKNESS, side[i+1].x, side[i+1].y) );
    }
    
    // Lens
    for (DTuint i = 0; i < ARRAY_SIZE(lens); ++i) {        
        b.vertex( Vector3(LENS_THICKNESS, lens[i].x, lens[i].y) );
        b.vertex( Vector3(-LENS_THICKNESS, lens[i].x, lens[i].y) );
    }

    for (DTuint i = 0; i < ARRAY_SIZE(lens)-1; ++i) {        
        b.vertex( Vector3(LENS_THICKNESS, lens[i].x, lens[i].y) );
        b.vertex( Vector3(LENS_THICKNESS, lens[i+1].x, lens[i+1].y) );
        
        b.vertex( Vector3(-LENS_THICKNESS, lens[i].x, lens[i].y) );
        b.vertex( Vector3(-LENS_THICKNESS, lens[i+1].x, lens[i+1].y) );
    }
    
    b.batchEnd();
	b.flush();

    // Frustum
    
	placeable->calculateFrustum();
	Matrix4 projection_inv = placeable->getProjection().inversed();
	
	Vector3 near_p0, near_p1, near_p2, near_p3;
	Vector3 far_p0, far_p1, far_p2, far_p3;
	
	MATTransform4H(projection_inv, Vector3(-1.0F,-1.0F,-1.0F), near_p0);
	MATTransform4H(projection_inv, Vector3(1.0F,-1.0F,-1.0F), near_p1);
	MATTransform4H(projection_inv, Vector3(1.0F,1.0F,-1.0F), near_p2);
	MATTransform4H(projection_inv, Vector3(-1.0F,1.0F,-1.0F), near_p3);
	
	MATTransform4H(projection_inv, Vector3(-1.0F,-1.0F,1.0F), far_p0);
	MATTransform4H(projection_inv, Vector3(1.0F,-1.0F,1.0F), far_p1);
	MATTransform4H(projection_inv, Vector3(1.0F,1.0F,1.0F), far_p2);
	MATTransform4H(projection_inv, Vector3(-1.0F,1.0F,1.0F), far_p3);

	b.batchBegin (&_line_material, placeable->getTransform(), DrawBatcher::BATCH_LINE_LOOP, DrawBatcher::FMT_V);
	b.vertex ( near_p0);
	b.vertex ( near_p1);
	b.vertex ( near_p2);
	b.vertex ( near_p3);
	b.batchEnd();
	b.flush();
	
	b.batchBegin (&_line_material, placeable->getTransform(), DrawBatcher::BATCH_LINE_LOOP, DrawBatcher::FMT_V);
	b.vertex ( far_p0);
	b.vertex ( far_p1);
	b.vertex ( far_p2);
	b.vertex ( far_p3);
	b.batchEnd();
	b.flush();
	
	b.batchBegin (&_line_material, placeable->getTransform(), DrawBatcher::BATCH_LINE_LOOP, DrawBatcher::FMT_V);
	b.vertex ( near_p0);
	b.vertex ( near_p1);
	b.vertex ( far_p1);
	b.vertex ( far_p0);
	b.batchEnd();
	b.flush();
	
	b.batchBegin (&_line_material, placeable->getTransform(), DrawBatcher::BATCH_LINE_LOOP, DrawBatcher::FMT_V);
	b.vertex ( near_p2);
	b.vertex ( near_p3);
	b.vertex ( far_p3);
	b.vertex ( far_p2);
	b.batchEnd();	
	b.flush();

    

}
bool LuxMaxCamera::exportCamera(float lensRadius, luxcore::Scene &scene)
{
	INode* camNode = GetCOREInterface9()->GetActiveViewExp().GetViewCamera();

	if (camNode == NULL)
	{
		MessageBox(0, L"Set active view to a target camera and render again.", L"Error!", MB_OK);
		return false;
	}
	else
	{
		CameraObject*   cameraPtr = (CameraObject *)camNode->EvalWorldState(GetCOREInterface()->GetTime()).obj;

		float v = 0.0f;
		float FOV = 0;
		float focaldistance = 0;
		Interval      ivalid = FOREVER;
		IParamBlock2 *pBlock = camNode->GetParamBlock(0);
		IParamBlock2* pblock2;

		if (v > 0.0f)
		{
			MessageBox(0, L"LuxCam modifier selected.", L"Error!", MB_OK);
			return false;
		}

		if (cameraPtr->ClassID() == MAX2016_PHYSICAL_CAMERA)
		{
			IPhysicalCamera* physicalCamera = dynamic_cast<IPhysicalCamera*>(camNode->EvalWorldState(GetCOREInterface()->GetTime()).obj);

			FOV = physicalCamera->GetFOV(GetCOREInterface()->GetTime(), FOREVER) * 180 / PI;
			focaldistance = physicalCamera->GetTDist(GetCOREInterface()->GetTime(), FOREVER);
		}
		else
		{
			FOV = cameraPtr->GetFOV(GetCOREInterface()->GetTime(), FOREVER) * 180 / PI;
			focaldistance = cameraPtr->GetTDist(GetCOREInterface()->GetTime(), FOREVER);
		}

		::Point3 camTrans = camNode->GetNodeTM(GetCOREInterface()->GetTime()).GetTrans();
		INode* NewCam = camNode;
		::Matrix3 targetPos;
		NewCam->GetTargetTM(GetCOREInterface()->GetTime(), targetPos);

		float aspectratio = GetCOREInterface11()->GetImageAspRatio();
		if (aspectratio < 1)
			FOV = 2.0f * ((180 / PI) *(atan(tan((PI / 180)*(FOV / 2.0f)) / aspectratio)));

		mprintf(L"Rendering with camera: : %s\n", camNode->GetName());
		scene.Parse(
			Property("scene.camera.lookat.orig")(camTrans.x, camTrans.y, camTrans.z) <<
			Property("scene.camera.lookat.target")(targetPos.GetTrans().x, targetPos.GetTrans().y, targetPos.GetTrans().z) <<
			Property("scene.camera.fieldofview")(FOV) <<
			Property("scene.camera.lensradius")(lensRadius) <<
			//Property("scene.camera.focaldistance")(cameraPtr->GetTDist(GetCOREInterface()->GetTime(), FOREVER)) <<
			Property("scene.camera.focaldistance")(focaldistance) <<
			Property("scene.camera.shutteropen")(0.0f) <<
			Property("scene.camera.shutterclose")(1.615f)
			);
		return true;
	}

	
}
void init( void )
{
	int i;
	//Fixes GlutMouseWarpPointer on Mac, thanks to John Huston and Chris Compton
#ifdef __APPLE__
	CGSetLocalEventsSuppressionInterval( 0.0 );
#endif

	glEnable(GL_DEPTH_TEST);

	// set up camera
	camera.setLockedXRot(true);
	camera.lockToPlane(-1.7);

	// load objects
	OBJParser::load_obj("models/subwaycar-done.obj", world);
	OBJParser::load_obj("models/stations.obj", world);
	OBJParser::load_obj("models/cardoor.obj", world);
	OBJParser::load_obj("models/cardoor.obj", world);
	OBJParser::load_obj("models/monkeyrobot-sit.obj", world);
	OBJParser::load_obj("models/monkeyrobot-stand.obj", world);
	OBJParser::load_obj("models/monkeyrobot-stand.obj", world);

	transformation = *new mat4();

	GLuint program = InitShader( "vshader.glsl", "fshader.glsl" );
	glUseProgram( program );

	for (i = 0; i < NUM_LIGHTS; i++) {
		init_lights(program);
		Light[i].bindLight(program);
	}
	 
	camMatLoc = glGetUniformLocation( program, "modelview");
	perspectiveMatLoc = glGetUniformLocation(program, "perspective");

	world.bufferActors();
	world.getActors()->at(0)->loadTexture("img/subwaycar.png");
	world.getActors()->at(1)->loadTexture("img/stations.png");
	world.getActors()->at(2)->loadTexture("img/cardoor.png");
	world.getActors()->at(3)->loadTexture("img/cardoor.png");
	world.getActors()->at(4)->loadTexture("img/monkeyrobot.png");
	world.getActors()->at(5)->loadTexture("img/monkeyrobot.png");
	world.getActors()->at(6)->loadTexture("img/monkeyrobot.png");

	world.getActors()->at(4)->setPosition(vec3(-0.75, 0.0, -0.9));
	world.getActors()->at(5)->setPosition(vec3(25.0, 9.2, 44.0));
	world.getActors()->at(5)->setScale(vec3(3.0));
	world.getActors()->at(5)->setRotation(vec3(0.0, -90.0, 0.0));
	world.getActors()->at(6)->setPosition(vec3(7.9, 1.1, 71.38));
	world.getActors()->at(6)->setRotation(vec3(0.0, 220.0, 0.0));
	world.getActors()->at(6)->setScale(vec3(0.7));

	world.getActors()->at(0)->addChild(world.getActors()->at(4));

	world.getActors()->at(0)->setRotation(vec3(0.0, 90.0, 0.0));
	world.getActors()->at(2)->setRotation(vec3(0.0, 90.0, 0.0));
	world.getActors()->at(3)->setRotation(vec3(0.0, 90.0, 0.0));
	world.getActors()->at(0)->setPosition(vec3(-0.3, 1.3, -5.5));

	train = new Train(world.getActors()->at(0), world.getActors()->at(2), world.getActors()->at(3), &camera, 0.0002, 0.1, 600, 1050, -1.3);

	world.getActors()->at(2)->setPosition(vec3(1.22, 1.3, 3.15));
	world.getActors()->at(3)->setPosition(vec3(1.22, 1.3, -14.2));

	world.getActors()->at(0)->translate(vec3(0.0, 0.0, 6.0));
			
	world.getActors()->at(1)->setScale(vec3(0.4));

	glEnable( GL_DEPTH_TEST );

	glClearColor( 0.0, 0.0, 0.0, 1.0 ); /* white background */
}
Beispiel #16
0
void CameraObject::TakeSnapshot()
{
    Q_ASSERT( IsDrivenByHardware() );

    CameraObject * newCam = CameraObject::New();
    newCam->SetName( FindNextSnapshotName() );
    newCam->SetHidden( true );
    newCam->SetIntrinsicParams( m_intrinsicParams );
    newCam->SetImageDistance( m_imageDistance );
    newCam->SetTransparencyCenter( m_transparencyCenter[0], m_transparencyCenter[1] );
    newCam->SetTransparencyRadius( m_transparencyRadius[0], m_transparencyRadius[1] );
    newCam->SetCalibrationMatrix( GetCalibrationMatrix() );
    newCam->AddFrame( GetVideoOutput(), GetUncalibratedTransform()->GetMatrix() );
    newCam->SetCanEditTransformManually( false );

    Application::GetInstance().GetSceneManager()->AddObject( newCam );
    Application::GetInstance().GetSceneManager()->SetCurrentObject( newCam );

    newCam->Delete();
}
bool AlembicCamera::Save(double time, bool bLastFrame)
{
    TimeValue ticks = GetTimeValueFromFrame(time);

    Object *obj = mMaxNode->EvalWorldState(ticks).obj;
    if (mNumSamples == 0) {
        bForever = CheckIfObjIsValidForever(obj, ticks);
    }
    else {
        bool bNewForever = CheckIfObjIsValidForever(obj, ticks);
        if (bForever && bNewForever != bForever) {
            ESS_LOG_INFO("bForever has changed");
        }
    }
    bForever = false;

    SaveMetaData(mMaxNode, this);

    // Set the xform sample
    Matrix3 wm = mMaxNode->GetObjTMAfterWSM(ticks);
    if (mJob) {
        Point3 worldMaxPoint = wm.GetTrans();
        Abc::V3f alembicWorldPoint = ConvertMaxPointToAlembicPoint(worldMaxPoint);
        mJob->GetArchiveBBox().extendBy(alembicWorldPoint);
    }

    // check if the camera is animated
    if (mNumSamples > 0) {
        if (bForever) {
            return true;
        }
    }

    // Return a pointer to a Camera given an INode or return false if the node
    // cannot be converted to a Camera

    CameraObject *cam = NULL;

    if (obj->CanConvertToType(Class_ID(SIMPLE_CAM_CLASS_ID, 0))) {
        cam = reinterpret_cast<CameraObject *>(
                  obj->ConvertToType(ticks, Class_ID(SIMPLE_CAM_CLASS_ID, 0)));
    }
    else if (obj->CanConvertToType(Class_ID(LOOKAT_CAM_CLASS_ID, 0))) {
        cam = reinterpret_cast<CameraObject *>(
                  obj->ConvertToType(ticks, Class_ID(LOOKAT_CAM_CLASS_ID, 0)));
    }
    else {
        return false;
    }

    CameraState cs;
    Interval valid = FOREVER;
    cam->EvalCameraState(ticks, valid, &cs);
    float tDist = cam->GetTDist(ticks);
    float ratio = GetCOREInterface()->GetRendImageAspect();
    float aperatureWidth =
        GetCOREInterface()->GetRendApertureWidth();  // this may differ from the
    // imported value
    // unfortunately
    float focalLength =
        (float)((aperatureWidth / 2.0) /
                tan(cs.fov / 2.0));  // alembic wants this one in millimeters
    aperatureWidth /= 10.0f;         // convert to centimeters

    IMultiPassCameraEffect *pCameraEffect = cam->GetIMultiPassCameraEffect();

    Interval interval = FOREVER;

    BOOL bUseTargetDistance = FALSE;
    const int TARGET_DISTANCE = 0;
    pCameraEffect->GetParamBlockByID(0)->GetValue(TARGET_DISTANCE, ticks,
            bUseTargetDistance, interval);
    float fFocalDepth = 0.0f;
    const int FOCAL_DEPTH = 1;
    pCameraEffect->GetParamBlockByID(0)->GetValue(FOCAL_DEPTH, ticks, fFocalDepth,
            interval);

    // store the camera data
    mCameraSample.setNearClippingPlane(cs.hither);
    mCameraSample.setFarClippingPlane(cs.yon);
    // mCameraSample.setLensSqueezeRatio(ratio);

    // should set to 1.0 according the article "Maya to Softimage: Camera
    // Interoperability"
    mCameraSample.setLensSqueezeRatio(1.0);

    mCameraSample.setFocalLength(focalLength);
    mCameraSample.setHorizontalAperture(aperatureWidth);
    mCameraSample.setVerticalAperture(aperatureWidth / ratio);
    if (bUseTargetDistance) {
        mCameraSample.setFocusDistance(tDist);
    }
    else {
        mCameraSample.setFocusDistance(fFocalDepth);
    }

    // save the samples
    mCameraSchema.set(mCameraSample);

    mNumSamples++;

    // Note that the CamObject should only be deleted if the pointer to it is not
    // equal to the object pointer that called ConvertToType()
    if (cam != NULL && obj != cam) {
        delete cam;
        cam = NULL;
        return false;
    }

    return true;
}
	// 工厂对象的创建方法
	ISceneObject *CameraObjectFactory::create(const String &name , IScene *scene , const NameValuePairList* params)
	{
		CameraObject *obj = new CameraObject(name);
		obj->create(scene , params);
		return obj;
	}
Beispiel #19
0
int main(int argc,char **argv)
{
    Options opt;
    if(!parse_args(&opt,argc,argv)){
        return 1;
    }
    char strk[256],strmu[256],strsigma[256],striso[256];
    int terminate=0;
    CameraObject camera;
    OrbitingViewer orbit;

	orbit.focusY=4.0;

    camera.z=10.0;

    FsOpenWindow(16,16,800,600,1);


    Cylinder cylinder;
	cylinder.setRadius(9.0);

    YsVec3 min(-10.0,0.0,-10.0);
    YsVec3 max(10.0,20.0,10.0);
    Box box;
    box.setMinMax(min,max);

    std::vector <YsVec3> iniPos;
    const double interval=0.9;
    CreateUniformInitialParticleLocation(iniPos,10,40,10,YsVec3(10.0,20.0,0.0),interval);

    std::vector <YsVec3> drip;
    CreateUniformInitialParticleLocation(drip,5,5,5,YsVec3(0.0,20.0,0.0),interval);

	ParticleSimulation sim;
    if(opt.infile){
        sim.read(opt.infile);
    }
    else{
	    //sim.init(iniPos);
    }
	sim.setObstacle(box);
	//sim.calculate_force();
	//sim.calculate_force();

	sim.mode=sim.MODE_NORMAL;



	glClearColor(0,0,0,0);

	YSBOOL pause=YSFALSE;
    YSBOOL cube=YSFALSE;
    YSBOOL savestl=YSFALSE;

    while(0==terminate)
    {
        FsPollDevice();

        int wid,hei;
        FsGetWindowSize(wid,hei);

        int key=FsInkey();
        switch(key)
        {
        case FSKEY_K:
            {
            printf("Enter k:\n");
            fscanf(stdin,"%lf",strk);
            double k=atof(strk);
            sim.setK(k);
            break;
            }
        case FSKEY_M:
            {
            printf("Enter mu:\n");
            fscanf(stdin,"%lf",strmu);
            double mu=atof(strmu);
            sim.setMu(mu);
            break;
            }
        case FSKEY_S:
            {
            printf("Enter Sigma:\n");
            fscanf(stdin,"%lf",strmu);
            double sigma=atof(strsigma);
            sim.setSigma(sigma);
            break;
            }
        case FSKEY_Q:
            if(cube){
                cube=YSFALSE;
            }
            else{
                cube=YSTRUE;
            }
            break;
        case FSKEY_I:
            {
                printf("Enter isolevel:\n");
                fscanf(stdin,"%lf",striso);
                double iso=atof(striso);
                sim.setIso(iso);
                break;
            }
        case FSKEY_L:
            if(savestl){
                savestl=YSFALSE;
            }
            else{
                savestl=YSTRUE;
            }
            break;

        case FSKEY_D:
            sim.placeParticles(drip);
            break;

		case FSKEY_P:
			YsFlip(pause);
			break;
        case FSKEY_ESC:
            terminate=1;
            break;
        }


		if(FSKEY_SPACE==key || YSTRUE!=pause)
		{
			sim.update();
		}

        if(0!=FsGetKeyState(FSKEY_LEFT))
        {
            orbit.h+=YsPi/180.0;
        }
        if(0!=FsGetKeyState(FSKEY_RIGHT))
        {
            orbit.h-=YsPi/180.0;
        }
        if(0!=FsGetKeyState(FSKEY_UP))
        {
            orbit.p+=YsPi/180.0;
        }
        if(0!=FsGetKeyState(FSKEY_DOWN))
        {
            orbit.p-=YsPi/180.0;
        }
        if(0!=FsGetKeyState(FSKEY_F) && orbit.dist>1.0)
        {
            orbit.dist/=1.05;
        }
        if(0!=FsGetKeyState(FSKEY_B) && orbit.dist<200.0)
        {
            orbit.dist*=1.05;
        }
        orbit.SetUpCamera(camera);

        glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

        glViewport(0,0,wid,hei);

        // Set up 3D drawing
        camera.SetUpCameraProjection();
        camera.SetUpCameraTransformation();

        glEnable(GL_DEPTH_TEST);
        glEnable(GL_POLYGON_OFFSET_FILL);
        glPolygonOffset(1,1);

        // 3D drawing from here
		glPushMatrix();
		glPointSize(3);
        if(cube){
           sim.drawMesh();
           if(savestl){
               sim.shl.SaveBinStl("test.stl");
               printf("stl saved\n");
               savestl=YSFALSE;
           }
        }
        else{
            sim.drawParticles();
        }
        //sim.drawColorFieldGrid();

        glPopMatrix();

        // Set up 2D drawing
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0,(float)wid-1,(float)hei-1,0,-1,1);

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glDisable(GL_DEPTH_TEST);

        FsSwapBuffers();
        FsSleep(25);
    }
    //sim.write(opt.outfile);

    return 0;
}
	//---------------------------------------------------------------
	void CameraExporter::exportCamera( ExportNode* exportNode )
	{
		if ( !exportNode->getIsInVisualScene() )
			return;
		
		String cameraId = getCameraId(*exportNode);

		INode* iNode = exportNode->getINode();

		CameraObject* camera = (CameraObject*)iNode->GetObjectRef();

		INode* targetNode =  ( camera->ClassID().PartA() == LOOKAT_CAM_CLASS_ID) ? iNode->GetTarget() : 0;

		if ( camera )
		{
			if (  mDocumentExporter->isExportedObject(ObjectIdentifier(camera)) )
				return;

			mDocumentExporter->insertExportedObject(ObjectIdentifier(camera), exportNode);


			// Retrieve the camera parameters block
			IParamBlock* parameters = (IParamBlock*) camera->GetReference(MaxCamera::PBLOCK_REF);

			COLLADASW::BaseOptic * optics = 0; 
			if ( camera->IsOrtho() )
			{
				optics = new COLLADASW::OrthographicOptic(COLLADASW::LibraryCameras::mSW);

				// Calculate the target distance for FOV calculations
				float targetDistance;
				if ( targetNode )
				{
					Point3 targetTrans = targetNode->GetNodeTM(mDocumentExporter->getOptions().getAnimationStart()).GetTrans();
					Point3 cameraTrans = iNode->GetNodeTM(mDocumentExporter->getOptions().getAnimationStart()).GetTrans();
					targetDistance = (targetTrans - cameraTrans).Length();
				}
				else
				{
					targetDistance = camera->GetTDist(mDocumentExporter->getOptions().getAnimationStart());
				}
				ConversionInverseOrthoFOVFunctor conversionInverseOrthoFOVFunctor(targetDistance);

				if ( AnimationExporter::isAnimated(parameters, MaxCamera::FOV) )
				{
					optics->setXMag(conversionInverseOrthoFOVFunctor(parameters->GetFloat(MaxCamera::FOV)), XMAG_SID);
					mAnimationExporter->addAnimatedParameter(parameters, MaxCamera::FOV, cameraId, XMAG_SID, 0, true, &conversionInverseOrthoFOVFunctor);
				}
				else
				{
					optics->setXMag(conversionInverseOrthoFOVFunctor(parameters->GetFloat(MaxCamera::FOV)));	
				}
			}
			else
			{
				optics = new COLLADASW::PerspectiveOptic(COLLADASW::LibraryCameras::mSW);
				if ( AnimationExporter::isAnimated(parameters, MaxCamera::FOV) )
				{
					optics->setXFov(COLLADASW::MathUtils::radToDegF(parameters->GetFloat(MaxCamera::FOV)), XFOV_SID);
					mAnimationExporter->addAnimatedParameter(parameters, MaxCamera::FOV, cameraId, XFOV_SID, 0, true, &ConversionFunctors::radToDeg);
				}
				else
				{
					optics->setXFov(COLLADASW::MathUtils::radToDegF(parameters->GetFloat(MaxCamera::FOV)));	
				}
			}

			bool hasAnimatedZNear = mAnimationExporter->addAnimatedParameter(parameters, MaxCamera::NEAR_CLIP, cameraId, optics->getZNearDefaultSid(), 0);
			optics->setZNear(parameters->GetFloat(MaxCamera::NEAR_CLIP), hasAnimatedZNear);

			bool hasAnimatedZFar = mAnimationExporter->addAnimatedParameter(parameters, MaxCamera::FAR_CLIP, cameraId, optics->getZFarDefaultSid(), 0);
			optics->setZFar(parameters->GetFloat(MaxCamera::FAR_CLIP), hasAnimatedZFar);


#ifdef UNICODE
			String exportNodeName = COLLADABU::StringUtils::wideString2utf8String(exportNode->getINode()->GetName());
			COLLADASW::Camera colladaCamera(COLLADASW::LibraryCameras::mSW, optics, cameraId, COLLADASW::Utils::checkNCName(exportNodeName));
#else
			COLLADASW::Camera colladaCamera(COLLADASW::LibraryCameras::mSW, optics, cameraId, COLLADASW::Utils::checkNCName(exportNode->getINode()->GetName()));
#endif
			setExtraTechnique(&colladaCamera);


			// Retrieve the camera target
			if ( targetNode )
			{
				ExportNode* targetExportNode = mExportSceneGraph->getExportNode(targetNode);
				addExtraParameter(EXTRA_PARAMETER_TARGET, "#" + targetExportNode->getId());
			}

			if (camera->GetMultiPassEffectEnabled(0, FOREVER))
			{
				IMultiPassCameraEffect *multiPassCameraEffect = camera->GetIMultiPassCameraEffect();
				if (multiPassCameraEffect)
				{
					Class_ID id = multiPassCameraEffect->ClassID();

					// the camera could have both effects, but not in Max
					if (id == FMULTI_PASS_MOTION_BLUR_CLASS_ID)
					{
						IParamBlock2 *parameters = multiPassCameraEffect->GetParamBlock(0);
						if (parameters )
						{
							addParamBlockAnimatedExtraParameters(MOTION_BLUR_ELEMENT, MOTION_BLUR_PARAMETERS, MOTION_BLUR_PARAMETER_COUNT, parameters, cameraId);
						}
					}
					else if (id == FMULTI_PASS_DOF_CLASS_ID)
					{
						IParamBlock2 *parameters = multiPassCameraEffect->GetParamBlock(0);
						if (parameters )
						{
							addParamBlockAnimatedExtraParameters(DEPTH_OF_FIELD_ELEMENT, DEPTH_OF_FIELD_PARAMETERS, DEPTH_OF_FIELD_PARAMETER_COUNT, parameters, cameraId);
							addExtraParameter(TARGETDISTANCE_PARAMETER, camera->GetTDist(0));
						}
					}
				}
			}
			addCamera(colladaCamera);
		
			delete optics;
		}

	}
void EntryExitCounter::process(FrameList &frames)
{
    if(frames.hasPrevious())
    {
        for(unsigned int n = 0; n < frames.getCurrent().getCameras().size(); n++)
        {
            if(frames.hasDoorMask())
            {
                CameraObject  *cameraCurr = &frames.getCurrent().getCameras()[n];
                CameraObject  *cameraPrev = &frames.getPrevious().getCameras()[n];
                cameraCurr->setEntered(cameraPrev->getEntered()); //Get data from last frame
                cameraCurr->setExited(cameraPrev->getExited());   //Get data from last frame
                cv::Mat doorMask = frames.getDoorMask(); //Get the door mask

                for(std::vector<Object>::iterator object = cameraCurr->getTransitionaryObjects().begin(); object != cameraCurr->getTransitionaryObjects().end(); object++)
                {
                    cv::Point2d pos = object->exitPoint;
                    if(isInsidePolygon(doorMask, pos) && object->hasPassedMasksOne && object->hasPassedMasksTwo && object->hasPassedMasksThree)
                    {
                        cameraCurr->setExited(cameraCurr->getExited()+1);
                    }
                }
                cameraCurr->getTransitionaryObjects().clear();

                for(std::vector<Object>::iterator object = cameraCurr->getObjects().begin(); object != cameraCurr->getObjects().end(); object++)
                {
                    cv::Point2d entryPosition = object->entryPoint;
                    if(isInsidePolygon(doorMask, entryPosition) && object->hasPassedMasksOne && object->hasPassedMasksTwo && object->hasPassedMasksThree && !object->hasAlreadyEntered)
                    {
                        cameraCurr->setEntered(cameraCurr->getEntered()+1);
                        object->hasAlreadyEntered = true;
                    }
                }

                //Set population for a specific RoomID corresponding to the current camera.
                std::string currentRoomID = frames.getCurrent().getCameras()[n].getRoomID();
                int exitedThisFrame = cameraCurr->getExited()-cameraPrev->getExited();
                int enteredThisFrame =  cameraCurr->getEntered()-cameraPrev->getEntered();
                int prevPopulation = frames.getPrevious().getPopulationInRoomID(currentRoomID);
                frames.getCurrent().setPopulationInRoomID(prevPopulation+enteredThisFrame-exitedThisFrame, currentRoomID);


                //------------------ Debug writes nr of people that enters/exits into debugImage ------------------//
                if(!cameraCurr->hasImage("debugImage"))
                    cameraCurr->addImage("debugImage", cameraCurr->getImage("rawImage").clone());
                cv::Mat debugImage = cameraCurr->getImage("debugImage");
                std::string text = "";
                std::string text2 = "";
                int fontFace = cv::FONT_HERSHEY_PLAIN;
                double fontScale = 1;
                int thickness = 1;
                cv::Point2d pos1(10,20);
                cv::Point2d pos2(10,40);
                text = "Entered: " + std::to_string(cameraCurr->getEntered());
                putText(debugImage, text, pos1, fontFace, fontScale, cv::Scalar(0,255,0), thickness, 8);
                text2 = "Exited: " + std::to_string(cameraCurr->getExited());
                putText(debugImage, text2, pos2, fontFace, fontScale, cv::Scalar(0,255,0), thickness, 8);
                //------------------------------------------------------------------------------------------------//
            }
        }

        /* Sum all room populations into one. Since roomId's are always different from each other,
           totalPopulation is really a debug variable that now is just printed. Works only
           for one camera at the moment.*/
        totalPopulation = 0;
        for(unsigned int n = 0; n < frames.getCurrent().getCameras().size(); n++) {
            std::string currentRoomID = frames.getCurrent().getCameras()[n].getRoomID();
            totalPopulation = totalPopulation + frames.getCurrent().getPopulationInRoomID(currentRoomID);
        }
        //--------------------------------- Debug, writes population to debugImage --------------------------------//
        std::vector<CameraObject> cameras = frames.getCurrent().getCameras();
        if(cameras.size() > 0){
            //CameraObject  *cameraCurr = &frames.getCurrent().getCameras()[0];
            CameraObject  *cameraCurr = &cameras[0];
            std::string text = "";
            int fontFace = cv::FONT_HERSHEY_PLAIN;
            double fontScale = 1;
            text = "Is inside: " + std::to_string(totalPopulation);
            cv::Point2d pos3(10,60);
            cv::Mat debugImage = cameraCurr->getImage("debugImage");
            putText(debugImage, text, pos3, fontFace, fontScale, cv::Scalar(0,255,0), 1, 8);
        }
        //--------------------------------------------------------------------------------------------------------//
    }
}
Beispiel #22
0
void SkeletonExporter::export_camera(INode *node)
{
  Control *c;
  int size_key;
  float camera_znear, camera_zfar;
  CameraState cs;
//  Interval valid = FOREVER;
  ObjectState os;
  CameraObject *cam;
  GenCamera *gencam;
  float roll0;
  Matrix3 mat;
  Point3 row;

  os = node->EvalWorldState(0);
  cam = (CameraObject *)os.obj;
  gencam = (GenCamera *)os.obj;
  if (gencam->Type() != TARGETED_CAMERA)
  {
	 fprintf(fTXT, "Only targeted camera are supported!\n\n");
	 return;
  }

  fprintf(fTXT, "Targeted camera found\n");
  write_chunk_header(fA3D, TARGETED_CAMERA_ID, node->GetName(), 40);
  if (makeRAY) write_chunk_header(fRAY, TARGETED_CAMERA_ID, node->GetName(), 40);

  INode* target = node->GetTarget();
  fprintf(fTXT, "Name : %s\n", node->GetName());
  cam->EvalCameraState(0, FOREVER, &cs);

  // ------------------  salviamo znear e zfar  ----------------------
  camera_znear=2;
  camera_zfar=2000;
  if (cs.manualClip)
  {
	camera_znear=cs.hither;
	camera_zfar=cs.yon;
  }
  fprintf(fTXT, "Znear = %f \n", camera_znear);
  fwrite(&camera_znear, sizeof(float), 1, fA3D);
  if (makeRAY) fwrite(&camera_znear, sizeof(float), 1, fRAY);
  fprintf(fTXT, "Zfar = %f \n", camera_zfar);
  fwrite(&camera_zfar, sizeof(float), 1, fA3D);
  if (makeRAY) fwrite(&camera_zfar, sizeof(float), 1, fRAY);

  // -----------------  salviamo l'angolo di FOV  --------------------
  fprintf(fTXT, "FOV (rad) = %f \n", cs.fov);
  fwrite(&cs.fov, sizeof(float), 1, fA3D);
  if (makeRAY) fwrite(&cs.fov, sizeof(float), 1, fRAY);

  // ------------------  salviamo l'angolo di roll  ------------------
  c=node->GetTMController()->GetRollController();
  c->GetValue(0, &roll0, FOREVER);	
  fprintf(fTXT, "Roll (rad) = %f \n", roll0);
  fwrite(&roll0, sizeof(float), 1, fA3D);
  if (makeRAY) fwrite(&roll0, sizeof(float), 1, fRAY);

  // salviamo la posizione nel mondo
  mat = node->GetNodeTM(0);
  row = mat.GetRow(3);
  fprintf(fTXT, "Camera world position : x=%f, y=%f, z=%f\n", row.x, row.y, row.z);
  write_point3(&row, fA3D);
  if (makeRAY) write_point3(&row, fRAY);

  // ---------  salviamo la posizione del target nel mondo  ----------
  if (target)
  {
    mat = target->GetNodeTM(0);
    row = mat.GetRow(3);
    fprintf(fTXT, "Target world position : x=%f, y=%f, z=%f\n", row.x, row.y, row.z);
    write_point3(&row, fA3D);
    if (makeRAY) write_point3(&row, fRAY);
  }

  
  // esportiamo l'animazione della posizione della camera
  // se ci sono un numero di key > 0
  c=node->GetTMController()->GetPositionController();
  if ((c) && (c->NumKeys()>0))
  {
	 if (IsTCBControl(c)) size_key=36;
	 else
	 if (IsBezierControl(c)) size_key=40;
	 else size_key=16;
	 fprintf(fTXT, "Camera position track present.");
     write_chunk_header(fA3D, POSITION_TRACK_ID,
	                    node->GetName(), 1+2+4+c->NumKeys()*size_key);
     export_point3_track(c, 1, fA3D);
     if (makeRAY) write_chunk_header(fRAY, POSITION_TRACK_ID,
	                    node->GetName(), 1+2+4+c->NumKeys()*size_key);
     if (makeRAY) export_point3_track(c, 1, fRAY);
  }

  // -----  esportiamo l'animazione della posizione del target  ------
  if (target)
  {
    c=target->GetTMController()->GetPositionController();
    if ((c) && (c->NumKeys()>0))
	{
	  if (IsTCBControl(c)) size_key=36;
	  else
	  if (IsBezierControl(c)) size_key=40;
	  else size_key=16;
	  fprintf(fTXT, "Target position track present.");
	  write_chunk_header(fA3D, CAMERA_TARGET_TRACK_ID,
		                 node->GetName(), 1+2+4+c->NumKeys()*size_key);
	  export_point3_track(c, 1, fA3D);

	  if (makeRAY) write_chunk_header(fRAY, CAMERA_TARGET_TRACK_ID,
		                 node->GetName(), 1+2+4+c->NumKeys()*size_key);
	  if (makeRAY) export_point3_track(c, 1, fRAY);
	}
  }

  // ---------------  esportiamo le tracce di FOV  -------------------
  c=gencam->GetFOVControl();
  if ((c) && (c->NumKeys()>0))
  {
	 if (IsTCBControl(c)) size_key=28;
	 else
	 if (IsBezierControl(c)) size_key=16;
	 else size_key=8;
	 fprintf(fTXT, "Camera FOV track present.");
     write_chunk_header(fA3D, CAMERA_FOV_TRACK_ID,
	                    node->GetName(), 1+2+4+c->NumKeys()*size_key);
     export_float_track(c, 1, fA3D);  // radianti
     if (makeRAY) write_chunk_header(fRAY, CAMERA_FOV_TRACK_ID,
	                    node->GetName(), 1+2+4+c->NumKeys()*size_key);
     if (makeRAY) export_float_track(c, 1, fRAY);  // radianti
  }


  // ---------------  esportiamo le tracce di roll  ------------------
  c=node->GetTMController()->GetRollController();
  if ((c) && (c->NumKeys()>0))
  {
	 if (IsTCBControl(c)) size_key=28;
	 else
	 if (IsBezierControl(c)) size_key=16;
	 else size_key=8;
	 fprintf(fTXT, "Camera roll track present.");
     write_chunk_header(fA3D, CAMERA_ROLL_TRACK_ID,
	                    node->GetName(), 1+2+4+c->NumKeys()*size_key);
     export_float_track(c, 1, fA3D); // radianti

     if (makeRAY) write_chunk_header(fRAY, CAMERA_ROLL_TRACK_ID,
	                    node->GetName(), 1+2+4+c->NumKeys()*size_key);
     if (makeRAY) export_float_track(c, 1, fRAY); // radianti
  }
  fprintf(fTXT, "\n\n--------------------------------------------------\n");
}