我要发帖 回复

中级会员

4

主题

141

积分

0

专家分

兴趣点(最多三项):

底层技术

私信
发表时间 : 2015-4-10 11:34:57 | 浏览 : 1332    评论 : 8
做的是一个基于MFC 对话框的程序,想把场景加进去,不知为什么我们一起的几个人都遇到了同样的问题。不知道该怎么解决,求解决的方法!

加载对象的代码断点

加载对象的代码断点

错误描述

错误描述

异常点抛出

异常点抛出

最近VR访客

sichuanwww 评论于2015-4-10 15:54:56
加载物体   一般都可以在LP下加载,然后转换为cpp,再调用。
如果彻底明白了,当然可以不用这样。
努力挣钱,快乐生活!
onionor 评论于2015-4-11 10:29:31
项目属性->c++->代码生成->运行库选择多线程DLL(/MD)
samlee 评论于2015-4-12 13:25:42
onionor 发表于 2015-4-11 10:29 AM
项目属性->c++->代码生成->运行库选择多线程DLL(/MD)

属性配置的没有问题
samlee 评论于2015-4-12 13:27:46
onionor 发表于 2015-4-11 10:29 AM
项目属性->c++->代码生成->运行库选择多线程DLL(/MD)

现在的问题是可以找到模型了,但是无法在场景里加载出来,云层和太阳的纹理都可以显示出来
onionor 评论于2015-4-12 21:24:15
samlee 发表于 2015-4-12 01:27 PM
现在的问题是可以找到模型了,但是无法在场景里加载出来,云层和太阳的纹理都可以显示出来 ...

这个问题很模糊啊,你仔细查看下代码,看看是否将对象都放入实例容器了
samlee 评论于2015-4-13 10:57:10
onionor 发表于 2015-4-12 09:24 PM
这个问题很模糊啊,你仔细查看下代码,看看是否将对象都放入实例容器了 ...

#include "StdAfx.h"
#include "VRBasic.h"

//场景窗口句柄
HWND CVRBasic::m_RunWindow = NULL;

//控制VP线程运行的变量
bool CVRBasic::m_ContinuesRunVP = NULL;

//VP线程变量
CWinThread *CVRBasic::m_pVegaThread = NULL;

//对象容器
InstancesList *CVRBasic::m_pInstancesList = NULL;

//VP 对象文件路径
vpSearchPath *CVRBasic::m_pSearchPath = NULL;

//Vp场景对象
vpScene *CVRBasic::m_pScene = NULL;

//VP 观察者对象
vpObject *CVRBasic::m_pObject = NULL;

//VP外挂物对象
vpObject *CVRBasic::m_pObjectOther = NULL;

//程序运行路径
CString CVRBasic::m_RunPath = NULL;

CVRBasic::CVRBasic(void)
{
}

CVRBasic::~CVRBasic(void)
{
}

//
void CVRBasic::GetSysPath(){

        char buf[MAX_PATH];
        ::GetCurrentDirectory(MAX_PATH, buf);
        CVRBasic::m_RunPath.Format("%s", buf);
}

