Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 273 vs 286 for /trunk/Source Code/Dynamics/Entities/Impostor.cpp

Diff revisions: vs.
  @@ -5,56 +5,17 @@
5 5 #include "Hardware/Video/Headers/RenderStateBlock.h"
6 6 #include "Geometry/Material/Headers/Material.h"
7 7
8 - Impostor::Impostor(const std::string& name, F32 radius) : _visible(false){
9 - ResourceDescriptor materialDescriptor(name+"_impostor_material");
10 - materialDescriptor.setFlag(true); //No shader
11 -
12 - ResourceDescriptor impostorDesc(name+"_impostor");
13 - impostorDesc.setFlag(true); //No default material
14 -
15 - _dummy = CreateResource<Sphere3D>(impostorDesc);
16 - _dummy->setMaterial(CreateResource<Material>(materialDescriptor));
17 - if(GFX_DEVICE.getRenderer()->getType() != RENDERER_FORWARD){
18 - _dummy->getMaterial()->setShaderProgram("DeferredShadingPass1.Impostor");
19 - }else{
20 - _dummy->getMaterial()->setShaderProgram("lighting");
21 - }
22 - _dummy->getSceneNodeRenderState().setDrawState(false);
23 - _dummy->setResolution(8);
24 - _dummy->setRadius(radius);
25 - RenderStateBlockDescriptor dummyDesc(GFX_DEVICE.getStateBlockDescriptor(_dummy->getMaterial()->getRenderStateBlock(FINAL_STAGE)));
8 + Impostor::Impostor(const std::string& name, F32 radius) : Sphere3D(radius, 8)
9 + {
10 + getSceneNodeRenderState().setDrawState(false);
11 +
12 + RenderStateBlockDescriptor dummyDesc(GFX_DEVICE.getStateBlockDescriptor(getMaterial()->getRenderStateBlock(FINAL_STAGE)));
26 13 dummyDesc.setFillMode(FILL_MODE_WIREFRAME);
27 - _dummy->getMaterial()->setRenderStateBlock(dummyDesc, FINAL_STAGE);
14 + getMaterial()->setRenderStateBlock(dummyDesc, FINAL_STAGE);
15 + setName(name);
16 + setState(RES_LOADED);
28 17 }
29 18
30 19 Impostor::~Impostor(){
31 - //Do not delete dummy as it is added to the SceneGraph as the node's child.
32 - //Only the SceneNode (by Uther's might) should delete the dummy
33 - }
34 -
35 - void Impostor::render(SceneGraphNode* const node, const SceneRenderState& sceneRenderState){
36 - GFXDevice& gfx = GFX_DEVICE;
37 - if(!gfx.isCurrentRenderStage(DISPLAY_STAGE)) return;
38 - SET_STATE_BLOCK(_dummy->getMaterial()->getRenderStateBlock(FINAL_STAGE));
39 - _dummy->renderInstance()->transform(node->getTransform());
40 -
41 - _dummy->onDraw(node, gfx.getRenderStage());
42 - _dummy->getMaterial()->getShaderInfo().getProgram()->bind();
43 - _dummy->getMaterial()->getShaderInfo().getProgram()->Uniform("material",_dummy->getMaterial()->getMaterialMatrix());
44 -
45 - gfx.renderInstance(_dummy->renderInstance());
46 - }
47 -
48 - /// Render dummy at target transform
49 - void Impostor::render(Transform* const transform, const SceneRenderState& sceneRenderState){
50 - GFXDevice& gfx = GFX_DEVICE;
51 - if(gfx.isCurrentRenderStage(DISPLAY_STAGE)) return;
52 - SET_STATE_BLOCK(_dummy->getMaterial()->getRenderStateBlock(FINAL_STAGE));
53 - _dummy->renderInstance()->transform(transform);
54 -
55 - _dummy->onDraw(nullptr, gfx.getRenderStage());
56 - _dummy->getMaterial()->getShaderInfo().getProgram()->bind();
57 - _dummy->getMaterial()->getShaderInfo().getProgram()->Uniform("material",_dummy->getMaterial()->getMaterialMatrix());
58 20
59 - gfx.renderInstance(_dummy->renderInstance());
60 21 }