我要发帖 回复

管理员

735

主题

2万

积分

30

专家分

忠于职守杰出贡献鼓励

兴趣点(最多三项):

建模技术

私信
发表时间 : 2007-12-24 11:05:53 | 浏览 : 9298    评论 : 20
Procedure for Creating a Standalone Player With
Virtools Dev 3.5/4 & VC++ 7 (.NET 2003)   同样适合于vt4.0
This document will illustrate the procedure for creating a standalone exe player for Virtools CMO and VMO files.
This document will assume “$VT” as the installation directory of the Virtools Dev 3.5 or Virtools Dev 4.0.
? Standalone player “Linked DLL compilation”:
This player relies on external files to launch the Virtools composition or VMO in a windows executable application, it’s a single lightweight executable which calls other external resources (DLL) files in order to correctly play the Virtools file.
Procedure:
1) Go to $VT \Sdk\Samples\Runtime\Standalone Player\
2) Open CustomPlayer.sln using Visual Studio 2003
3) Build the solution.
4) Initial build should commence with no problems as this is the most basic compilation of the player.
5) Refer to $VT \Sdk\Temp\Win32.
6) You will see the project built into that directory, to change the output directory in which VC++ places the generated files do the following:
? Using the IDE, choose the solution explorer and right click on the CustomPlayer to view properties.
? In the Configuration Properties>>General pane, change the output directory & intermediate directory values though they are inconsequential.
? In the Linker>>General pane, change the Output File value to wherever you want the program to create the final EXE file.
? If you build the solution as it is, it will probably work fine on your PC but will generate an MFC related error on other stations, because the current configuration is set to DEBUG, to change that configuration, go the Properties of the solution and click on Configuration Manager, change the mode to RELEASE, hit ok and build solution.
? The exe File should be generated in the directory you specified -$VT \Sdk\Temp\Win32 by default-.
7) Browse the directory and test the application using the following procedure, assume you are at
$VT \Sdk\Temp\Win32\CustomPlayer\Release\:
? Place a test –operational- CMO file at the same level of the exe generated file –CustomPlayer.exe by default- name the file TEST123.CMO.
? Copy the following directories to the
$VT \Sdk\Temp\Win32\CustomPlayer\Release\ directory:
1) $VT \BuildingBlocks\
2) $VT \Managers\
3) $VT \Plugins\
4) $VT \RenderEngines\
Copy the following files to the
$VT \Sdk\Temp\Win32\CustomPlayer\Release\ directory:
1) $VT \CK2.dll\
2) $VT \CKZlib.dll\
3) $VT \VSL.dll\
4) $VT \VSLRT.dll\
5) $VT \VxMath.dll\
? Copy all of the following directory contents to the corresponding directories you copied in
$VT \Sdk\Temp\Win32\CustomPlayer\Release\
1) $VT \Sdk\Redist\BuildingBlocks\
2) $VT \Sdk\Redist\Manager
? Copy the following file to the
$VT \Sdk\Temp\Win32\CustomPlayer\Release\ Directory:
$VT \Sdk\Redist\VSLRT.dll
Note that not all of the previous files and directories are required,
you can minimize the size of the final output by selecting specific DLL’s-
those DLL’s that are required by your composition only-
This is a great and a very important way of doing things.
So when you are deploying an application make sure that you copy only the files you need.
8) Now the player should be accessible, to play the Virtools file do the following:
? Start >> Run.
? Type cmd and press enter.
? Issue the commands:
cd $VT \Sdk\Temp\Win32\CustomPlayer\Release\
CustomPlayer –file=TEST123.CMO –title=test –width=800 –height=900
? The player should play the file now, if not, backtrack and make sure you have all the steps right.
? Take a look at the readme.txt for further clarification on the parameters passed to the player.
The previous procedure compiles a basic player of the Virtools player. The following is what might be considered the pros and cons of the compilation:
? Pros:
1. Ease of deployment.
2. Ease of file transition, meaning it is suitable for playing a number of files instead of hard coding the filename and path, so if you create a batch file instead of issuing the run command at every turn, you can create a number of batch files for a number of Virtools files with different parameters.
3. Not all of the Virtools DLL’s are required, meaning you don’t have to copy the entire contents of the BuildingBlocks, Managers, Plugins and RenderEngines, just copy the ones you need and redistribute your application accordingly.
? Cons:
1. The Virtools DLL’s are visible and should be present when distributing the application, this can be considered a poor approach for deploying projects with Virtools, at least to me, having everything bundled in single packages sounds a lot more practical, plus you minimize the margin of error, when a user accidentally deletes a required DLL for example.
2. A deployed version might be tampered with, a batch file might be reconfigured to play a file with a parameter set other than the original one, and I strongly recommend that this approach be used to deploy Virtools applications for debugging purposes only regardless or whether you chose the DEBUG or RELEASE configuration types.
? Static Stand Alone Player “Single Bundled EXE File”
After doing the previous compilation, it’s a good idea to get a single bundled EXE file, to do that, follow the following steps:
1. Go to Solution Explorer, Right click, choose Properties, in the dialog window click on Configuration Manager and choose “ReleaseStatic”.
2. Make sure you have the DirectX SDK installed – Only the October 2004 release will work, apparently, Microsoft newer releases of the SDK is not backward compatible with previous release, surprise surprise! - When you install the SDK, it’s a good idea to use a default installation; otherwise, you might have to change the configuration of the linked DLL’s from within the Solution Explorer Properties.
3. You can skip this step- but I had to do it on my machine, apparently there were some missing DLL files for DirectX- open the file CustomPlayerStaticLibs.h, scroll down until you see the line:
// virtools plugins
Comment the following two lines:
#pragma comment(lib,"3dsLoaderStatic")
#pragma comment(lib,"XLoaderStatic")
4. Build the solution, it might take a while, and unless configured in a different way, the output file will be “StaticPlayer.exe”, so when you try to run using the same steps as the previous compilation, remember to change the filename.
The previous procedure compiles a single bundled EXE file for the Virtools player. The following is what might be considered the pros and cons of the compilation:
? Pros:
1. Ease of deployment.
2. Securing the Virtools DLL files.
? Cons:
1. A deployed version might be tampered with; a batch file might be reconfigured to play a file with a parameter set other than the original one.
2. The CMO/VMO file is still visible to the user.
? Managing the Player, Modifying parameter passing:
To solve the problem of parameter passing, you can modify the code itself to allow for playing a Virtools file automatically without the need for parameters, this method is of course the preferred method of deployment regardless if you are compiling a static or a standalone player.
To make your player play the file automatically, do the following steps:
1. Open the file CustomPlayerApp.cpp.
2. in the _ReadConfig Method , replace all the contents of the method with the following lines :
-------------------------------------------------------------
const char* cmdLine = "-title test123 -width 800 -height 600";
return _ReadCommandLine(cmdLine,oFilename);
-------------------------------------------------------------
3. in the InitInstance method, replace the line :
-------------------------------------------------------------
XString filename;
-------------------------------------------------------------
With:
-------------------------------------------------------------
XString filename="TEST123.cmo";
-------------------------------------------------------------
4. Also in the InitInstance method, comment the following block of code:
-------------------------------------------------------------
if(!_ReadConfig(filename,fileBuffer,fileSize)) {
MessageBox(NULL,CANNOT_READ_CONFIG,
INIT_ERROR,MB_OK|MB_ICONERROR)
return FALSE;
}
-------------------------------------------------------------
And add the following line instead:
-------------------------------------------------------------
_ReadConfig(filename,fileBuffer,fileSize);
-------------------------------------------------------------
That should do it! Now you have a player that plays the file automatically without parameter passing, note that if you need to modify the parameters, you should do it in the first line mentioned in step 2, and you should it do it every time you need to change the parameters, since this compilation doesn’t read the command line parameters anymore even if you pass them, also the file name mentioned in step 3 in the second line should be changed according to the filename you are using.
? Managing the Player, Embedding the Virtools File inside the player:
If you ever saw the HDRI demo produced by Virtools and you wanted to do something like it, then this section is for you, follow the following steps to the letter and you should be fine:
1. Open the CustomPlayerApp.cpp file.
2. in the init method , replace this block of code:
-------------------------------------------------------------
XString filename;
const char* fileBuffer = 0;
XDWORD fileSize = 0;
if(!_ReadConfig(filename,fileBuffer,fileSize)) {
MessageBox(NULL,CANNOT_READ_CONFIG,
INIT_ERROR,MB_OK|MB_ICONERROR);
return FALSE;
}
-------------------------------------------------------------
With this one
-------------------------------------------------------------
CString Type="VIRTOOLS";
HRSRC rest=FindResource(NULL,
MAKEINTRESOURCE(IDR_VIRTOOLS1),Type);
HGLOBAL gl=LoadResource (NULL,rest);
LPVOID lp=LockResource(gl);
fileBuffer=(char*)lp;
fileSize = SizeofResource (NULL,rest);
_ReadConfig(filename,fileBuffer,fileSize);
-------------------------------------------------------------
3. Go to Solution Explorer, right click on the Resource Files, choose
Add >> Add Resource, click on Import, browse to your CMO or VMO file, and click Open, A dialog will appear requesting the Resource Type, Type VIRTOOLS and click ok.
4. Rebuild solution.
Now you have a player with an embedded VMO/CMO file, when you want to use this method for other files, make sure you delete the VIRTOOLS Resource from the Resource View and re-import the file, because this method stores the binary data of the VMO or the CMO in the solution, cached files will remain, also, this method seems to exhibit problems with large files with sizes that exceed 15 MB.
READ ME ….. A MUST READ
All of the procedures described in this document are actually the work of myself and a collective of relentless Virtools developers, of which I thank Chahé Adourian & Senne de Jong & bf_long specifically, your contribution is actually an enormous one.
Please read the following notes carefully.
1. The distribution of Virtools EXE applications is subject to specific license agreement supplied from Virtools directly, if you are not sure whether you have the said license or not, DO NOT attempt to distribute any applications made with the help of this tutorial, check your license status, and act accordingly.
2. This documentation is meant to be a clarification document only, if it is in violation of the rules and regulations of Virtools, you should dispose of it immediately, further, at the time of writing, I submit that I have not heard or read or been informed of any constraint regarding distributing this tutorial, not from Virtools or any other party affiliated or not with Virtools.
3. The documentation provided in this document has been authored and edited by me, so if there are any typing, logical or procedural errors, they are mine to bear, if you have found any, I would be most appreciative if you notify me via email or by posting new threads in the forum.
4. All of the procedures discussed throughout this document here are the work of myself and a number of developers, and although the original code itself has been published by Virtools, neither I nor any of the developers offer any guarantee as to the performance of these procedures, true the code has changed, but until we get a valid feedback from lots of people who have used this tutorial, we cannot offer any guarantee.
5. Note that all of the processes of embedding the CMO/VMO in the application is the work of an individual based on trial and error, it is not tested for enterprise application deployment, and it is not officially endorsed by Virtools, further, neither I nor the original developer -bf_long & Senne de Jong- offer any guarantee as to the performance, so if anything goes wrong, I’m afraid your on your own, I myself will continue modifying and enhancing –If I can- the concept that Senne & bf_long has so graciously contributed, if however you the reader should find a better way of doing things, We will be most appreciative if you could share it.