//运动场景配置函数
void CVRBasic::Define(){

        //设置对象容器
        m_pInstancesList = new InstancesList;

        vpModule::initializeModule("vpEnv");
        vpModule::initializeModule("vpMotion");


        //创建内核实例
        vpKernel *m_pKernel = vpKernel::instance();
        m_pKernel->setNotifyLevel(vuNotify::LEVEL_WARN);
        m_pKernel->setNotifyColorEnable(false);
        m_pKernel->setPriority(vuThread::PRIORITY_NORMAL);
        m_pKernel->setProcessor(-1);
        m_pKernel->setFrameRateLimiterEnable(true);
        m_pKernel->setDesiredFrameRate(0);
        m_pKernel->setNotifyClassTypeMode(vuNotify::CLASS_TYPE_MODE_INCLUSIVE);

        vpPagingMgr* pPagingMgr_myPagingMgr = vpPagingMgr::instance();
        pPagingMgr_myPagingMgr->setAsynchronousPagingQueueEnable( true );
        pPagingMgr_myPagingMgr->setAsynchronousFileIOEnable( false );
        pPagingMgr_myPagingMgr->setDefaultQueuePriority( vuThread::PRIORITY_NORMAL );
        pPagingMgr_myPagingMgr->setDefaultQueueProcessor( 0 );
        pPagingMgr_myPagingMgr->setMaxNumPageablesToBeCompletedPerFrame( -1 );

        //搜索对象的路径
        m_pSearchPath = vpSearchPath::instance();
        m_pSearchPath->append(m_RunPath + "//data");
        m_pSearchPath->append(m_RunPath + "//data//town");
        m_pSearchPath->append(m_RunPath + "//data//m1_tank");

        //设置管道
        vpPipeline *m_myPipeline = new vpPipeline();
        m_myPipeline->setName("myPipeline");
        m_myPipeline->setMultiThread(vsPipeline::MULTITHREAD_INLINE);
        m_myPipeline->setId(0);
        m_myPipeline->setNumCullThreads(0);
        m_myPipeline->setCullThreadPriority(vuThread::PRIORITY_NORMAL);
        m_myPipeline->setCullThreadProcessor(-1);
        m_myPipeline->setDrawThreadPriority(vuThread::PRIORITY_NORMAL);
        m_myPipeline->setDrawThreadProcessor(-1);
        m_myPipeline->setBeginFrameOnVsyncEnable(false);
        m_myPipeline->setDesiredBufferObjectSubloadTime(-1);
        m_myPipeline->setDesiredTextureSubloadTime(-1);
        m_myPipeline->setDesiredShaderApplyTime(-1);
        m_myPipeline->setTextureSubloadByteAmount(-1);
        m_myPipeline->setBufferObjectSubloadByteAmount(-1);
        m_myPipeline->setTextureSubloadingGain(1);
        m_myPipeline->setBufferObjectSubloadingGain(1);
        m_myPipeline->setGraphicsResourceApplyThreadMode(vsPipeline::APPLY_ASYNCHRONOUS_GRAPHICS, false);
        m_myPipeline->setGraphicsResourceApplyThreadMode(vsPipeline::APPLY_ASYNCHRONOUS_TEXTURE_SUBLOAD, false);
        m_myPipeline->setGraphicsResourceApplyThreadMode(vsPipeline::APPLY_ASYNCHRONOUS_BUFFER_OBJECT_SUBLOAD, false);
        m_myPipeline->setGraphicsResourceThreadPriority(vuThread::PRIORITY_ABOVE_NORMAL);
        m_myPipeline->setGraphicsResourceThreadProcessor(-1);

        m_pInstancesList->push_back(m_myPipeline);

        //窗体
        vpWindow *pWindow = new vpWindow();
        pWindow->setName("myWindow");
        pWindow->setLabel("Vega Prime Window");
        pWindow->setOrigin(0, 0);
        pWindow->setSize(1024, 768);
        pWindow->setFullScreenEnable(false);
        pWindow->setBorderEnable( true );
        pWindow->setInputEnable( true );
        pWindow->setCursorEnable( true );
        pWindow->setStereoEnable( false );
        pWindow->setNumColorBits( 8 );
        pWindow->setNumAlphaBits( 8 );
        pWindow->setNumDepthBits( 24 );
        pWindow->setNumStencilBits( 0 );
        pWindow->setNumAccumColorBits( 0 );
        pWindow->setNumAccumAlphaBits( 0 );
        pWindow->setNumMultiSampleBits( 4 );
        pWindow->setSwapInterval( 1 );
        pWindow->setSwapSyncEnable( false );
        pWindow->setPixelBufferMode( vrDrawContext::PIXEL_BUFFER_MODE_OFF );

        m_pInstancesList->push_back(pWindow);

        //设置通道
        vpChannel* pChannel_myChannel = new vpChannel();
        pChannel_myChannel->setName( "myChannel" );
        pChannel_myChannel->setOffsetTranslate( 0 ,  0 ,  0 );
        pChannel_myChannel->setOffsetRotate( 0 ,  0 ,  0 );
        pChannel_myChannel->setCullMask( 0x0FFFFFFFF );
        pChannel_myChannel->setRenderMask( 0x0FFFFFFFF );
        pChannel_myChannel->setClearColor( 0.000000f ,  0.500000f ,  1.000000f ,  0.000000f );
        pChannel_myChannel->setClearBuffers( 0x03 );
        pChannel_myChannel->setDrawArea( 0 ,  1 ,  0 ,  1 );
        pChannel_myChannel->setFOVSymmetric( 45.000000f ,  -1.000000f );
        pChannel_myChannel->setNearFar( 1.000000f ,  35000.000000f );
        pChannel_myChannel->setLODVisibilityRangeScale( 1 );
        pChannel_myChannel->setLODTransitionRangeScale( 1 );
        pChannel_myChannel->setFOVScale( -1 );
        pChannel_myChannel->setCullThreadPriority( vuThread::PRIORITY_NORMAL );
        pChannel_myChannel->setCullThreadProcessor( -1 );
        pChannel_myChannel->setGraphicsModeEnable( vpChannel::GRAPHICS_MODE_WIREFRAME ,  false );
        pChannel_myChannel->setGraphicsModeEnable( vpChannel::GRAPHICS_MODE_TRANSPARENCY ,  true );
        pChannel_myChannel->setGraphicsModeEnable( vpChannel::GRAPHICS_MODE_TEXTURE ,  true );
        pChannel_myChannel->setGraphicsModeEnable( vpChannel::GRAPHICS_MODE_LIGHT ,  true );
        pChannel_myChannel->setGraphicsModeEnable( vpChannel::GRAPHICS_MODE_FOG ,  true );
        pChannel_myChannel->setGraphicsModeEnable( vpChannel::GRAPHICS_MODE_SHADERS ,  true );
        pChannel_myChannel->setLightPointThreadPriority( vuThread::PRIORITY_NORMAL );
        pChannel_myChannel->setLightPointThreadProcessor( -1 );
        pChannel_myChannel->setMultiSample( vpChannel::MULTISAMPLE_ANTIALIAS );
        pChannel_myChannel->setStatisticsPage( vpChannel::PAGE_OFF );
        pChannel_myChannel->setCullBoundingBoxTestEnable( false );
        pChannel_myChannel->setOpaqueSort( vpChannel::OPAQUE_SORT_TEXTURE ,  vpChannel::OPAQUE_SORT_MATERIAL );
        pChannel_myChannel->setTransparentSort( vpChannel::TRANSPARENT_SORT_DEPTH );
        pChannel_myChannel->setDrawBuffer( vpChannel::DRAW_BUFFER_DEFAULT );
        pChannel_myChannel->setStressEnable( false );
        pChannel_myChannel->setStressParameters( 1 ,  20 ,  0.75 ,  0.5 ,  2 );

        m_pInstancesList->push_back(pChannel_myChannel);

        //观察者
        vpObserver* pObserver_myObserver = new vpObserver();
        pObserver_myObserver->setName( "myObserver" );
        pObserver_myObserver->setStrategyEnable( true );
        pObserver_myObserver->setTranslate( -1297.13 ,  -1025.92 ,  343.347 );
        pObserver_myObserver->setRotate( 292 ,  -7 ,  0 );
        pObserver_myObserver->setLatencyCriticalEnable( false );

        m_pInstancesList->push_back(pObserver_myObserver);

        //场景
        m_pScene = new vpScene();
        m_pScene->setName( "myScene" );

        m_pInstancesList->push_back(m_pScene);


        //对象:地形
        m_pObject= new vpObject();
        m_pObject->setName( "town" );
        m_pObject->setCullMask( 0x0FFFFFFFF );
        m_pObject->setRenderMask( 0x0FFFFFFFF );
        m_pObject->setIsectMask( 0x0FFFFFFFF );
        m_pObject->setStrategyEnable( false );
        m_pObject->setTranslate( 0 ,  0 ,  0 );
        m_pObject->setRotate( 0 ,  0 ,  0 );
        m_pObject->setScale( 1 ,  1 ,  1 );
        m_pObject->setStaticEnable( false );
        m_pObject->setFileName( "town.flt" );
        m_pObject->setAutoPage( vpObject::AUTO_PAGE_SYNCHRONOUS );
        m_pObject->setManualLODChild( -1 );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_LIGHT_SOURCES ,  false );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_SIGNIFICANT_SIZE ,  false );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_CONTROLS ,  true );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_ANIMATIONS ,  true );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_APPEARANCES ,  true );
        m_pObject->setLoaderDetailMultiTextureStage( -1 );
        m_pObject->setLoaderBlendTolerance( 0.050000f );
        m_pObject->setLoaderUnits( vsNodeLoader::Data::LOADER_UNITS_METERS );
        m_pObject->setBuilderNormalMode( vsNodeLoader::Data::BUILDER_NORMAL_MODE_PRESERVE );
        m_pObject->setBuilderTangentMode( vsNodeLoader::Data::BUILDER_TANGENT_MODE_GENERATE_PER_VERTEX_PER_PRIMITIVE_AND_ANGLE_WEIGHTED );
        m_pObject->setBuilderTangentGenerationMode( vsNodeLoader::Data::BUILDER_TANGENT_GENERATION_MODE_GENERATE_AS_NEEDED );
        m_pObject->setBuilderColorTolerance( 0.001000f );
        m_pObject->setBuilderNormalTolerance( 0.860000f );
        m_pObject->setGeometryOption( vsNodeLoader::Data::GEOMETRY_OPTION_GENERATE_DISPLAY_LISTS ,  false );
        m_pObject->setGeometryFormat( vrGeometryBase::FORMAT_VERTEX_BUFFER_OBJECT ,  0x0FFF );
        m_pObject->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_COLLAPSE_BINDINGS ,  true );
        m_pObject->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_COLLAPSE_TRIANGLE_STRIPS ,  true );
        m_pObject->setTextureSubloadEnable( false );
        m_pObject->setBufferObjectSubloadEnable( true );
        m_pObject->setTextureSubloadRender( vpGeometry::TEXTURE_SUBLOAD_RENDER_DEFERRED );
        m_pObject->setTexturePreserveImageLevelsEnable( true );

        m_pInstancesList->push_back(m_pObject);


        //对象:坦克
        vpObject* pObject_m1_tank = new vpObject();
        pObject_m1_tank->setName( "m1_tank" );
        pObject_m1_tank->setCullMask( 0x0FFFFFFFF );
        pObject_m1_tank->setRenderMask( 0x0FFFFFFFF );
        pObject_m1_tank->setIsectMask( 0x0FFFFFFFF );
        pObject_m1_tank->setStrategyEnable( true );
        pObject_m1_tank->setTranslate( 0 ,  0 ,  0 );
        pObject_m1_tank->setRotate( 0 ,  0 ,  0 );
        pObject_m1_tank->setScale( 1 ,  1 ,  1 );
        pObject_m1_tank->setStaticEnable( false );
        pObject_m1_tank->setFileName( "m1_tank.flt" );
        pObject_m1_tank->setAutoPage( vpObject::AUTO_PAGE_SYNCHRONOUS );
        pObject_m1_tank->setManualLODChild( -1 );
        pObject_m1_tank->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_LIGHT_SOURCES ,  false );
        pObject_m1_tank->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_SIGNIFICANT_SIZE ,  false );
        pObject_m1_tank->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_CONTROLS ,  true );
        pObject_m1_tank->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_ANIMATIONS ,  true );
        pObject_m1_tank->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_APPEARANCES ,  true );
        pObject_m1_tank->setLoaderDetailMultiTextureStage( -1 );
        pObject_m1_tank->setLoaderBlendTolerance( 0.050000f );
        pObject_m1_tank->setLoaderUnits( vsNodeLoader::Data::LOADER_UNITS_METERS );
        pObject_m1_tank->setBuilderNormalMode( vsNodeLoader::Data::BUILDER_NORMAL_MODE_PRESERVE );
        pObject_m1_tank->setBuilderTangentMode( vsNodeLoader::Data::BUILDER_TANGENT_MODE_GENERATE_PER_VERTEX_PER_PRIMITIVE_AND_ANGLE_WEIGHTED );
        pObject_m1_tank->setBuilderTangentGenerationMode( vsNodeLoader::Data::BUILDER_TANGENT_GENERATION_MODE_GENERATE_AS_NEEDED );
        pObject_m1_tank->setBuilderColorTolerance( 0.001000f );
        pObject_m1_tank->setBuilderNormalTolerance( 0.860000f );
        pObject_m1_tank->setGeometryFormat( vrGeometryBase::FORMAT_VERTEX_BUFFER_OBJECT ,  0x0FFF );
        pObject_m1_tank->setTextureSubloadEnable( true );
        pObject_m1_tank->setBufferObjectSubloadEnable( true );
        pObject_m1_tank->setTextureSubloadRender( vpGeometry::TEXTURE_SUBLOAD_RENDER_DEFERRED );
        pObject_m1_tank->setTexturePreserveImageLevelsEnable( false );

        m_pInstancesList->push_back(pObject_m1_tank);


        vpRecyclingService* pRecyclingService_myRecyclingService = vpRecyclingService::instance();
        pRecyclingService_myRecyclingService->setMultiThread( vpRecyclingService::MULTITHREAD_INLINE );
        pRecyclingService_myRecyclingService->setThreadPriority( vuThread::PRIORITY_NORMAL );
        pRecyclingService_myRecyclingService->setThreadProcessor( -1 );
        pRecyclingService_myRecyclingService->setRecycleTime( -1 );

        vpEnvGlobals* pEnvGlobals_myEnvGlobals = vpEnvGlobals::instance();
        pEnvGlobals_myEnvGlobals->setSkyLightEnable( true );
        pEnvGlobals_myEnvGlobals->setDominantCelestialLightingEnable( true );
        pEnvGlobals_myEnvGlobals->setLocalViewerEnable( false );
        pEnvGlobals_myEnvGlobals->setTwoSidedLightingEnable( false );
        pEnvGlobals_myEnvGlobals->setEnvironmentMapGenerationEnable( false );

        vpEnv* pEnv_myEnv = new vpEnv();
        pEnv_myEnv->setName( "myEnv" );
        pEnv_myEnv->setDate( 1 ,  9 ,  2006 );
        pEnv_myEnv->setTimeOfDay( 9.250000f );
        pEnv_myEnv->setTimeMultiplier( 1.000000f );
        pEnv_myEnv->setEphemerisUpdateInterval( 0.000000f );
        pEnv_myEnv->setReferencePosition( -117.355103f ,  33.301300f );
        pEnv_myEnv->setEphemerisTimeZoneOffset( -10000 );
        pEnv_myEnv->setSkyColor( 0.513725f ,  0.701961f ,  0.941176f ,  1.000000f );
        pEnv_myEnv->setVisibilityType( vpEnvFx::VISIBILITY_TYPE_VERTEX_EXP2 );
        pEnv_myEnv->setVisibilityRangeOnset( 0.000000f );
        pEnv_myEnv->setVisibilityRangeOpaque( 60000.000000f );
        pEnv_myEnv->setVisibilityColor( 0.764706f ,  0.858824f ,  1.000000f ,  1.000000f );
        pEnv_myEnv->setHazeColor( 0.772549f ,  0.772549f ,  0.772549f ,  0.445397f );
        pEnv_myEnv->setManageVisibilityColorsEnable( true );
        pEnv_myEnv->setAmbientLightingColor( 0.000000f ,  0.000000f ,  0.000000f ,  1.000000f );
        pEnv_myEnv->setLightBrightnessScale( vpEnv::COLOR_AMBIENT ,  0.500000f );
        pEnv_myEnv->setLightBrightnessScale( vpEnv::COLOR_DIFFUSE ,  0.500000f );
        pEnv_myEnv->setLightBrightnessScale( vpEnv::COLOR_SPECULAR ,  1.000000f );
        pEnv_myEnv->setLightColorScale( vpEnv::COLOR_AMBIENT ,  1.000000f ,  1.000000f ,  1.000000f );
        pEnv_myEnv->setLightColorScale( vpEnv::COLOR_DIFFUSE ,  1.000000f ,  1.000000f ,  1.000000f );
        pEnv_myEnv->setLightColorScale( vpEnv::COLOR_SPECULAR ,  1.000000f ,  1.000000f ,  1.000000f );

        m_pInstancesList->push_back(pEnv_myEnv);

        //太阳
        vpEnvSun* pEnvSun_myEnvSun = new vpEnvSun();
        pEnvSun_myEnvSun->setName( "myEnvSun" );
        pEnvSun_myEnvSun->setEnable( true );
        pEnvSun_myEnvSun->setTwilightDip( -18.000000f );
        pEnvSun_myEnvSun->setGeometryEnable( true );
        pEnvSun_myEnvSun->setTextureFile( "sun.inta" );
        pEnvSun_myEnvSun->setTextureBlendColor( 1.000000f ,  1.000000f ,  1.000000f ,  1.000000f );
        pEnvSun_myEnvSun->setTextureBlendMode( vpEnvSun::TEXTURE_BLEND_MODE_MODULATE );
        pEnvSun_myEnvSun->setColor( 0.992156f ,  1.000000f ,  0.949019f ,  1.000000f );
        pEnvSun_myEnvSun->setVisibilityRangeRatio( 0.050000f );
        pEnvSun_myEnvSun->setAngularSize( 5.500000f );
        pEnvSun_myEnvSun->setHorizonAngle( 40.000000f );
        pEnvSun_myEnvSun->setHorizonColor( 1.000000f ,  0.545098f ,  0.239216f ,  1.000000f );
        pEnvSun_myEnvSun->setHorizonSizeScale( 2.000000f );
        pEnvSun_myEnvSun->setHorizonLightColorScale( 0.250000f );

        m_pInstancesList->push_back( pEnvSun_myEnvSun );

        //月亮
        vpEnvMoon* pEnvMoon_myEnvMoon = new vpEnvMoon();
        pEnvMoon_myEnvMoon->setName( "myEnvMoon" );
        pEnvMoon_myEnvMoon->setEnable( true );
        pEnvMoon_myEnvMoon->setBrightness( 0.250000f );
        pEnvMoon_myEnvMoon->setGeometryEnable( true );
        pEnvMoon_myEnvMoon->setTextureFile( "moon.inta" );
        pEnvMoon_myEnvMoon->setTextureBlendColor( 1.000000f ,  1.000000f ,  1.000000f ,  1.000000f );
        pEnvMoon_myEnvMoon->setTextureBlendMode( vpEnvMoon::TEXTURE_BLEND_MODE_MODULATE );
        pEnvMoon_myEnvMoon->setColor( 0.811765f ,  0.886275f ,  0.937255f ,  1.000000f );
        pEnvMoon_myEnvMoon->setVisibilityRangeRatio( 0.100000f );
        pEnvMoon_myEnvMoon->setAngularSize( 1.500000f );
        pEnvMoon_myEnvMoon->setHorizonAngle( 30.000000f );
        pEnvMoon_myEnvMoon->setHorizonColor( 0.811765f ,  0.886275f ,  0.937255f ,  1.000000f );
        pEnvMoon_myEnvMoon->setHorizonSizeScale( 1.700000f );
        pEnvMoon_myEnvMoon->setHorizonLightColorScale( 0.000000f );

        m_pInstancesList->push_back( pEnvMoon_myEnvMoon );

        //天空盒
        vpEnvSkyDome* pEnvSkyDome_myEnvSkyDome = new vpEnvSkyDome();
        pEnvSkyDome_myEnvSkyDome->setName( "myEnvSkyDome" );
        pEnvSkyDome_myEnvSkyDome->setEnable( true );
        pEnvSkyDome_myEnvSkyDome->setGroundColor( 0.211765f ,  0.286275f ,  0.149020f ,  1.000000f );
        pEnvSkyDome_myEnvSkyDome->setGroundEnable( true );
        pEnvSkyDome_myEnvSkyDome->setVisibilityRangeRatio( 0 ,  0.100000f );
        pEnvSkyDome_myEnvSkyDome->setVisibilityRangeRatio( 1 ,  0.300000f );
        pEnvSkyDome_myEnvSkyDome->setVisibilityRangeRatio( 2 ,  0.750000f );
        pEnvSkyDome_myEnvSkyDome->setVisibilityRangeRatio( 3 ,  0.900000f );
        pEnvSkyDome_myEnvSkyDome->setVisibilityRangeRatio( 4 ,  1.000000f );
        pEnvSkyDome_myEnvSkyDome->setVisibilityRangeRatio( 5 ,  1.000000f );
        pEnvSkyDome_myEnvSkyDome->setVisibilityRangeRatio( 6 ,  1.000000f );

        m_pInstancesList->push_back( pEnvSkyDome_myEnvSkyDome );

        //云层
        vpEnvCloudLayer* pEnvCloudLayer_myEnvCloudLayer = new vpEnvCloudLayer();
        pEnvCloudLayer_myEnvCloudLayer->setName( "myEnvCloudLayer" );
        pEnvCloudLayer_myEnvCloudLayer->setEnable( true );
        pEnvCloudLayer_myEnvCloudLayer->setColor( 0.300000f ,  0.300000f ,  0.300000f ,  1.000000f );
        pEnvCloudLayer_myEnvCloudLayer->setElevation( 5000.000000f ,  6000.000000f );
        pEnvCloudLayer_myEnvCloudLayer->setTransitionRange( 500.000000f ,  500.000000f );
        pEnvCloudLayer_myEnvCloudLayer->setScudEnable( false );
        pEnvCloudLayer_myEnvCloudLayer->setTextureFile( "" );
        pEnvCloudLayer_myEnvCloudLayer->setTextureBlendColor( 1.000000f ,  1.000000f ,  1.000000f ,  1.000000f );
        pEnvCloudLayer_myEnvCloudLayer->setTextureBlendMode( vpEnvCloudLayer::TEXTURE_BLEND_MODE_MODULATE );
        pEnvCloudLayer_myEnvCloudLayer->setTextureTiling( 2.000000f ,  2.000000f );
        pEnvCloudLayer_myEnvCloudLayer->setMinVisibilityScale( 0.000000f );
        pEnvCloudLayer_myEnvCloudLayer->setHorizonColorScale( 1.000000f );
        pEnvCloudLayer_myEnvCloudLayer->setCoverageScale( 0.250000f );
        pEnvCloudLayer_myEnvCloudLayer->setShadowsEnable( false );
        pEnvCloudLayer_myEnvCloudLayer->setShadowsColorPunchThrough( 0.300000f );
        pEnvCloudLayer_myEnvCloudLayer->setShadowIntensity( 0.600000f );
        pEnvCloudLayer_myEnvCloudLayer->setShadowsContribution( 0.100000f ,  0.900000f );

        m_pInstancesList->push_back( pEnvCloudLayer_myEnvCloudLayer );

        //星星
        vpEnvStars* pEnvStars_myEnvStars = new vpEnvStars();
        pEnvStars_myEnvStars->setName( "myEnvStars" );
        pEnvStars_myEnvStars->setEnable( true );
        pEnvStars_myEnvStars->setIntensityThreshold( 0.350000f );
        pEnvStars_myEnvStars->setBrightnessThreshold( 0.400000f ,  0.250000f );
        pEnvStars_myEnvStars->setVisibilityRangeRatio( 0.100000f );
        pEnvStars_myEnvStars->setPointSize( 2.300000f );

        m_pInstancesList->push_back( pEnvStars_myEnvStars );

        //风
        vpEnvWind* pEnvWind_myEnvWind = new vpEnvWind();
        pEnvWind_myEnvWind->setName( "myEnvWind" );
        pEnvWind_myEnvWind->setEnable( true );
        pEnvWind_myEnvWind->setSpeed( 100.000000f );
        pEnvWind_myEnvWind->setDirection( 0.000000f ,  1.000000f ,  0.000000f );

        m_pInstancesList->push_back( pEnvWind_myEnvWind );

        //运动模式
        vpMotionUFO* pMotionUFO_myMotion = new vpMotionUFO();
        pMotionUFO_myMotion->setName( "myMotion" );
        pMotionUFO_myMotion->setSpeed( 10 );
        pMotionUFO_myMotion->setBoost( 50 );
        pMotionUFO_myMotion->setBoostTurning( 5 );
        pMotionUFO_myMotion->setRateHeading( 40 );
        pMotionUFO_myMotion->setRatePitch( 20 );

        m_pInstancesList->push_back( pMotionUFO_myMotion );

        // Satisfy all references 配置各种对象实例
        m_myPipeline->addWindow(pWindow);
        pWindow->addChannel(pChannel_myChannel);

        pObserver_myObserver->setStrategy(pMotionUFO_myMotion);
        pObserver_myObserver->addChannel(pChannel_myChannel);
        pObserver_myObserver->addAttachment(pEnv_myEnv);
        pObserver_myObserver->setScene(m_pScene);

        m_pScene->addChild(m_pObject);
        m_pScene->addChild(pObject_m1_tank);

        pEnv_myEnv->addEnvFx( pEnvSun_myEnvSun );
        pEnv_myEnv->addEnvFx( pEnvMoon_myEnvMoon );
        pEnv_myEnv->addEnvFx( pEnvSkyDome_myEnvSkyDome );
        pEnv_myEnv->addEnvFx( pEnvCloudLayer_myEnvCloudLayer );
        pEnv_myEnv->addEnvFx( pEnvWind_myEnvWind );
        pEnv_myEnv->addEnvFx( pEnvStars_myEnvStars );
}

