Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wz4 : Normal Maps support for ribbons and ribbons2 #75

Merged
merged 1 commit into from
Sep 30, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions altona_wz4/altona/main/base/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ sVertexFormatHandle *sVertexFormatBasic;
sVertexFormatHandle *sVertexFormatStandard;
sVertexFormatHandle *sVertexFormatSingle;
sVertexFormatHandle *sVertexFormatDouble;
sVertexFormatHandle *sVertexFormatTangent;
sVertexFormatHandle *sVertexFormatTSpace;
sVertexFormatHandle *sVertexFormatTSpace4;
sVertexFormatHandle *sVertexFormatTSpace4_uv3;
Expand All @@ -81,6 +82,7 @@ sU32 DeclBasic[] = { sVF_POSITION,sVF_COLOR0,0 };
sU32 DeclStandard[] = { sVF_POSITION,sVF_NORMAL,sVF_UV0,0 };
sU32 DeclSingle[] = { sVF_POSITION,sVF_COLOR0,sVF_UV0,0 };
sU32 DeclDouble[] = { sVF_POSITION,sVF_COLOR0,sVF_UV0,sVF_UV1,0 };
sU32 DeclTangent[] = { sVF_POSITION,sVF_NORMAL,sVF_TANGENT|sVF_F3,sVF_UV0,0 };
sU32 DeclTSpace[] = { sVF_POSITION,sVF_NORMAL,sVF_TANGENT|sVF_F3,sVF_COLOR0,sVF_UV0,sVF_UV1,0 };
sU32 DeclTSpace4[] = { sVF_POSITION,sVF_NORMAL,sVF_TANGENT|sVF_F4,sVF_COLOR0,sVF_UV0,sVF_UV1,0 };
sU32 DeclTSpace4_uv3[] = { sVF_POSITION,sVF_NORMAL,sVF_TANGENT|sVF_F4,sVF_COLOR0,sVF_UV0,sVF_UV1,sVF_UV2,0 };
Expand All @@ -99,6 +101,7 @@ void sInitGfxCommon()
sVertexFormatStandard = sCreateVertexFormat(DeclStandard);
sVertexFormatSingle = sCreateVertexFormat(DeclSingle);
sVertexFormatDouble = sCreateVertexFormat(DeclDouble);
sVertexFormatTangent = sCreateVertexFormat(DeclTangent);
sVertexFormatTSpace = sCreateVertexFormat(DeclTSpace);
sVertexFormatTSpace4 = sCreateVertexFormat(DeclTSpace4);
sVertexFormatTSpace4_uv3 = sCreateVertexFormat(DeclTSpace4_uv3);
Expand Down
15 changes: 15 additions & 0 deletions altona_wz4/altona/main/base/graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ extern sVertexFormatHandle *sVertexFormatBasic; // pos, color0
extern sVertexFormatHandle *sVertexFormatStandard; // pos, normal, uv0
extern sVertexFormatHandle *sVertexFormatDouble; // pos, color0, uv0, uv1
extern sVertexFormatHandle *sVertexFormatSingle; // pos, color0, uv0
extern sVertexFormatHandle *sVertexFormatTangent; // pos, normal, tangent, uv0
extern sVertexFormatHandle *sVertexFormatTSpace; // pos, normal, tangent, color0, uv0, uv1
extern sVertexFormatHandle *sVertexFormatTSpace4; // pos, normal, tangent with bitangent sign, color0, uv0, uv1
extern sVertexFormatHandle *sVertexFormatTSpace4_uv3; // pos, normal, tangent with bitangent sign, color0, uv0, uv1, uv2
Expand Down Expand Up @@ -822,6 +823,20 @@ struct sVertexStandard // 32 bytes
static sVertexFormatHandle* VertexFormat() {return sVertexFormatStandard;}
};

