source: GTP/trunk/Lib/Vis/Preprocessing/src/RenderSampler.cpp @ 897

Revision 897, 1.0 KB checked in by mattausch, 19 years ago (diff)

updated to ogre 1.2

  • Property svn:executable set to *
Line 
1#include "Environment.h"
2#include "RenderSampler.h"
3#include "GlRenderer.h"
4
5namespace GtpVisibilityPreprocessor {
6
7
8RenderSampler::RenderSampler():Preprocessor()
9{
10  environment->GetIntValue("RenderSampler.samples", mSamples);
11  cout<<"mspamples"<<mSamples<<endl;
12}
13
14bool
15RenderSampler::ComputeVisibility()
16{
17 
18  cout<<"HERE I WAS!\n";
19
20  vector<RenderCostSample> samples;
21 
22  if (renderer)
23        renderer->SampleRenderCost(
24                                                           mSamples,
25                                                           samples
26                                                           );
27
28
29  // compute histogram from the samples
30  int bins = 100;
31  int maxPvs = 0;
32
33  vector<int> histogram(bins);
34 
35  int i;
36  for (i = 0; i < bins; i++)
37        histogram[i] = 0;
38 
39  for (i = 0; i < mSamples; i++) {
40        if (samples[i].mVisibleObjects > maxPvs)
41          maxPvs = samples[i].mVisibleObjects;
42  }
43 
44  for (i = 0; i < mSamples; i++) {
45        int bin = (samples[i].mVisibleObjects*bins)/maxPvs;
46        histogram[bin]++;
47  }
48
49  // output the histogram
50  for (i = 0; i < bins; i++) {
51        cout<<histogram[i]<<endl;
52  }
53
54 
55  return true;
56}
57
58}
Note: See TracBrowser for help on using the repository browser.