//动态添加物体
void CVRBasic::AddObject(CString FileDirctory, CString ObjectName, CString FileName){


        //文件路径
        m_pSearchPath->append(FileDirctory);

        //物体名称
        m_pObject->setName(ObjectName);

        m_pObject->setCullMask( 0x0FFFFFFFF );
        m_pObject->setRenderMask( 0x0FFFFFFFF );
        m_pObject->setIsectMask( 0x0FFFFFFFF );
        m_pObject->setStrategyEnable( false );
        m_pObject->setTranslate( 20 ,  20 ,  10 );
        m_pObject->setRotate( 0 ,  0 ,  0 );
        m_pObject->setScale( 1 ,  1 ,  1 );
        m_pObject->setStaticEnable( false );

        //物体文件
        m_pObject->setFileName(FileName);

        m_pObject->setAutoPage( vpObject::AUTO_PAGE_SYNCHRONOUS );
        m_pObject->setManualLODChild( -1 );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_LIGHT_SOURCES ,  false );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_PRESERVE_SIGNIFICANT_SIZE ,  false );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_CONTROLS ,  true );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_ANIMATIONS ,  true );
        m_pObject->setLoaderOption( vsNodeLoader::Data::LOADER_OPTION_SHARE_LIGHT_POINT_APPEARANCES ,  true );
        m_pObject->setLoaderDetailMultiTextureStage( -1 );
        m_pObject->setLoaderBlendTolerance( 0.050000f );
        m_pObject->setLoaderUnits( vsNodeLoader::Data::LOADER_UNITS_METERS );
        m_pObject->setBuilderNormalMode( vsNodeLoader::Data::BUILDER_NORMAL_MODE_PRESERVE );
        m_pObject->setBuilderTangentMode( vsNodeLoader::Data::BUILDER_TANGENT_MODE_GENERATE_PER_VERTEX_PER_PRIMITIVE_AND_ANGLE_WEIGHTED );
        m_pObject->setBuilderTangentGenerationMode( vsNodeLoader::Data::BUILDER_TANGENT_GENERATION_MODE_GENERATE_AS_NEEDED );
        m_pObject->setBuilderColorTolerance( 0.001000f );
        m_pObject->setBuilderNormalTolerance( 0.860000f );
        m_pObject->setGeometryOption( vsNodeLoader::Data::GEOMETRY_OPTION_GENERATE_DISPLAY_LISTS ,  false );
        m_pObject->setGeometryFormat( vrGeometryBase::FORMAT_VERTEX_BUFFER_OBJECT ,  0x0FFF );
        m_pObject->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_COLLAPSE_BINDINGS ,  true );
        m_pObject->setPostLoadOption( vpGeometryPageable::POST_LOAD_OPTION_COLLAPSE_TRIANGLE_STRIPS ,  true );
        m_pObject->setTextureSubloadEnable( false );
        m_pObject->setBufferObjectSubloadEnable( true );
        m_pObject->setTextureSubloadRender( vpGeometry::TEXTURE_SUBLOAD_RENDER_DEFERRED );
        m_pObject->setTexturePreserveImageLevelsEnable( true );


        m_pInstancesList->push_back(m_pObject);
}


