Skip to main content
GameDev.net gamedev.net
🔒 Locked

3ds Max Plugin,How to get the lens and fov of target-camera with animation?

Started by akira32 Mar 27, 2009 at 1:37 AM 4 replies 2.3k views
Original Post
akira32
akira32
How to get the lens and fov of target-camera with animation? (I use the source code of KW X-port with IGame) And export both them to the scale channel of certain key frame of target-camera? append(foo, (DWORD)1); // scale animation append(foo, (DWORD)scaleAnim.size()); append(foo, scaleAnim); CHECK( anim->AddDataObject(TID_D3DRMAnimationKey, "scale", 0, foo.size(), &foo[0], &temp) );
akira32 編程之家 Yahoohttp://tw.myblog.yahoo.com/akira32-akira32
RobTheBloke
RobTheBloke
Your best bet is to not use IGame (it's fecking crap), and IIRC in this case it won't help you in the slightest.

Getting the fov is pretty trivial. Just eval the camera state using CameraObject::EvalCameraState. And that's it.

You might want to query the camera object's sub animations if you want to get the animated F-Curves, though if you only want sampled keys then just eval the camera along the timeline range.
akira32
akira32
I have a special requirement for exporting 3dsmax camera path to a xfile.
Asciiexp is a very good example. KW X-port is a 3da max plugin and it can export camera path with animation. If I do not use KW X-port, then I will make more effort in XFile format. Does somebody give me some suggestes? Or I should base on Asciiexp to desgin my file format?

akira32 編程之家 Yahoohttp://tw.myblog.yahoo.com/akira32-akira32
RobTheBloke
RobTheBloke
Quote:
Original post by akira32Or I should base on Asciiexp to desgin my file format?


In an ideal world you would.

Quote:
Original post by akira32
I have a special requirement for exporting 3dsmax camera path to a xfile.


That should already be there surely? It's just a TM afterall, and i assume that KW does basic transforms? (If not, it's totally crap).

Quote:
Original post by akira32
KW X-port is a 3da max plugin and it can export camera path with animation. If I do not use KW X-port, then I will make more effort in XFile format. Does somebody give me some suggestes?


Modify the export code.
akira32
akira32
I had modified the AsciiExp source code for exporting camera FOV.

void AsciiExp::DumpCameraFOVSample(INode* node, int indentLevel){	TSTR indent = GetIndent(indentLevel);	fprintf(pStream,"%s\t\t%s {\n", indent.data(), "*CONTROL_CAMERA_FOV_TRACK");	TimeValue start = ip->GetAnimRange().Start();	TimeValue end = ip->GetAnimRange().End();	TimeValue t;	int delta = GetTicksPerFrame() * GetKeyFrameStep();	CameraState cs;	Interval valid = FOREVER;	for (t=start; t<=end; t+=delta) {		ObjectState os = node->EvalWorldState(t);		CameraObject *cam = (CameraObject *)os.obj;		cam->EvalCameraState(t,valid,&cs);		ExportCameraSettings(&cs, cam, t, indentLevel+2);


I want to export camera path based on KW X_port and export the FOV variation into Scaling keys of Animation. The KW X-port can export camera and its target's key frame.

void IGameExporter::ExportAnimations(ID3DXFileSaveObject * save)......    for (ptr = animated_.begin(), end = animated_.end(); ptr != end; ++ptr) {      IGameNode * node = *ptr;......


I had found a member function GetMaxNode() of IGameNode. Myabe I will solved this problem soon.
akira32 編程之家 Yahoohttp://tw.myblog.yahoo.com/akira32-akira32
akira32
akira32
I had solved the problem export camera fov into scaling keys.

void IGameExporter::ExportAnimations(ID3DXFileSaveObject * save){.......    for (ptr = animated_.begin(), end = animated_.end(); ptr != end; ++ptr) {      		IGameNode * node = *ptr;		ObjectState object_state = node->GetMaxNode()->EvalWorldState(0); 				bool bCameraobject=false;		if (object_state.obj) 		{			if (object_state.obj->SuperClassID()==CAMERA_CLASS_ID)			{				bCameraobject=true;			}		}......      for (int time = 0; time < ar.length; ++time) {......		if (bCameraobject)		{			Interval valid = FOREVER;			CameraState cs;			CameraObject *cam = (CameraObject *)object_state.obj;			cam->EvalCameraState(time*outTime,valid,&cs);			s.x=cs.fov;			s.y=0.0f;			s.z=0.0f;		}		if (!almostEqual(s, os) || time == 0) {			if (compScale > 0) {				scaleAnim.push_back(std::pair<std::pair<DWORD, DWORD>, Point3>(					std::pair<DWORD, DWORD>((time-1)*outTime, 3), os));			}			scaleAnim.push_back(std::pair<std::pair<DWORD, DWORD>, Point3>(				std::pair<DWORD, DWORD>(time*outTime, 3), s));			os = s;			compScale = 0;		}		else {			++compScale;		}
akira32 編程之家 Yahoohttp://tw.myblog.yahoo.com/akira32-akira32

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.