最近VR访客

liushaokai 评论于2007-12-24 15:17:46

谢谢楼主

可是一点都看不懂~
daiyulianghg 评论于2007-12-29 22:16:27
Thanks
chenxiaoqiu 评论于2008-1-14 15:35:25
在别的机子上运行,还是会弹出注册框的啊!
gjswhx 评论于2008-4-29 17:47:52
谢谢你!
liminghao 评论于2008-5-23 11:12:44
好帖子,可惜是英文的
hfyan_cumt 评论于2008-8-3 11:47:27
.net 2005适用吗?
hfyan_cumt 评论于2008-8-3 23:46:14
生成了CustomPlayer.exe,但运行时出现Unable to load composition from file,提示,请大侠指教
wgfvirtools 评论于2008-9-28 20:46:13
看不懂啊
cg521ming1 评论于2008-10-20 14:14:28
楼主自己也看不懂吧,贴上来就完事儿了。
vr8 评论于2008-10-31 15:14:39
LZ你这个估计没几个人能弄出来吧,没有别的意思!

本人免费提供Virtools各版本的打包服务,整个项目打包成exe可执行文件,完全看不出是VT做的!安全高效绿色无毒!窗口大小、标题栏和图标根据客户需要进行修改!
如有需要的邮件联系
vr8vr8@163.com
playwww 评论于2008-12-26 16:45:37