//控制物体透明
void CVRBasic::SetObjectTransparent(vpObject *pObject, bool transparent){

        vrAlphaTest::Element ate;
        if(transparent)
                //设置为透明
                ate.m_ref = 1.0f;
        else
                //设置为不透明
                ate.m_ref = 0.0f;

        ate.m_mode = vrAlphaTest::MODE_GREATER;
        ate.m_enable = true;
        vpObject::const_iterator_geometry nit, nite = pObject->end_geometry();
        for (nit = pObject->begin_geometry(); nit != nite; nit ++)
        {
                vrState *state = (* nit)->getState();

                state->setElement(vrAlphaTest::Element::Id, &ate);
                (*nit)->setState(state);
        }

}
//键盘消息响应函数
void CVRBasic::KeyBoard(vpWindow *window, vpWindow::Key key, int mod, void *){

        switch(key){

                //方向键:上
                case vpWindow::KEY_UP:
                        m_pObjectOther->setTranslateY(1.0, true);
                        break;
                //方向键:下
                case vpWindow::KEY_DOWN:
                        m_pObjectOther->setTranslateY(-1.0, true);
                        break;
                //方向键:左
                case vpWindow::KEY_LEFT:
                        m_pObjectOther->setTranslateX(1.0, true);
                        break;
                //方向键:右
                case vpWindow::KEY_RIGHT:
                        m_pObjectOther->setTranslateX(-1.0, true);
                        break;

                default:
                        break;
        }
}

