| 1 |
|
| 2 |
typedef unsigned char Bytecxx . . $ Byte#; |
| 3 |
|
| 4 |
#include <math.h> |
| •5 |
#include <stdio.h> |
| 6 |
|
| 7 |
#include <vector> |
| 8 |
#include <vcg/space/point3.h>cxx . . $ `<file>/vcg/vcg/space/point3.h`/ |
| 9 |
|
| 10 |
using namespace vcg; |
| 11 |
using namespace std; |
| 12 |
|
| 13 |
#include "CubeMapSamp.h"cxx . . $ `<file>/src/CubeMapSamp.h`/ |
| 14 |
#include "OctaMapSamp.h"cxx . . $ `<file>/src/OctaMapSamp.h`/ |
| 15 |
|
| 16 |
#include "Mol.h"cxx . . $ `<file>/src/Mol.h`/ |
| 17 |
#include "AO.h"cxx . . $ `<file>/src/AO.h`/ |
| 18 |
|
| 19 |
const float inftycxx . . $ infty.=1000; |
| 20 |
|
| 21 |
vectorcxx . . $ std/vector#<bool> tmpboolcxx . . $ tmpbool.(32*32,false); |
| 22 |
|
| 23 |
void AOcxx . . $ AO#::PrintBuffercxx . . $ AO#PrintBuffer(49f6e7a06ebc5aa8).(){ |
| 24 |
int target=32; |
| 25 |
int k=0; |
| 26 |
for (int y=0; y<target; y++){ |
| 27 |
for (int x=0; x<target; x++) { |
| 28 |
double b=bufcxx . . $ AO#buf.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k]; |
| 29 |
if (b==inftycxx . . $ infty.) |
| 30 |
printf("%2s","*"); |
| 31 |
else |
| 32 |
printf("%2s","-"); |
| 33 |
if (tmpboolcxx . . $ tmpbool.[cxx . . $ std/vector#`operator[]`(1450282ea0befc17).k]) printf("'"); else printf(" "); |
| 34 |
|
| 35 |
k++; |
| 36 |
// printf("%7.3f ",buf[k++]); |
| 37 |
} |
| 38 |
printf("\n"); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
void AOcxx . . $ AO#::RenderSpherecxx . . $ AO#RenderSphere(7e9a355db6148521).(float cx, float cy, float cz, float rad){ |
| 43 |
printf("Rendering %f %f %f %f...\n",cx,cy,cz,rad); |
| 44 |
/*cx*=bufscale; |
| 45 |
cy*=bufscale; |
| 46 |
rad*=bufscale;*/ |
| 47 |
int cxi=int(cx); |
| 48 |
int cyi=int(cy); |
| 49 |
|
| 50 |
for (int y=-(int)rad; y<=(int)rad; y++) |
| 51 |
for (int x=-(int)rad; x<=(int)rad; x++) |
| 52 |
{ |
| 53 |
float tmp=(-x*x-y*y+rad*rad); |
| 54 |
if (tmp>0) { |
| 55 |
tmp=sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(tmp)+cz; |
| 56 |
int i=indexcxx . . $ AO#index(9b79fb6aee4c0440).(x+cxi,y+cyi); |
| 57 |
if (bufcxx . . $ AO#buf.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]>tmp) bufcxx . . $ AO#buf.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]=tmp; |
| 58 |
//buf[i]=0; |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
void AOcxx . . $ AO#::CheckAtomcxx . . $ AO#CheckAtom(f32a922b976c2f37).(QAtomcxx . . $ QAtom# &a){ |
| 65 |
|
| 66 |
int n=a.scxx . . $ QAtom#s..nsampcxx . . $ OctaMapSamp#nsamp(b126dc7c1de90089).(); |
| 67 |
for (int i=0; i<n; i++) { |
| 68 |
Point3fcxx . . $ vcg/Point3f# f=a.scxx . . $ QAtom#s..dirrotcxx . . $ OctaMapSamp#dirrot.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).a.trrcxx . . $ QAtom#trr.; |
| 69 |
|
| 70 |
if (f[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2]>0) { |
| 71 |
|
| 72 |
|
| 73 |
int bx=(int) (a.trpcxx . . $ QAtom#trp.[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).0]+f[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).0]); |
| 74 |
int by=(int) (a.trpcxx . . $ QAtom#trp.[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1]+f[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1]); |
| 75 |
tmpboolcxx . . $ tmpbool.[cxx . . $ std/vector#`operator[]`(1450282ea0befc17).indexcxx . . $ AO#index(9b79fb6aee4c0440).(bx,by)]=cxx . . $ std/_Bit_reference#`operator=`(2a6c206c8bbf32aa).true;; |
| 76 |
if (bufcxx . . $ AO#buf.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).indexcxx . . $ AO#index(9b79fb6aee4c0440).(bx,by)] == inftycxx . . $ infty. ) { |
| 77 |
a.scxx . . $ QAtom#s..sumcxx . . $ OctaMapSamp#sum.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]+=f[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2]; |
| 78 |
}; |
| 79 |
a.scxx . . $ QAtom#s..divcxx . . $ OctaMapSamp#div.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]+=f[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2]; |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
AOcxx . . $ AO#::AOcxx . . $ AO#AO(72d8b97c8152dd25).( Point3fcxx . . $ vcg/Point3f# _dir, Molcxx . . $ Mol# &m) { |
| 86 |
|
| 87 |
dircxx . . $ AO#dir.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e)._dir.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 88 |
|
| 89 |
// orthonormal basis |
| 90 |
Point3fcxx . . $ vcg/Point3f# axcxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,aycxx . . $ vcg/Point3#Point3(49f6e7a06ebc5aa8).,az=dircxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).; |
| 91 |
ax=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).az^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,0,0); |
| 92 |
if (ax.SquaredNormcxx . . $ vcg/Point3#SquaredNorm(8f5363d873dd4781).()<0.1) ax=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).az^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,1,0); |
| 93 |
ax=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).ax.Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 94 |
ay=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).(az^cxx . . $ vcg/Point3#`operator^`(df3b8fd47e21bd0c).ax).Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).(); |
| 95 |
|
| 96 |
// project... |
| 97 |
m.Transformcxx . . $ Mol#Transform(5d15d4e2ac4f9dae).(ax,ay,az); |
| 98 |
|
| 99 |
|
| 100 |
int target=32; // |
| 101 |
bufxcxx . . $ AO#bufx.=bufycxx . . $ AO#bufy.=target; |
| 102 |
float bufscalex=target/(m.tx1cxx . . $ Mol#tx1.-m.tx0cxx . . $ Mol#tx0.); |
| 103 |
float bufscaley=target/(m.ty1cxx . . $ Mol#ty1.-m.ty0cxx . . $ Mol#ty0.); |
| 104 |
bufscalecxx . . $ AO#bufscale.=(bufscalex<bufscaley)?bufscalex:bufscaley; |
| 105 |
|
| 106 |
m.ScaleTranslcxx . . $ Mol#ScaleTransl(9364e6e7bff7660).(bufscalecxx . . $ AO#bufscale.); |
| 107 |
CubeMapSampcxx . . $ CubeMapSamp#::Transformcxx . . $ CubeMapSamp#Transform(d1992f7955acee33).(axcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,aycxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).,azcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).); |
| 108 |
|
| 109 |
printf("Scale=%f\n",bufscalecxx . . $ AO#bufscale.); |
| 110 |
|
| 111 |
bufcxx . . $ AO#buf..resizecxx . . $ std/vector#resize(3804226c8c0acbc3).(target*target,inftycxx . . $ infty.); |
| 112 |
|
| •113 |
for (int i=0; i < (int)m.atomcxx . . $ Mol#atom..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()-1; i++) { |
| 114 |
QAtomcxx . . $ QAtom# &a=m.atomcxx . . $ Mol#atom.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]; |
| 115 |
CheckAtomcxx . . $ AO#CheckAtom(f32a922b976c2f37).(a); |
| 116 |
RenderSpherecxx . . $ AO#RenderSphere(7e9a355db6148521).( a.trpcxx . . $ QAtom#trp.[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).0], a.trpcxx . . $ QAtom#trp.[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1], a.trpcxx . . $ QAtom#trp.[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2], a.trrcxx . . $ QAtom#trr. ); |
| 117 |
PrintBuffercxx . . $ AO#PrintBuffer(49f6e7a06ebc5aa8).(); |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
} |