source: GTP/trunk/App/Games/Jungle_Rumble/src/Ocean.cpp @ 1378

Revision 1378, 2.5 KB checked in by giegl, 18 years ago (diff)

GTPD - Jungle Rumble - integrate into GTP SVN structure

Line 
1#include "dxstdafx.h"
2#include "./Ocean.h"
3#include "NxPhysics.h"
4
5Ocean::Ocean(void):Node() {
6        this->nodeType |= GameScene::NODE_OCEAN;
7}
8
9void Ocean::generateOcean(float deepC [4], float shallowC [4])
10{
11        //load effect
12        loadEffect(deepC, shallowC);
13       
14        Object3d *p = (Object3d *) this->myScene->createNode(this->myScene->NODE_OBJECT3D, *this->myScene->getRoot(), false);
15        p->loadMeshFromFile("./media/models/plane3.x");
16       
17        // create renderer
18       
19        SPTR<Renderer> renderer(new OceanRenderer);
20        renderer->setScene(*this->myScene);
21        OceanRenderer *temp = (OceanRenderer*)renderer.get();
22        temp->setEffect(this->OceanEffect);
23        this->myScene->connectNodeAndRenderer(*p, renderer);
24
25        //set mesh position
26        p->setPosition(this->myScene->getWidth()/2, 0.0f, this->myScene->getDepth()/2);
27}
28
29Ocean::~Ocean(void)
30{
31       
32        //OceanEffect->Release();
33}
34
35void Ocean::setTextures(std::string texture0, std::string texture1, std::string watermap) {
36        this->texture0 = texture0;
37        this->texture1 = texture1;
38        this->watermap = watermap;
39}
40
41void Ocean::loadEffect(float *deepC, float *shallowC) {
42        this->OceanEffect = this->myScene->manager->getEffect(GameManager::EFFECT_OCEAN);
43        if(!this->OceanEffect) {
44                this->OceanEffect = this->myScene->manager->loadEffect(GameManager::EFFECT_OCEAN, L"shaders/Ocean.obj");
45        }
46
47        TexHandleWaves = OceanEffect->GetParameterByName(0, "normalMap");
48        TexHandleCubemap = OceanEffect->GetParameterByName(0, "cubeMap");
49        TexHandleTerrain = OceanEffect->GetParameterByName(0, "terrainTex");
50       
51        IDirect3DTexture9* tex = 0;
52        tex = this->myScene->manager->resManager.loadTexture(this->texture0);
53        OceanEffect->SetTexture(TexHandleWaves, tex);
54       
55        tex = 0;
56        tex = this->myScene->manager->resManager.loadTexture(this->texture1);
57        OceanEffect->SetTexture(TexHandleCubemap, tex);
58
59        tex = 0;
60        tex = this->myScene->manager->resManager.loadTexture(this->watermap);
61        OceanEffect->SetTexture(TexHandleTerrain, tex);
62
63        ShallowColorHandle = OceanEffect->GetParameterByName(0, "shallowColor");
64        OceanEffect->SetFloatArray(ShallowColorHandle, shallowC, 4);
65
66        DeepColorHandle = OceanEffect->GetParameterByName(0, "deepColor");
67        OceanEffect->SetFloatArray(DeepColorHandle, deepC, 4);
68
69        DimensionHandle = OceanEffect->GetParameterByName(0, "fSceneDimensions");
70        float fDimension[3];
71        fDimension[0] = myScene->getWidth();
72        fDimension[1] = myScene->getHeight();
73        fDimension[2] = myScene->getDepth();
74        OceanEffect->SetFloatArray(DimensionHandle, fDimension, 3);     
75}
76
77
Note: See TracBrowser for help on using the repository browser.