struct sVertexTangent // 44 bytes
{
sF32 px,py,pz; // 3 position
sF32 nx,ny,nz; // 3 normal
sF32 tx,ty,tz; // 3 tangent
sF32 u0,v0; // 2 uv's
void Init(sF32 PX,sF32 PY,sF32 PZ,sF32 NX,sF32 NY,sF32 NZ,sF32 TX,sF32 TY,sF32 TZ,sF32 U0,sF32 V0) volatile
{ px=PX; py=PY; pz=PZ; nx=NX; ny=NY; nz=NZ; u0=U0; v0=V0; tx=ty=tz=0;}
void Init(const sVector31 &p,const sVector30 &n,sF32 U0,sF32 V0) volatile
{ px=p.x; py=p.y; pz=p.z; nx=n.x; ny=n.y; nz=n.z; u0=U0; v0=V0; tx=ty=tz=0; }

static sVertexFormatHandle* VertexFormat() {return sVertexFormatTangent;}
};

struct sVertexDouble // 32 bytes
{
sF32 px,py,pz; // 3 pos
Expand Down
20 changes: 16 additions & 4 deletions altona_wz4/wz4/wz4frlib/chaosfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void RNPrint::Render(Wz4RenderContext *ctx)
RNRibbons::RNRibbons()
{
Geo = new sGeometry;
Geo->Init(sGF_TRILIST|sGF_INDEX32,sVertexFormatStandard);
Geo->Init(sGF_TRILIST|sGF_INDEX32,sVertexFormatTangent);
Mtrl = new sSimpleMaterial;
Mtrl->Flags = sMTRL_CULLOFF|sMTRL_ZON|sMTRL_LIGHTING;
Mtrl->Prepare(sVertexFormatStandard);
Expand Down Expand Up @@ -244,7 +244,7 @@ void RNRibbons::Prepare(Wz4RenderContext *ctx)
sMatrix34 mat;
sF32 rx,ry,rz;
sVector31 p;
sVertexStandard *vp;
sVertexTangent *vp;

sInt max = Para.Steps;
const sF32 scale = 0.001f;
Expand All @@ -270,8 +270,14 @@ void RNRibbons::Prepare(Wz4RenderContext *ctx)

p += mat.k * Para.Forward;
vp->Init(p-mat.i*Para.Side,-mat.j,0.0f,i+(1/Para.Steps));
vp->tx = vp->nx * (vp->nx * p.x);
vp->ty = vp->ny * (vp->ny * p.y);
vp->tz = vp->nz * (vp->nz * p.z);
vp++;
vp->Init(p+mat.i*Para.Side,-mat.j,1.0f,i+(1/Para.Steps));
vp->tx = vp->nx * (vp->nx * p.x);
vp->ty = vp->ny * (vp->ny * p.y);
vp->tz = vp->nz * (vp->nz * p.z);
vp++;
}
}
Expand Down Expand Up @@ -338,7 +344,7 @@ void RNRibbons::Render(Wz4RenderContext *ctx)
RNRibbons2::RNRibbons2()
{
Geo = new sGeometry;
Geo->Init(sGF_TRILIST|sGF_INDEX32,sVertexFormatStandard);
Geo->Init(sGF_TRILIST|sGF_INDEX32,sVertexFormatTangent);
Mtrl = new sSimpleMaterial;
Mtrl->Flags = sMTRL_CULLOFF|sMTRL_ZON|sMTRL_LIGHTING;
Mtrl->Prepare(sVertexFormatStandard);
Expand Down Expand Up @@ -368,7 +374,7 @@ void RNRibbons2::Simulate(Wz4RenderContext *ctx)

void RNRibbons2::Prepare(Wz4RenderContext *ctx)
{
sVertexStandard *vp;
sVertexTangent *vp;
sVector31 pos;
sVector30 speed;
sVector30 camdir,norm;
Expand Down Expand Up @@ -431,7 +437,13 @@ void RNRibbons2::Prepare(Wz4RenderContext *ctx)
norm.Unit();

vp[0].Init(pos-d0,norm,0.0f,j+(1/Para.Length));
vp->tx = vp->nx * (vp->nx * pos.x);
vp->ty = vp->ny * (vp->ny * pos.y);
vp->tz = vp->nz * (vp->nz * pos.z);
vp[1].Init(pos+d0,norm,1.0f,j+(1/Para.Length));
vp->tx = vp->nx * (vp->nx * pos.x);
vp->ty = vp->ny * (vp->ny * pos.y);
vp->tz = vp->nz * (vp->nz * pos.z);
vp+=2;
}
}
Expand Down