回复 7楼 的帖子

估计路径问题
相对路径不行就改成绝对路径

如:  ..\CustomPlayer -file Vtest2.VMO -title test -width 800 -height 600

或 ..\CustomPlayer -file d:\Vtest2.VMO -title test -width 800 -height 600
xingjiantian 评论于2009-4-11 22:19:42
我有这个可直接打包的源文件,不用编程的。
大家要的话,可找我。
是人家国外做好的可执行程序,只需双击,再选择你想打包的文件,就可以自动生成了。
phevos 评论于2009-4-18 16:13:57
Unique_hfw 评论于2009-4-21 12:08:12
原帖由 xingjiantian 于 2009-4-11 10:19 PM 发表
我有这个可直接打包的源文件,不用编程的。
大家要的话,可找我。
是人家国外做好的可执行程序,只需双击,再选择你想打包的文件,就可以自动生成了。

可以发给我吗?
我现在很需要那个东西
asdfgame 评论于2009-5-22 10:30:19
我也要 liangyic@tom.com
liuqing131-520 评论于2009-6-3 11:55:58

回复 12楼 的帖子

可以给我个吗  我想要
liuqing131-520@163.com
wdg 评论于2012-3-25 01:18:17
神仙能看懂吧
微汐 评论于2012-4-12 16:04:25
我也要942011308@qq.com谢谢。
shenyoufu 评论于2012-6-5 15:42:55
xingjiantian 发表于 2009-4-11 10:19 PM
我有这个可直接打包的源文件,不用编程的。
大家要的话,可找我。
是人家国外做好的可执行程序,只需双击, ...

谢谢,我想要1

手机版|VR开发网 统计 津ICP备18009691号
网安备12019202000257

GMT+8, 2021-4-21 10:20 PM

返回顶部