//运行主线程
UINT CVRBasic::RunBasicThread(LPVOID){

        //初始化
        vp::initialize(__argc, __argv);

        //定义场景
        Define();

        //动态添加外挂物-----------------------------------------------------------------

        //添加对象
        //AddObject("C:\\Users\\Administrator\\Desktop\\CVPDlg\\data","m1_tank", "m1_tank.flt" );

        //绘制场景
        vpKernel::instance()->configure();

        ////设置观察者
        //m_pObject = vpObject::find("m1_tank ");
        //m_pObject->ref();

        //设置窗体
        vpWindow *vpWin = *vpWindow::begin();
        vpWin->setParent(m_RunWindow);
        vpWin->setBorderEnable(false);
        vpWin->setFullScreenEnable(true);

        //设置键盘
        vpWin->setInputEnable(true);
        vpWin->setKeyboardFunc((vpWindow::KeyboardFunc)KeyBoard, NULL);
       
        vpWin->open();
        ::SetFocus(vpWin->getWindow());

        //帧循环
        while(vpKernel::instance()->beginFrame() != 0){

                vpKernel::instance()->endFrame();
                if (!m_ContinuesRunVP)
                {
                        vpKernel::instance()->endFrame();
                        vpKernel::instance()->unconfigure();

                        vp::shutdown();

                        return 0;
                }
        }
        return 0;
}
cneter 评论于2015-4-14 16:48:08
samlee 发表于 2015-4-13 10:57 AM
#include "StdAfx.h"
#include "VRBasic.h"

报错可能是你的模型文件找不到,如果不报错了还显示不了是因为你没有
m_pScene->addChild(vpObject*)
onionor 评论于2015-4-17 22:37:07
samlee 发表于 2015-4-13 10:57 AM
#include "StdAfx.h"
#include "VRBasic.h"

myEnv场景加载成功了?
你把m_pInstancesList改成CVRBasic::m_pInstancesList试试

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

GMT+8, 2020-12-5 10:19 AM

返回顶部