Ignore:
Timestamp:
10/20/08 01:26:12 (16 years ago)
Author:
mattausch
Message:

added shader for forward shadin tree animation program

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r3045 r3046  
    4242static CGprofile sCgFragmentProfile; 
    4343static CGprofile sCgVertexProfile;  
    44 static ShaderProgram *sTreeAnimation; 
     44 
     45static ShaderProgram *sTreeAnimationProgramMrt; 
     46static ShaderProgram *sTreeAnimationProgram; 
     47 
    4548 
    4649// only instance of the resource manager 
     
    153156 
    154157        /////////// 
    155         //-- hack: tree animation 
     158        //-- hack: add tree animation 
    156159 
    157160        if (numLODs > 1) 
    158161        { 
    159                 for (int i = 0; i < min(numLODs, 2); ++ i) 
     162                //for (int i = 0; i < min(numLODs, 2); ++ i) 
     163                for (int i = 0; i < numLODs; ++ i) 
    160164                { 
    161165                        ShapeContainer::iterator sstart, send; 
     
    172176                                { 
    173177                                        Technique *tech = mat->GetTechnique(i); 
    174                                         tech->SetVertexProgram(sTreeAnimation); 
    175178 
    176179                                        GPUProgramParameters *vtxParams = tech->GetVertexProgramParameters(); 
    177180 
     181                                        if (i == 0) 
     182                                        { 
     183                                                tech->SetVertexProgram(sTreeAnimationProgram); 
     184                                                vtxParams->SetLightDirParam(5); 
     185                                        } 
     186                                        else 
     187                                        { 
     188                                                tech->SetVertexProgram(sTreeAnimationProgramMrt); 
     189                                        } 
     190 
     191                                        /// use a timer to simulate the moving of the tree in the wind 
    178192                                        vtxParams->SetTimerParam(0); 
    179193                                        // wind direction 
     
    352366 
    353367 
    354 void ResourceManager::LoadSceneEntities(igzstream &str, SceneEntityContainer &entities) 
     368void ResourceManager::LoadSceneEntities(igzstream &str,  
     369                                                                                SceneEntityContainer &entities) 
    355370{ 
    356371        int entityCount; 
     
    373388 
    374389 
    375 bool ResourceManager::Load(const std::string &filename, SceneEntityContainer &entities) 
     390bool ResourceManager::Load(const std::string &filename, 
     391                                                   SceneEntityContainer &entities) 
    376392{ 
    377393        igzstream istr(filename.c_str()); 
     
    468484        mMrtDefaultFragmentProgram->AddParameter("viewMatrix", 0); 
    469485        mMrtDefaultFragmentTexProgram->AddParameter("viewMatrix", 0); 
    470  
    471486        // add a texture parameter 
    472487        mMrtDefaultFragmentTexProgram->AddParameter("tex", 1); 
    473488 
    474         sTreeAnimation = CreateVertexProgram("treeanimation", "animateVtxMrt"); 
    475  
    476         sTreeAnimation->AddParameter("timer", 0); 
    477         sTreeAnimation->AddParameter("windDir", 1); 
    478         sTreeAnimation->AddParameter("windStrength", 2); 
    479         sTreeAnimation->AddParameter("minMaxPos", 3); 
    480         sTreeAnimation->AddParameter("frequency", 4); 
     489 
     490        //////////// 
     491        //-- hack: apply hardcoded tree animation (should be provided with a material script!) 
     492 
     493        sTreeAnimationProgram = CreateVertexProgram("treeanimation", "animateVtx"); 
     494        sTreeAnimationProgramMrt = CreateVertexProgram("treeanimation", "animateVtxMrt"); 
     495 
     496        sTreeAnimationProgram->AddParameter("timer", 0); 
     497        sTreeAnimationProgram->AddParameter("windDir", 1); 
     498        sTreeAnimationProgram->AddParameter("windStrength", 2); 
     499        sTreeAnimationProgram->AddParameter("minMaxPos", 3); 
     500        sTreeAnimationProgram->AddParameter("frequency", 4); 
     501        sTreeAnimationProgram->AddParameter("lightDir", 5); 
     502 
     503        sTreeAnimationProgramMrt->AddParameter("timer", 0); 
     504        sTreeAnimationProgramMrt->AddParameter("windDir", 1); 
     505        sTreeAnimationProgramMrt->AddParameter("windStrength", 2); 
     506        sTreeAnimationProgramMrt->AddParameter("minMaxPos", 3); 
     507        sTreeAnimationProgramMrt->AddParameter("frequency", 4); 
    481508 
    482509        cout << "cg initialization successful" << endl; 
Note: See TracChangeset for help on using the changeset viewer.