#include "stdafx.h" #define BuildTangentSpace_GUID CKGUID(0x1fb64cad,0x283e01bb) //----------------------------------------------------------------------------- int BuildTangentSpace(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKMesh* mesh = (CKMesh*)beh->GetTarget(); if( !mesh ) return CKBR_PARAMETERERROR; CKBOOL remove = FALSE; beh->GetInputParameter(0)->GetValue( &remove ); if( remove ){ mesh->SetFlags(mesh->GetFlags() & ~VXMESH_GENTANSPACE); } else { mesh->SetFlags(mesh->GetFlags() | VXMESH_GENTANSPACE); } beh->ActivateOutput(0); return CKBR_OK; } //----------------------------------------------------------------------------- CKERROR CreateBuildTangentSpaceProto(CKBehaviorPrototype **pproto) { CKBehaviorPrototype *proto = CreateCKBehaviorPrototype("Build Tangent Space"); if(!proto) return CKERR_OUTOFMEMORY; proto->DeclareInput("In"); proto->DeclareOutput("Out"); proto->DeclareInParameter( "Remove", CKPGUID_BOOL, "FALSE" ); proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL); proto->SetFunction(BuildTangentSpace); proto->SetBehaviorFlags( (CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_TARGETABLE) ); *pproto = proto; return CK_OK; } //----------------------------------------------------------------------------- CKObjectDeclaration *FillBehaviorBuildTangentSpace() { CKObjectDeclaration *od = CreateCKObjectDeclaration("Build Tangent Space"); od->SetDescription("Ask the mesh to build (or remove) tangent space (used for bump mapping for example)."); od->SetCategory("Shaders/General"); od->SetType(CKDLL_BEHAVIORPROTOTYPE); od->SetGuid(BuildTangentSpace_GUID); od->SetAuthorGuid(VIRTOOLS_GUID); od->SetAuthorName("Virtools"); od->SetVersion(0x00010000); od->SetCreationFunction(CreateBuildTangentSpaceProto); od->SetCompatibleClassId(CKCID_MESH); return od; }