@David W - Wow! Thanx! (Now I have to live up to that... LOL
)
@tparkin -
Quote: "1) Is there a reason you are not using shaders for texturing and lighting?"
1: Hardware Lighting + DBPro/GDK Fog work Together nicely.
2: Shaders Require Correct Normals Just as much as Hardware Lighting - It helps the routines that use the normals to decide something - like what texture or how much of one to blend etc.
3: Shaders + Global Fog Looks Terrible. Poly artifacts as terrain comes into view... YUCK.
Quote: "would be happy to share"
Most Awesome. I've actually got everything down except the normals. This particular routine is complicated by the fact that multiple objects, multiple limbs, and mulaiple faces per limb, all need to adjoin seamless. I've done it for the vertex positions, placement, ground height works, heightmap or USGS files (Loads them natively...the gridfloat format) and all is great.. Except the normals.
Quote: "2) Can you please explain your terminology of "welded vertices"."
Sure. Jason's terminology: Welded Vertices = Vertices that are shared by multiple polygons to conserve resources, and also simplfy making deformable terrain (By changing ONE VERTICE... Multiple Poly effected because they share EXACT same vert)
Quote: "I think you mean that the vertices are stuck in their x, y positions, but not z? (To be used as a DBPro matrix)"
Well kinda but my "Class" to control this mesh allows moving verts any direction on any axis. For basic, I just play with the Y or Heights of each vertice - but I hope to eventually be using it all
Example: Explosion? Deform and Burn terrain!
Maybe catch folliage on fire, smoke particles etc.
Quote: "It sounds like you can light one "chunk" of terrain fine, but when you put several "chunks" (perhaps they are limbs in your system) next to eachother, they don't line up in terms of lighting."
Well.. this function I've been working on ALL WEEKEND looks that way... and has sent me chasing my tail... How do I know I'm chasing my Tail? Because I got fed up with the three vertice x,y,z to FACE NORMAL calculation, and replaced it with something kinda odd.
I have a version of this function using My Sparky Based GroundHeight Function (offset so ray cast lands dead center in the polys) and then I query sparky's normal collision values, divide by two (because the ray shoots straight down and I suspect the normal is a combination of the ray + terrain hit)... anyways... this comes out PERFECT. The averaging, no seams.... I'm a bit perplexed by the whole affair now though.
Scope this out! This is using Sparky's to gerate the normals... I take that and divide by two.. then the rest of my function does everything perfectly - included the averaging I talked about etc.
so Somehow the code you gave me, in this situation is either not working, my vectors are screwy or something (I tried various vertex ordering and you mentioned the subtract order might be hosed, but I compared to someone elses code and the only thing that was different was the final normalizevector in the pvt_GetNormal function):
//----------------------------------------------------------------------------
void JGC_VMESH::pvt_GetNormal(void){
//----------------------------------------------------------------------------
// Now create v01 and v02
dbSubtractVector3( V1003->ID, V1001->ID, V1000->ID );
dbSubtractVector3( V1004->ID, V1002->ID, V1000->ID );
// Normalize v01 and v02
dbNormalizeVector3( V1003->ID, V1003->ID );
dbNormalizeVector3( V1004->ID, V1004->ID );
// Cross v01 and v02 to get the normal
dbCrossProductVector3( V1005->ID, V1003->ID, V1004->ID );
dbNormalizeVector3(V1005->ID,V1005->ID);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_VMESH::NormalizeMatrix3(void){
//----------------------------------------------------------------------------
int ox=0;int oz=0;int lx=0;int lz=0;int cx=0; int cz=0;
int xObj=0; int xLimb=0; int iVert=0; int ObjID=0;
// Per Vert:
// X,Y,Z Vert Normals (3*4 bytes)*2 Per Cell
int iBytesPerCell = ( 3 * 4 ) * 2;
int MemSize = this->TotalCells * iBytesPerCell;
int VertX1Norm=0;
int VertY1Norm=4;
int VertZ1Norm=8;
int VertX2Norm=12;
int VertY2Norm=16;
int VertZ2Norm=20;
MMB->Make(MemSize);
int Cell=0; int ModCX; int ModCZ;
// ONE CELL BLOCK = 2 Cells Across,and 2 Cells UP, Bottom Left is ROOT.
// The Numbers Represent WHAT CELL from this diagram the Variable CELL
// represents.
// ___________
// | /| |
// | / | |
// 3 | / | | 4
// |/___|___|
// | | /|
// | | / |
// | | / |
// 1 ____|/___| 2
int MPos=0;
float OffsOX;
float OffsOZ;
//JGC::ObjToy->Exclude_Set(false);
for(cz=0;cz<this->TotalCellsZ;cz++){
ModCZ=cz % 2;
for(cx=0;cx<this->TotalCellsX;cx++){
MPos = (cx+(cz*this->TotalCellsX))*iBytesPerCell;
// Find out WHAT Cell We Are Gonna Snag two Normals
// From. It Matters How We Gather the VERT Info later in the math.
ModCX = cx % 2;
if(ModCZ==0){
if(ModCX==0){
Cell=1;
}else{
Cell=2;
};
}else{
if(ModCX==0){
Cell=3;
}else{
Cell=4;
};
};
if((Cell==1)||(Cell==4)){
//This Method the Poly Divider resembles a BACKSLASH
//----
// First Poly of our Cell
this->Vert_Get(cx,cz, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1000->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
this->Vert_Get(cx+1,cz, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1001->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
this->Vert_Get(cx,cz+1, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1002->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
pvt_GetNormal();
MMB->Float_Set(MPos+VertX1Norm, dbXVector3(V1005->ID));
MMB->Float_Set(MPos+VertY1Norm, dbYVector3(V1005->ID));
MMB->Float_Set(MPos+VertZ1Norm, dbZVector3(V1005->ID));
// Second Poly of our Cell
this->Vert_Get(cx+1,cz, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1000->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
this->Vert_Get(cx,cz+1, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1001->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
this->Vert_Get(cx+1,cz+1, JMV_X+JMV_Y+JMV_Z);
dbSetVector3(
this->V1002->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
pvt_GetNormal();
MMB->Float_Set(MPos+VertX2Norm, dbXVector3(V1005->ID));
MMB->Float_Set(MPos+VertY2Norm, dbYVector3(V1005->ID));
MMB->Float_Set(MPos+VertZ2Norm, dbZVector3(V1005->ID));
}else{
//This Method the Poly Divider resembles a Forward Slash
//----
// First Poly of our Cell
this->Vert_Get(cx,cz, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1000->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
this->Vert_Get(cx+1,cz+1, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1001->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
this->Vert_Get(cx+1,cz, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1002->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
pvt_GetNormal();
MMB->Float_Set(MPos+VertX1Norm, dbXVector3(V1005->ID));
MMB->Float_Set(MPos+VertY1Norm, dbYVector3(V1005->ID));
MMB->Float_Set(MPos+VertZ1Norm, dbZVector3(V1005->ID));
// Second Poly of our Cell
this->Vert_Get(cx,cz, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1000->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
this->Vert_Get(cx,cz+1, JMV_X+JMV_Y+JMV_Z);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1001->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
this->Vert_Get(cx+1,cz+1, JMV_X+JMV_Y+JMV_Z);
dbSetVector3(
this->V1002->ID,
this->Vert->Pos->X,
this->Vert->Pos->Y,
this->Vert->Pos->Z
);
pvt_GetNormal();
MMB->Float_Set(MPos+VertX2Norm, dbXVector3(V1005->ID));
MMB->Float_Set(MPos+VertY2Norm, dbYVector3(V1005->ID));
MMB->Float_Set(MPos+VertZ2Norm, dbZVector3(V1005->ID));
};
};
};
int iDivideBy;
float nX; float nY; float nZ;// Normals' Accumulators.
for(cz=0;cz<this->TotalCellsZ;cz++){
ModCZ=cz % 2;
for(cx=0;cx<this->TotalCellsX;cx++){
// To Be incremented in code to correct #of normals To Average together.
iDivideBy=0;nX=0.0f; nY=0.0f; nZ=0.0f;
// Find out WHAT Cell We Are one.
// From. It Matters How We Gather the VERT Info later in the math.
ModCX = cx % 2;
if(ModCZ==0){
if(ModCX==0){
Cell=1;
}else{
Cell=2;
};
}else{
if(ModCX==0){
Cell=3;
}else{
Cell=4;
};
};
if((Cell==1)||(Cell==4)){
// MAXIMUM is FOUR NORMALS to Average Together
// so We Are adding, averaging, then setting the SHARED Vert normal
// with adjacent POLY Normal we gathered above and stored in memblock.
// (info sharing the vert.)
//---main
iDivideBy+=1;
MPos = (cx+(cz*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
//West
if(cx>0){
iDivideBy+=1;
MPos = ((cx-1)+((cz)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
};
//South
if(cz>0){
iDivideBy+=1;
MPos = ((cx)+((cz-1)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
//South West
if((cx>0) && (cz>0)){
iDivideBy+=1;
MPos = ((cx-1)+((cz-1)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
}else{
// MAXIMUM is EIGHT NORMALS to Average Together
// MAIN PAIR
iDivideBy+=1;
MPos = (cx+(cz*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
iDivideBy+=1;
//MPos = (cx+(cz*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
//WEST PAIR
if(cx>0){
iDivideBy+=1;
MPos = ((cx-1)+((cz)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
iDivideBy+=1;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
//South
if(cz>0){
iDivideBy+=1;
MPos = ((cx)+((cz-1)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
iDivideBy+=1;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
//SouthWest
if((cx>0)&&(cz>0)){
iDivideBy+=1;
MPos = ((cx-1)+((cz-1)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
iDivideBy+=1;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
};
this->Vert->Normal->X=nX/iDivideBy;
this->Vert->Normal->Y=nY/iDivideBy;
this->Vert->Normal->Z=nZ/iDivideBy;
this->Vert_Set(cx,cz, JMV_NX+JMV_NY+JMV_NZ);
};
};
MMB->Delete();
};
//----------------------------------------------------------------------------
Looks MESSED UP.... But this... using Ground Height functions, Raycasting Collision normals / 2 - Works Gorgeous... I'll attach a Pic.
//----------------------------------------------------------------------------
void JGC_VMESH::NormalizeMatrix2(void){
//----------------------------------------------------------------------------
int ox=0;int oz=0;int lx=0;int lz=0;int cx=0; int cz=0;
int xObj=0; int xLimb=0; int iVert=0; int ObjID=0;
// Per Vert:
// X,Y,Z Vert Normals (3*4 bytes)*2 Per Cell
int iBytesPerCell = ( 3 * 4 ) * 2;
int MemSize = this->TotalCells * iBytesPerCell;
int VertX1Norm=0;
int VertY1Norm=4;
int VertZ1Norm=8;
int VertX2Norm=12;
int VertY2Norm=16;
int VertZ2Norm=20;
MMB->Make(MemSize);
int Cell=0; int ModCX; int ModCZ;
// ONE CELL BLOCK = 2 Cells Across,and 2 Cells UP, Bottom Left is ROOT.
// The Numbers Represent WHAT CELL from this diagram the Variable CELL
// represents.
// ___________
// | /| |
// | / | |
// 3 | / | | 4
// |/___|___|
// | | /|
// | | / |
// | | / |
// 1 ____|/___| 2
int MPos=0;
float OffsOX;
float OffsOZ;
//JGC::ObjToy->Exclude_Set(false);
for(cz=0;cz<this->TotalCellsZ;cz++){
ModCZ=cz % 2;
for(cx=0;cx<this->TotalCellsX;cx++){
MPos = (cx+(cz*this->TotalCellsX))*iBytesPerCell;
// Find out WHAT Cell We Are Gonna Snag two Normals
// From. It Matters How We Gather the VERT Info later in the math.
ModCX = cx % 2;
if(ModCZ==0){
if(ModCX==0){
Cell=1;
}else{
Cell=2;
};
}else{
if(ModCX==0){
Cell=3;
}else{
Cell=4;
};
};
if((Cell==1)||(Cell==4)){
//This Method the Poly Divider resembles a BACKSLASH
//----
// First Poly of our Cell
this->GroundHeight(
(cx*this->LimbCellSizeX)+(this->LimbCellSizeX/4),
(cz*this->LimbCellSizeZ)+(this->LimbCellSizeZ/4)
);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1005->ID,
SC_GetCollisionNormalX()/2,
SC_GetCollisionNormalY()/2,
SC_GetCollisionNormalZ()/2
);
MMB->Float_Set(MPos+VertX1Norm, dbXVector3(V1005->ID));
MMB->Float_Set(MPos+VertY1Norm, dbYVector3(V1005->ID));
MMB->Float_Set(MPos+VertZ1Norm, dbZVector3(V1005->ID));
// Second Poly of our Cell
this->GroundHeight(
(cx*this->LimbCellSizeX)+this->LimbCellSizeX-(this->LimbCellSizeX/4),
(cz*this->LimbCellSizeZ)+this->LimbCellSizeZ-(this->LimbCellSizeZ/4)
);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1005->ID,
SC_GetCollisionNormalX()/2,
SC_GetCollisionNormalY()/2,
SC_GetCollisionNormalZ()/2
);
MMB->Float_Set(MPos+VertX2Norm, dbXVector3(V1005->ID));
MMB->Float_Set(MPos+VertY2Norm, dbYVector3(V1005->ID));
MMB->Float_Set(MPos+VertZ2Norm, dbZVector3(V1005->ID));
}else{
//This Method the Poly Divider resembles a Forward Slash
//----
//MMB->Float_Set(MPos+VertX1Norm, 0);
//MMB->Float_Set(MPos+VertY1Norm, 1);
//MMB->Float_Set(MPos+VertZ1Norm, 0);
//MMB->Float_Set(MPos+VertX2Norm, 0);
//MMB->Float_Set(MPos+VertY2Norm, -1);
//MMB->Float_Set(MPos+VertZ2Norm, 0);
this->GroundHeight(
(cx*this->LimbCellSizeX)+(this->LimbCellSizeX/2),
(cz*this->LimbCellSizeZ)+(this->LimbCellSizeZ/4)
);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1005->ID,
SC_GetCollisionNormalX()/2,
SC_GetCollisionNormalY()/2,
SC_GetCollisionNormalZ()/2
);
MMB->Float_Set(MPos+VertX1Norm, dbXVector3(V1005->ID));
MMB->Float_Set(MPos+VertY1Norm, dbYVector3(V1005->ID));
MMB->Float_Set(MPos+VertZ1Norm, dbZVector3(V1005->ID));
// Second Poly of our Cell
this->GroundHeight(
(cx*this->LimbCellSizeX)+(this->LimbCellSizeX/4),
(cz*this->LimbCellSizeZ)+(this->LimbCellSizeZ/2)
);
//JGC::ObjToy->Position(this->Vert->Pos->X,this->Vert->Pos->Y,this->Vert->Pos->Z);dbSync();dbSync();
dbSetVector3(
this->V1005->ID,
SC_GetCollisionNormalX()/2,
SC_GetCollisionNormalY()/2,
SC_GetCollisionNormalZ()/2
);
MMB->Float_Set(MPos+VertX2Norm, dbXVector3(V1005->ID));
MMB->Float_Set(MPos+VertY2Norm, dbYVector3(V1005->ID));
MMB->Float_Set(MPos+VertZ2Norm, dbZVector3(V1005->ID));
};
};
};
int iDivideBy;
float nX; float nY; float nZ;// Normals' Accumulators.
for(cz=0;cz<this->TotalCellsZ;cz++){
ModCZ=cz % 2;
for(cx=0;cx<this->TotalCellsX;cx++){
// To Be incremented in code to correct #of normals To Average together.
iDivideBy=0;nX=0.0f; nY=0.0f; nZ=0.0f;
// Find out WHAT Cell We Are one.
// From. It Matters How We Gather the VERT Info later in the math.
ModCX = cx % 2;
if(ModCZ==0){
if(ModCX==0){
Cell=1;
}else{
Cell=2;
};
}else{
if(ModCX==0){
Cell=3;
}else{
Cell=4;
};
};
if((Cell==1)||(Cell==4)){
// MAXIMUM is FOUR NORMALS to Average Together
// so We Are adding, averaging, then setting the SHARED Vert normal
// with adjacent POLY Normal we gathered above and stored in memblock.
// (info sharing the vert.)
//---main
iDivideBy+=1;
MPos = (cx+(cz*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
//West
if(cx>0){
iDivideBy+=1;
MPos = ((cx-1)+((cz)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
};
//South
if(cz>0){
iDivideBy+=1;
MPos = ((cx)+((cz-1)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
//South West
if((cx>0) && (cz>0)){
iDivideBy+=1;
MPos = ((cx-1)+((cz-1)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
}else{
// MAXIMUM is EIGHT NORMALS to Average Together
// MAIN PAIR
iDivideBy+=1;
MPos = (cx+(cz*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
iDivideBy+=1;
//MPos = (cx+(cz*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
//WEST PAIR
if(cx>0){
iDivideBy+=1;
MPos = ((cx-1)+((cz)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
iDivideBy+=1;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
//South
if(cz>0){
iDivideBy+=1;
MPos = ((cx)+((cz-1)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
iDivideBy+=1;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
//SouthWest
if((cx>0)&&(cz>0)){
iDivideBy+=1;
MPos = ((cx-1)+((cz-1)*this->TotalCellsX))*iBytesPerCell;
nX+=MMB->Float_Get(MPos + VertX1Norm);
nY+=MMB->Float_Get(MPos + VertY1Norm);
nZ+=MMB->Float_Get(MPos + VertZ1Norm);
iDivideBy+=1;
nX+=MMB->Float_Get(MPos + VertX2Norm);
nY+=MMB->Float_Get(MPos + VertY2Norm);
nZ+=MMB->Float_Get(MPos + VertZ2Norm);
};
};
this->Vert->Normal->X=nX/iDivideBy;
this->Vert->Normal->Y=nY/iDivideBy;
this->Vert->Normal->Z=nZ/iDivideBy;
this->Vert_Set(cx,cz, JMV_NX+JMV_NY+JMV_NZ);
};
};
MMB->Delete();
};
//----------------------------------------------------------------------------
Pic Attached.
[edit]
If you looked at second code snip before this edit - you were looking at the same snip pased 2 times... sorry... I was IM'ing with another developer during this post and lost my train of thought... My Apologies. Especially if you were gawking at the code for awhile perplexed![/edit]
[edit2]Concerning Shaders - Did I mention shaders drop my frame rates as much as 50% or more? Thats another reason I'm not struggling to get a shader based scene going. Wouldn't be playable. I'll use the hardcoded FFP shader for now that GDK uses.[/edit2]