#if _MSC_VER >= 1700
#pragma warning( disable: 4005 )
#endif
#include <maya/MPxLocatorNode.h>
#include <maya/MString.h>
#include <maya/MDagPath.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MVector.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MColor.h>
#include <maya/M3dView.h>
#include <maya/MFnPlugin.h>
#include <maya/MDistance.h>
#include <maya/MMatrix.h>
#include <maya/MFnUnitAttribute.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFileObject.h>
#include <maya/MHWGeometry.h>
#include <maya/MEventMessage.h>
#include <maya/MEvaluationNode.h>
#include <maya/MDrawRegistry.h>
#include <maya/MPxDrawOverride.h>
#include <maya/MUserData.h>
#include <maya/MDrawContext.h>
#include <maya/MSelectionContext.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionList.h>
#include <maya/MViewport2Renderer.h>
#include <maya/MHWGeometryUtilities.h>
#include <maya/MStateManager.h>
#include <maya/MShaderManager.h>
#include <maya/MRenderTargetManager.h>
#include <maya/MAnimControl.h>
#include <maya/MFnCamera.h>
#include <assert.h>
#include <stdlib.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <d3d11.h>
#if _MSC_VER < 1700
#include <d3dx11.h>
#include <xnamath.h>
#else
#include <dxgi.h>
#include <DirectXMath.h>
using namespace DirectX;
#endif
#include <d3dcompiler.h>
#ifndef D3DCOMPILE_ENABLE_STRICTNESS
#define D3DCOMPILE_ENABLE_STRICTNESS D3D10_SHADER_ENABLE_STRICTNESS
#define D3DCOMPILE_DEBUG D3D10_SHADER_DEBUG
#endif
#endif //_WIN32
#if defined (OSMac_)
#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
#include <OpenGL/gl3.h>
#endif // OSMac_
static float sole[][3] = { { 0.00f, 0.0f, -0.70f },
{ 0.04f, 0.0f, -0.69f },
{ 0.09f, 0.0f, -0.65f },
{ 0.13f, 0.0f, -0.61f },
{ 0.16f, 0.0f, -0.54f },
{ 0.17f, 0.0f, -0.46f },
{ 0.17f, 0.0f, -0.35f },
{ 0.16f, 0.0f, -0.25f },
{ 0.15f, 0.0f, -0.14f },
{ 0.13f, 0.0f, 0.00f },
{ 0.00f, 0.0f, 0.00f },
{ -0.13f, 0.0f, 0.00f },
{ -0.15f, 0.0f, -0.14f },
{ -0.16f, 0.0f, -0.25f },
{ -0.17f, 0.0f, -0.35f },
{ -0.17f, 0.0f, -0.46f },
{ -0.16f, 0.0f, -0.54f },
{ -0.13f, 0.0f, -0.61f },
{ -0.09f, 0.0f, -0.65f },
{ -0.04f, 0.0f, -0.69f },
{ -0.00f, 0.0f, -0.70f } };
#ifdef _WIN32
static float soleNorm[][3] = { { 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f } };
#endif
static float heel[][3] = { { 0.00f, 0.0f, 0.06f },
{ 0.13f, 0.0f, 0.06f },
{ 0.14f, 0.0f, 0.15f },
{ 0.14f, 0.0f, 0.21f },
{ 0.13f, 0.0f, 0.25f },
{ 0.11f, 0.0f, 0.28f },
{ 0.09f, 0.0f, 0.29f },
{ 0.04f, 0.0f, 0.30f },
{ 0.00f, 0.0f, 0.30f },
{ -0.04f, 0.0f, 0.30f },
{ -0.09f, 0.0f, 0.29f },
{ -0.11f, 0.0f, 0.28f },
{ -0.13f, 0.0f, 0.25f },
{ -0.14f, 0.0f, 0.21f },
{ -0.14f, 0.0f, 0.15f },
{ -0.13f, 0.0f, 0.06f },
{ -0.00f, 0.0f, 0.06f } };
#ifdef _WIN32
static float heelNorm[][3] = { { 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f },
{ 0.00f, 1.0f, 0.00f } };
#endif
static int soleCount = 21;
static int heelCount = 17;
static unsigned short soleWireIndices[] =
{
0, 1,
1, 2,
2, 3,
3, 4,
4, 5,
5, 6,
6, 7,
7, 8,
8, 9,
9, 10,
10, 11,
11, 12,
12, 13,
13, 14,
14, 15,
15, 16,
16, 17,
17, 18,
18, 19,
19, 20
};
static unsigned short heelWireIndices[] =
{
0, 1,
1, 2,
2, 3,
3, 4,
4, 5,
5, 6,
6, 7,
7, 8,
8, 9,
9, 10,
10, 11,
11, 12,
12, 13,
13, 14,
14, 15,
15, 16
};
static unsigned short soleShadedIndices[] =
{
0, 1, 2,
0, 2, 3,
0, 3, 4,
0, 4, 5,
0, 5, 6,
0, 6, 7,
0, 7, 8,
0, 8, 9,
0, 9, 10,
0, 10, 11,
0, 11, 12,
0, 12, 13,
0, 13, 14,
0, 14, 15,
0, 15, 16,
0, 16, 17,
0, 17, 18,
0, 18, 19,
0, 19, 20
};
static unsigned short heelShadedIndices[] =
{
0, 1, 2,
0, 2, 3,
0, 3, 4,
0, 4, 5,
0, 5, 6,
0, 6, 7,
0, 7, 8,
0, 8, 9,
0, 9, 10,
0, 10, 11,
0, 11, 12,
0, 12, 13,
0, 13, 14,
0, 14, 15,
0, 15, 16
};
static float bbData[][3] = {
{ -0.18f, 0.f, -0.71f},
{ 0.18f, 0.f, -0.71f},
{ 0.18f, 0.f, 0.31f},
{ -0.18f, 0.f, 0.31f},
{ -0.18f, 0.f, -0.71f},
{ 0.18f, 0.f, -0.71f},
{ 0.18f, 0.f, 0.31f},
{ -0.18f, 0.f, 0.31f}};
static unsigned short bbWireIndices[] =
{
0,1,
1,2,
2,3,
3,0,
4,5,
5,6,
6,7,
7,4,
0,4,
1,5,
2,6,
3,7
};
{
public:
rawfootPrint();
~rawfootPrint() override;
bool isBounded() const override;
static void * creator();
public:
static MString drawDbClassification;
};
MObject rawfootPrint::transparencySort;
MObject rawfootPrint::transparency;
MTypeId rawfootPrint::id( 0x0008002D );
MString rawfootPrint::drawDbClassification(
"drawdb/geometry/rawfootPrint");
MString rawfootPrint::drawRegistrantId(
"RawFootprintNodePlugin");
rawfootPrint::rawfootPrint() {}
rawfootPrint::~rawfootPrint() {}
{
return MS::kUnknownParameter;
}
{
MPlug plug( thisNode, size );
plug.getValue( sizeVal );
{
glPushAttrib( GL_CURRENT_BIT );
} else {
}
glBegin( GL_TRIANGLE_FAN );
int i;
int last = soleCount - 1;
for ( i = 0; i < last; ++i ) {
glVertex3f( sole[i][0] * multiplier,
sole[i][1] * multiplier,
sole[i][2] * multiplier );
}
glEnd();
glBegin( GL_TRIANGLE_FAN );
last = heelCount - 1;
for ( i = 0; i < last; ++i ) {
glVertex3f( heel[i][0] * multiplier,
heel[i][1] * multiplier,
heel[i][2] * multiplier );
}
glEnd();
glPopAttrib();
}
glBegin( GL_LINES );
int i;
int last = soleCount - 1;
for ( i = 0; i < last; ++i ) {
glVertex3f( sole[i][0] * multiplier,
sole[i][1] * multiplier,
sole[i][2] * multiplier );
glVertex3f( sole[i+1][0] * multiplier,
sole[i+1][1] * multiplier,
sole[i+1][2] * multiplier );
}
last = heelCount - 1;
for ( i = 0; i < last; ++i ) {
glVertex3f( heel[i][0] * multiplier,
heel[i][1] * multiplier,
heel[i][2] * multiplier );
glVertex3f( heel[i+1][0] * multiplier,
heel[i+1][1] * multiplier,
heel[i+1][2] * multiplier );
}
glEnd();
}
bool rawfootPrint::isBounded() const
{
return true;
}
{
MPlug plug( thisNode, size );
plug.getValue( sizeVal );
MPoint corner1( -0.17, 0.0, -0.7 );
MPoint corner2( 0.17, 0.0, 0.3 );
corner1 = corner1 * multiplier;
corner2 = corner2 * multiplier;
}
MStatus rawfootPrint::preEvaluation(
{
{
if ((evaluationNode.
dirtyPlugExists(transparencySort, &status) && status) ||
{
}
}
}
void* rawfootPrint::creator()
{
return new rawfootPrint();
}
{
public:
, mBlendState(NULL)
{
mLastFrameStamp = 0;
}
~RawFootPrintData() override { mBlendState = NULL; }
float fMultiplier;
float fColor[4];
bool fCustomBoxDraw;
MUint64 mLastFrameStamp;
};
class RawFootPrintDrawAgent
{
public:
RawFootPrintDrawAgent() : mDrawContext(NULL), mShaderOverride(NULL) {}
virtual ~RawFootPrintDrawAgent(){}
virtual void drawShaded() = 0;
virtual void drawBoundingBox() = 0;
virtual void drawWireframe() = 0;
mDrawContext = &context;
mShaderOverride = passShaderOverride;
const bool debugShader = false;
if (mShaderOverride)
{
if (debugShader)
{
mShaderOverride->requiredVertexBuffers(bufferList);
for (
int i=0; i<bufferList.
length(); i++)
{
printf("Buffer[%d][name=%s]\n", i,
printf(
"[dataType = %d\n", desc.
dataType());
printf(
"[dimension = %d\n", desc.
dimension());
printf(
"[offset = %d\n", desc.
offset());
printf(
"[stride = %d\n", desc.
stride());
}
}
mShaderOverride->bind( *mDrawContext );
mShaderOverride->updateParameters( *mDrawContext );
mShaderOverride->activatePass( *mDrawContext, 0 );
}
}
virtual void endDraw() {
if (mShaderOverride) {
mShaderOverride->unbind( *mDrawContext );
}
mDrawContext = NULL;
mShaderOverride = NULL;
}
void setColor(
const MColor& color){
mColor = color;
}
protected:
};
class RawFootPrintDrawAgentGL : public RawFootPrintDrawAgent
{
public:
static RawFootPrintDrawAgentGL& getDrawAgent(){
static RawFootPrintDrawAgentGL obj;
return obj;
}
void drawShaded() override;
void drawBoundingBox() override;
void drawWireframe() override;
void endDraw() override;
mWorldViewMatrix =
mUsePickMatrix = false;
if (selContext) {
unsigned int sel_x, sel_y, sel_width, sel_height;
selContext->
selectRect(sel_x, sel_y, sel_width, sel_height);
int scr_x, scr_y, scr_width, scr_height;
mPickParams[0] = sel_x + sel_width / 2;
mPickParams[1] = sel_y + sel_height / 2;
mPickParams[2] = sel_width;
mPickParams[3] = sel_height;
mPickViewport[0] = scr_x;
mPickViewport[1] = scr_y;
mPickViewport[2] = scr_width;
mPickViewport[3] = scr_height;
mUsePickMatrix = true;
}
}
private:
RawFootPrintDrawAgentGL(){}
~RawFootPrintDrawAgentGL() override{}
RawFootPrintDrawAgentGL( const RawFootPrintDrawAgentGL& v ){}
RawFootPrintDrawAgentGL operator = (const RawFootPrintDrawAgentGL& v){ return *this; }
bool mUsePickMatrix;
double mPickParams[4];
GLint mPickViewport[4];
};
class GLCP
{
public:
#if !defined (OSMac_)
typedef char GLchar;
typedef ptrdiff_t GLsizeiptr;
#endif
typedef void (APIENTRY *Tp_glBindVertexArray) (GLuint array);
static Tp_glBindVertexArray BindVertexArray;
typedef void (APIENTRY *Tp_glGenVertexArrays) (GLsizei n, GLuint *arrays);
static Tp_glGenVertexArrays GenVertexArrays;
typedef void (APIENTRY *Tp_glDeleteVertexArrays ) (GLsizei n, const GLuint *arrays);
static Tp_glDeleteVertexArrays DeleteVertexArrays;
typedef void (APIENTRY *Tp_glUniform4f) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
static Tp_glUniform4f Uniform4f;
typedef void (APIENTRY *Tp_glUniformMatrix4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
static Tp_glUniformMatrix4fv UniformMatrix4fv;
typedef GLint (APIENTRY *Tp_glGetUniformLocation) (GLuint program, const GLchar *name);
static Tp_glGetUniformLocation GetUniformLocation;
typedef GLint (APIENTRY *Tp_glGetAttribLocation) (GLuint program, const GLchar *name);
static Tp_glGetAttribLocation GetAttribLocation;
typedef GLuint (APIENTRY *Tp_glCreateShader ) (GLenum type);
static Tp_glCreateShader CreateShader;
typedef void (APIENTRY *Tp_glShaderSource ) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
static Tp_glShaderSource ShaderSource;
typedef void (APIENTRY *Tp_glCompileShader ) (GLuint shader);
static Tp_glCompileShader CompileShader;
typedef void (APIENTRY *Tp_glGetShaderiv ) (GLuint shader, GLenum pname, GLint *params);
static Tp_glGetShaderiv GetShaderiv;
typedef void (APIENTRY *Tp_glGetShaderInfoLog ) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
static Tp_glGetShaderInfoLog GetShaderInfoLog;
typedef GLuint (APIENTRY *Tp_glCreateProgram ) ();
static Tp_glCreateProgram CreateProgram;
typedef void (APIENTRY *Tp_glAttachShader ) (GLuint program, GLuint shader);
static Tp_glAttachShader AttachShader;
typedef void (APIENTRY *Tp_glDeleteShader ) (GLuint shader);
static Tp_glDeleteShader DeleteShader;
typedef void (APIENTRY *Tp_glLinkProgram ) (GLuint program);
static Tp_glLinkProgram LinkProgram;
typedef void (APIENTRY *Tp_glGetProgramiv ) (GLuint program, GLenum pname, GLint *params);
static Tp_glGetProgramiv GetProgramiv;
typedef void (APIENTRY *Tp_glUseProgram ) (GLuint program);
static Tp_glUseProgram UseProgram;
typedef void (APIENTRY *Tp_glDeleteProgram ) (GLuint program);
static Tp_glDeleteProgram DeleteProgram;
typedef void (APIENTRY *Tp_glGetProgramInfoLog ) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
static Tp_glGetProgramInfoLog GetProgramInfoLog;
typedef void (APIENTRY *Tp_glGenBuffers ) (GLsizei n, GLuint *buffers);
static Tp_glGenBuffers GenBuffers;
typedef void (APIENTRY *Tp_glDeleteBuffers ) (GLsizei n, const GLuint *buffers);
static Tp_glDeleteBuffers DeleteBuffers;
typedef void (APIENTRY *Tp_glBindBuffer ) (GLenum target, GLuint buffer);
static Tp_glBindBuffer BindBuffer;
typedef void (APIENTRY *Tp_glBufferData ) (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
static Tp_glBufferData BufferData;
typedef void (APIENTRY *Tp_glEnableVertexAttribArray ) (GLuint index);
static Tp_glEnableVertexAttribArray EnableVertexAttribArray;
typedef void (APIENTRY *Tp_glVertexAttribPointer ) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
static Tp_glVertexAttribPointer VertexAttribPointer;
static void initGLFunctionsCoreProfile();
};
GLCP::Tp_glBindVertexArray GLCP::BindVertexArray = 0;
GLCP::Tp_glGenVertexArrays GLCP::GenVertexArrays = 0;
GLCP::Tp_glDeleteVertexArrays GLCP::DeleteVertexArrays = 0;
GLCP::Tp_glUniform4f GLCP::Uniform4f = 0;
GLCP::Tp_glUniformMatrix4fv GLCP::UniformMatrix4fv = 0;
GLCP::Tp_glGetUniformLocation GLCP::GetUniformLocation = 0;
GLCP::Tp_glGetAttribLocation GLCP::GetAttribLocation = 0;
GLCP::Tp_glCreateShader GLCP::CreateShader = 0;
GLCP::Tp_glShaderSource GLCP::ShaderSource = 0;
GLCP::Tp_glCompileShader GLCP::CompileShader = 0;
GLCP::Tp_glGetShaderiv GLCP::GetShaderiv = 0;
GLCP::Tp_glGetShaderInfoLog GLCP::GetShaderInfoLog = 0;
GLCP::Tp_glCreateProgram GLCP::CreateProgram = 0;
GLCP::Tp_glAttachShader GLCP::AttachShader = 0;
GLCP::Tp_glDeleteShader GLCP::DeleteShader = 0;
GLCP::Tp_glLinkProgram GLCP::LinkProgram = 0;
GLCP::Tp_glGetProgramiv GLCP::GetProgramiv = 0;
GLCP::Tp_glUseProgram GLCP::UseProgram = 0;
GLCP::Tp_glDeleteProgram GLCP::DeleteProgram = 0;
GLCP::Tp_glGetProgramInfoLog GLCP::GetProgramInfoLog = 0;
GLCP::Tp_glGenBuffers GLCP::GenBuffers = 0;
GLCP::Tp_glDeleteBuffers GLCP::DeleteBuffers = 0;
GLCP::Tp_glBindBuffer GLCP::BindBuffer = 0;
GLCP::Tp_glBufferData GLCP::BufferData = 0;
GLCP::Tp_glEnableVertexAttribArray GLCP::EnableVertexAttribArray = 0;
GLCP::Tp_glVertexAttribPointer GLCP::VertexAttribPointer = 0;
void GLCP::initGLFunctionsCoreProfile()
{
#if defined (OSMac_)
#define INIT_GLPOINTER(funcName) funcName = gl##funcName
#elif defined (_WIN32)
#define INIT_GLPOINTER(funcName) if (!funcName) funcName = (Tp_gl##funcName)wglGetProcAddress("gl" #funcName)
#else
#define INIT_GLPOINTER(funcName) if (!funcName) funcName = (Tp_gl##funcName)::glXGetProcAddressARB((const GLubyte*)"gl" #funcName)
#endif
INIT_GLPOINTER(BindVertexArray);
INIT_GLPOINTER(GenVertexArrays);
INIT_GLPOINTER(DeleteVertexArrays);
INIT_GLPOINTER(Uniform4f);
INIT_GLPOINTER(UniformMatrix4fv);
INIT_GLPOINTER(GetUniformLocation);
INIT_GLPOINTER(GetAttribLocation);
INIT_GLPOINTER(CreateShader);
INIT_GLPOINTER(ShaderSource);
INIT_GLPOINTER(CompileShader);
INIT_GLPOINTER(GetShaderiv);
INIT_GLPOINTER(GetShaderInfoLog);
INIT_GLPOINTER(CreateProgram);
INIT_GLPOINTER(AttachShader);
INIT_GLPOINTER(DeleteShader);
INIT_GLPOINTER(LinkProgram);
INIT_GLPOINTER(GetProgramiv);
INIT_GLPOINTER(UseProgram);
INIT_GLPOINTER(DeleteProgram);
INIT_GLPOINTER(GetProgramInfoLog);
INIT_GLPOINTER(GenBuffers);
INIT_GLPOINTER(DeleteBuffers);
INIT_GLPOINTER(BindBuffer);
INIT_GLPOINTER(BufferData);
INIT_GLPOINTER(EnableVertexAttribArray);
INIT_GLPOINTER(VertexAttribPointer);
#undef INIT_GLPOINTER
}
#if !defined (OSMac_)
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_STATIC_DRAW 0x88E4
#define GL_COMPILE_STATUS 0x8B81
#define GL_LINK_STATUS 0x8B82
#define GL_INFO_LOG_LENGTH 0x8B84
#endif
class RawFootPrintDrawAgentCoreProfile : public RawFootPrintDrawAgent
{
public:
static RawFootPrintDrawAgentCoreProfile& getDrawAgent(){
static RawFootPrintDrawAgentCoreProfile obj;
return obj;
}
void drawShaded() override;
void drawBoundingBox() override;
void drawWireframe() override;
void endDraw() override;
mWorldViewProjMatrix =
}
bool releaseCoreProfileResources();
private:
GLuint mShaderProgram;
GLint mWVPIndex;
GLint mColorIndex;
GLint mVtxAttrib;
GLuint mBBoxVAO;
GLuint mSoleWireframeVAO;
GLuint mHeelWireframeVAO;
GLuint mSoleShadedVAO;
GLuint mHeelShadedVAO;
GLuint mBoundingboxVertexBuffer;
GLuint mBoundingboxIndexBuffer;
GLuint mSoleVertexBuffer;
GLuint mSoleNormalBuffer;
GLuint mHeelVertexBuffer;
GLuint mHeelNormalBuffer;
GLuint mSoleWireIndexBuffer;
GLuint mSoleShadedIndexBuffer;
GLuint mHeelWireIndexBuffer;
GLuint mHeelShadedIndexBuffer;
bool mInitialized;
bool mValid;
bool initShadersCoreProfile();
bool initBuffersCoreProfile();
void setupUniforms();
private:
RawFootPrintDrawAgentCoreProfile()
: mShaderProgram(0)
, mWVPIndex(0)
, mColorIndex(0)
, mVtxAttrib(0)
, mBBoxVAO(0)
, mSoleWireframeVAO(0)
, mHeelWireframeVAO(0)
, mSoleShadedVAO(0)
, mHeelShadedVAO(0)
, mBoundingboxVertexBuffer(0)
, mBoundingboxIndexBuffer(0)
, mSoleVertexBuffer(0)
, mSoleNormalBuffer(0)
, mHeelVertexBuffer(0)
, mHeelNormalBuffer(0)
, mSoleWireIndexBuffer(0)
, mSoleShadedIndexBuffer(0)
, mHeelWireIndexBuffer(0)
, mHeelShadedIndexBuffer(0)
, mInitialized(false)
, mValid(false)
{}
~RawFootPrintDrawAgentCoreProfile() override{}
RawFootPrintDrawAgentCoreProfile( const RawFootPrintDrawAgentCoreProfile& v ){}
RawFootPrintDrawAgentCoreProfile operator = (const RawFootPrintDrawAgentCoreProfile& v){ return *this; }
};
#ifdef _WIN32
class RawFootPrintDrawAgentDX : public RawFootPrintDrawAgent
{
public:
static RawFootPrintDrawAgentDX& getDrawAgent(){
static RawFootPrintDrawAgentDX obj;
return obj;
}
virtual void drawShaded();
virtual void drawBoundingBox();
virtual void drawWireframe();
virtual void endDraw();
mWorldViewProjMatrix =
}
bool releaseDXResources();
private:
ID3D11Device* mDevicePtr;
ID3D11DeviceContext* mDeviceContextPtr;
ID3D11Buffer* mBoundingboxVertexBufferPtr;
ID3D11Buffer* mBoundingboxIndexBufferPtr;
ID3D11Buffer* mSoleVertexBufferPtr[2];
ID3D11Buffer* mHeelVertexBufferPtr[2];
ID3D11Buffer* mSoleWireIndexBufferPtr;
ID3D11Buffer* mSoleShadedIndexBufferPtr;
ID3D11Buffer* mHeelWireIndexBufferPtr;
ID3D11Buffer* mHeelShadedIndexBufferPtr;
ID3D11Buffer* mConstantBufferPtr;
ID3D11VertexShader* mVertexShaderPtr;
ID3D11PixelShader* mPixelShaderPtr;
ID3D11InputLayout* mVertexLayoutPtr;
bool mEffectLoad;
unsigned int mStride[2];
unsigned int mOffset[2];
struct ConstantBufferDef
{
XMMATRIX fWVP;
XMFLOAT4 fMatColor;
};
bool initShadersDX();
bool initBuffersDX();
void setupConstantBuffer();
private:
RawFootPrintDrawAgentDX():
mDevicePtr(NULL), mDeviceContextPtr(NULL), mEffectLocation(""),
mEffectLoad(false),
mBoundingboxVertexBufferPtr(NULL),
mBoundingboxIndexBufferPtr(NULL),
mSoleWireIndexBufferPtr(NULL),
mSoleShadedIndexBufferPtr(NULL),
mHeelWireIndexBufferPtr(NULL),
mHeelShadedIndexBufferPtr(NULL),
mConstantBufferPtr(NULL),
mVertexShaderPtr(NULL),
mPixelShaderPtr(NULL),
mVertexLayoutPtr(NULL)
{
mSoleVertexBufferPtr[0] = NULL;
mSoleVertexBufferPtr[1] = NULL;
mHeelVertexBufferPtr[0] = NULL;
mHeelVertexBufferPtr[1] = NULL;
mStride[0] = sizeof(float) * 3;
mStride[1] = sizeof(float) * 3;
mOffset[0] = 0;
mOffset[1] = 0;
}
~RawFootPrintDrawAgentDX(){}
RawFootPrintDrawAgentDX( const RawFootPrintDrawAgentDX& v ){}
RawFootPrintDrawAgentDX operator = (const RawFootPrintDrawAgentDX& v){ return *this; }
};
#endif // _WIN32
{
RawFootPrintDrawAgent::beginDraw(context, passShaderOverride);
if (!mShaderOverride)
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadMatrixd(mWorldViewMatrix.matrix[0]);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
if (mUsePickMatrix) {
auto _gluPickMatrix = [](GLdouble x, GLdouble y, GLdouble deltax, GLdouble deltay, GLint viewport[4])
{
if (deltax <= 0 || deltay <= 0) {
return;
}
glTranslatef((viewport[2] - 2 * (x - viewport[0])) / deltax, (viewport[3] - 2 * (y - viewport[1])) / deltay, 0);
glScalef(viewport[2] / deltax, viewport[3] / deltay, 1.0);
};
_gluPickMatrix(mPickParams[0], mPickParams[1], mPickParams[2], mPickParams[3], mPickViewport);
}
glMultMatrixd(mProjectionMatrix.matrix[0]);
glPushAttrib( GL_CURRENT_BIT );
}
}
void RawFootPrintDrawAgentGL::endDraw()
{
if (!mShaderOverride)
{
glPopAttrib();
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
RawFootPrintDrawAgent::endDraw();
}
void RawFootPrintDrawAgentGL::drawShaded()
{
glColor4fv( &(mColor.r) );
glBegin( GL_TRIANGLE_FAN );
int i;
int last = soleCount - 1;
for ( i = 0; i < last; ++i ) {
glNormal3f( 0.0f, 1.0f, 0.0f );
glVertex3f( sole[i][0],
sole[i][1],
sole[i][2]);
}
glEnd();
glBegin( GL_TRIANGLE_FAN );
last = heelCount - 1;
for ( i = 0; i < last; ++i ) {
glNormal3f( 0.0f, 1.0f, 0.0f );
glVertex3f( heel[i][0],
heel[i][1],
heel[i][2]);
}
glEnd();
}
void RawFootPrintDrawAgentGL::drawBoundingBox()
{
glColor4fv( &(mColor.r) );
const float* bottomLeftFront = bbData[0];
const float* topLeftFront = bbData[4];
const float* bottomRightFront = bbData[1];
const float* topRightFront = bbData[5];
const float* bottomLeftBack = bbData[3];
const float* topLeftBack = bbData[7];
const float* bottomRightBack = bbData[2];
const float* topRightBack = bbData[6];
glBegin( GL_LINES );
glVertex3fv( bottomLeftFront );
glVertex3fv( bottomRightFront );
glVertex3fv( bottomRightFront );
glVertex3fv( bottomRightBack );
glVertex3fv( bottomRightBack );
glVertex3fv( bottomLeftBack );
glVertex3fv( bottomLeftBack );
glVertex3fv( bottomLeftFront );
glVertex3fv( topLeftFront );
glVertex3fv( topRightFront );
glVertex3fv( topRightFront );
glVertex3fv( topRightBack );
glVertex3fv( topRightBack );
glVertex3fv( topLeftBack );
glVertex3fv( topLeftBack );
glVertex3fv( topLeftFront );
glVertex3fv( bottomLeftFront );
glVertex3fv( topLeftFront );
glVertex3fv( bottomRightFront );
glVertex3fv( topRightFront );
glVertex3fv( bottomRightBack );
glVertex3fv( topRightBack );
glVertex3fv( bottomLeftBack );
glVertex3fv( topLeftBack );
glEnd();
}
void RawFootPrintDrawAgentGL::drawWireframe()
{
glColor4fv( &(mColor.r) );
glBegin( GL_LINES );
int i;
int last = soleCount - 1;
for ( i = 0; i < last; ++i ) {
glVertex3f( sole[i][0],
sole[i][1],
sole[i][2]);
glVertex3f( sole[i+1][0],
sole[i+1][1],
sole[i+1][2]);
}
last = heelCount - 1;
for ( i = 0; i < last; ++i ) {
glVertex3f( heel[i][0],
heel[i][1],
heel[i][2]);
glVertex3f( heel[i+1][0],
heel[i+1][1],
heel[i+1][2]);
}
glEnd();
}
{
if ( !mInitialized ){
GLCP::initGLFunctionsCoreProfile();
mValid = initShadersCoreProfile() && initBuffersCoreProfile();
mInitialized = true;
}
if (!mValid)
return;
RawFootPrintDrawAgent::beginDraw(context, passShaderOverride);
if (!mShaderOverride) {
GLCP::UseProgram(mShaderProgram);
}
}
void RawFootPrintDrawAgentCoreProfile::endDraw()
{
if (!mValid)
return;
if (!mShaderOverride) {
GLCP::UseProgram(0);
}
GLCP::BindVertexArray(0);
RawFootPrintDrawAgent::endDraw();
}
void RawFootPrintDrawAgentCoreProfile::setupUniforms()
{
if( mShaderOverride == NULL )
{
float fMatrix[4][4];
for (size_t i = 0; i < 4; ++i)
for (size_t j = 0; j < 4; ++j)
fMatrix[i][j] = (float)mWorldViewProjMatrix.matrix[i][j];
GLCP::UniformMatrix4fv(mWVPIndex, 1, GL_FALSE, (float*)fMatrix);
GLCP::Uniform4f(mColorIndex, mColor.r, mColor.g, mColor.b, mColor.a);
}
}
void RawFootPrintDrawAgentCoreProfile::drawShaded()
{
if (!mValid)
return;
setupUniforms();
GLCP::BindVertexArray(mSoleShadedVAO);
glDrawElements(GL_TRIANGLES, 3 * (soleCount-2), GL_UNSIGNED_SHORT, 0);
GLCP::BindVertexArray(mHeelShadedVAO);
glDrawElements(GL_TRIANGLES, 3 * (heelCount-2), GL_UNSIGNED_SHORT, 0);
}
void RawFootPrintDrawAgentCoreProfile::drawBoundingBox()
{
if (!mValid)
return;
setupUniforms();
GLCP::BindVertexArray(mBBoxVAO);
glDrawElements(GL_LINES, 2 * 12, GL_UNSIGNED_SHORT, 0);
}
void RawFootPrintDrawAgentCoreProfile::drawWireframe()
{
if (!mValid)
return;
setupUniforms();
GLCP::BindVertexArray(mSoleWireframeVAO);
glDrawElements(GL_LINES, 2 * (soleCount-1), GL_UNSIGNED_SHORT, 0);
GLCP::BindVertexArray(mHeelWireframeVAO);
glDrawElements(GL_LINES, 2 * (heelCount-1), GL_UNSIGNED_SHORT, 0);
}
#ifdef _WIN32
{
if (!mEffectLoad)
{
mEffectLocation =
MString(
"$MAYA_PLUG_IN_PATH/rawfootprint.hlsl");
{
mEffectLoad = false;
return;
}
mEffectLoad = true;
}
if( !mDevicePtr || !mDeviceContextPtr ){
if ( theRenderer ){
if ( mDevicePtr ){
mDevicePtr->GetImmediateContext( &mDeviceContextPtr );
}
}
}
assert( mDevicePtr );
assert( mDeviceContextPtr );
if ( mDevicePtr && mDeviceContextPtr ){
RawFootPrintDrawAgent::beginDraw(context, passShaderOverride);
if ( initShadersDX() && passShaderOverride == NULL ){
mDeviceContextPtr->VSSetShader(mVertexShaderPtr, NULL, 0);
mDeviceContextPtr->PSSetShader(mPixelShaderPtr, NULL, 0);
}
initBuffersDX();
}
}
void RawFootPrintDrawAgentDX::endDraw()
{
RawFootPrintDrawAgent::endDraw();
}
void RawFootPrintDrawAgentDX::setupConstantBuffer()
{
assert( mDeviceContextPtr );
if ( !mDeviceContextPtr )
return;
if( mShaderOverride == NULL )
{
XMMATRIX dxTransform = XMMATRIX(
(float)mWorldViewProjMatrix.matrix[0][0], (float)mWorldViewProjMatrix.matrix[0][1], (float)mWorldViewProjMatrix.matrix[0][2], (float)mWorldViewProjMatrix.matrix[0][3],
(float)mWorldViewProjMatrix.matrix[1][0], (float)mWorldViewProjMatrix.matrix[1][1], (float)mWorldViewProjMatrix.matrix[1][2], (float)mWorldViewProjMatrix.matrix[1][3],
(float)mWorldViewProjMatrix.matrix[2][0], (float)mWorldViewProjMatrix.matrix[2][1], (float)mWorldViewProjMatrix.matrix[2][2], (float)mWorldViewProjMatrix.matrix[2][3],
(float)mWorldViewProjMatrix.matrix[3][0], (float)mWorldViewProjMatrix.matrix[3][1], (float)mWorldViewProjMatrix.matrix[3][2], (float)mWorldViewProjMatrix.matrix[3][3]);
ConstantBufferDef cb;
cb.fWVP = XMMatrixTranspose(dxTransform);
cb.fMatColor = XMFLOAT4( mColor.r, mColor.g, mColor.b, mColor.a);
mDeviceContextPtr->UpdateSubresource(mConstantBufferPtr, 0, NULL, &cb, 0, 0);
mDeviceContextPtr->VSSetConstantBuffers(0, 1, &mConstantBufferPtr);
mDeviceContextPtr->PSSetConstantBuffers(0, 1, &mConstantBufferPtr);
}
}
void RawFootPrintDrawAgentDX::drawShaded()
{
assert( mDeviceContextPtr );
if ( !(mDeviceContextPtr && mEffectLoad) )
return;
setupConstantBuffer();
mDeviceContextPtr->IASetVertexBuffers(0, 2, &mSoleVertexBufferPtr[0], &mStride[0], &mOffset[0]);
mDeviceContextPtr->IASetIndexBuffer(mSoleShadedIndexBufferPtr, DXGI_FORMAT_R16_UINT, 0);
mDeviceContextPtr->IASetInputLayout(mVertexLayoutPtr);
mDeviceContextPtr->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
mDeviceContextPtr->DrawIndexed(3 * (soleCount-2), 0, 0);
mDeviceContextPtr->IASetVertexBuffers(0, 2, &mHeelVertexBufferPtr[0], &mStride[0], &mOffset[0]);
mDeviceContextPtr->IASetIndexBuffer(mHeelShadedIndexBufferPtr, DXGI_FORMAT_R16_UINT, 0);
mDeviceContextPtr->IASetInputLayout(mVertexLayoutPtr);
mDeviceContextPtr->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
mDeviceContextPtr->DrawIndexed(3 * (heelCount-2), 0, 0);
}
void RawFootPrintDrawAgentDX::drawBoundingBox()
{
assert( mDeviceContextPtr );
if ( !(mDeviceContextPtr && mEffectLoad) )
return;
setupConstantBuffer();
mDeviceContextPtr->IASetVertexBuffers(0, 1, &mBoundingboxVertexBufferPtr, &mStride[0], &mOffset[0]);
mDeviceContextPtr->IASetIndexBuffer(mBoundingboxIndexBufferPtr, DXGI_FORMAT_R16_UINT, 0);
mDeviceContextPtr->IASetInputLayout(mVertexLayoutPtr);
mDeviceContextPtr->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
mDeviceContextPtr->DrawIndexed(2 * 12, 0, 0);
}
void RawFootPrintDrawAgentDX::drawWireframe()
{
assert( mDeviceContextPtr );
if ( !(mDeviceContextPtr && mEffectLoad) )
return;
setupConstantBuffer();
mDeviceContextPtr->IASetVertexBuffers(0, 1, &mSoleVertexBufferPtr[0], &mStride[0], &mOffset[0]);
mDeviceContextPtr->IASetIndexBuffer(mSoleWireIndexBufferPtr, DXGI_FORMAT_R16_UINT, 0);
mDeviceContextPtr->IASetInputLayout(mVertexLayoutPtr);
mDeviceContextPtr->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
mDeviceContextPtr->DrawIndexed(2 * (soleCount-1), 0, 0);
mDeviceContextPtr->IASetVertexBuffers(0, 1, &mHeelVertexBufferPtr[0], &mStride[0], &mOffset[0]);
mDeviceContextPtr->IASetIndexBuffer(mHeelWireIndexBufferPtr, DXGI_FORMAT_R16_UINT, 0);
mDeviceContextPtr->IASetInputLayout(mVertexLayoutPtr);
mDeviceContextPtr->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
mDeviceContextPtr->DrawIndexed(2 * (heelCount-1), 0, 0);
}
#endif // _WIN32
{
public:
{
return new RawFootPrintDrawOverride(obj);
}
~RawFootPrintDrawOverride() override;
bool isBounded(
const MDagPath& cameraPath)
const override;
const MDagPath& cameraPath)
const override;
const MDagPath& cameraPath)
const override;
bool disableInternalBoundingBoxDraw() const override;
bool excludedFromPostEffects() const override;
bool isTransparent() const override;
bool hasUIDrawables() const override { return true; }
void addUIDrawables(
bool traceCallSequence() const override
{
return false;
}
void handleTraceMessage(
const MString &message )
const override
{
fputs("rawFootPrintNode: ", stderr);
fputs(message.
asChar(), stderr);
fputs("\n", stderr);
}
bool wantUserSelection() const override
{
}
bool userSelect(
{
const GLsizei BUF_SIZE = 10;
GLuint selectBuf[BUF_SIZE];
glSelectBuffer(BUF_SIZE, selectBuf);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
drawImpl(context, &selectInfo, data);
glPopName();
GLint hits = glRenderMode(GL_RENDER);
if (hits <= 0) return false;
unsigned int x, y, w, h;
GLuint minZ = selectBuf[1];
GLuint maxZ = selectBuf[2];
double depth = (minZ*0.5 + maxZ*0.5) / 0xFFFFFFFF;
if (!camera.isOrtho())
{
const double Zf = camera.farClippingPlane();
depth *= Zn / (Zf - depth * (Zf - Zn));
}
hitPoint = nearPw + depth * (farPw - nearPw);
return true;
}
protected:
bool mCustomBoxDraw;
bool mExcludeFromPostEffects;
bool mTransparencySort;
MUint64 mLastFrameStamp;
private:
RawFootPrintDrawOverride(
const MObject& obj);
float getMultiplier(
const MDagPath& objPath)
const;
bool isTransparentSort(
const MDagPath& objPath)
const;
float getTransparency(
const MDagPath& objPath)
const;
static void OnModelEditorChanged(void *clientData);
MCallbackId fModelEditorChangedCbId;
};
RawFootPrintDrawOverride::RawFootPrintDrawOverride(
const MObject& obj)
:
MHWRender::MPxDrawOverride(obj, RawFootPrintDrawOverride::draw, false)
, mCustomBoxDraw(true)
, mExcludeFromPostEffects(false)
, mTransparencySort(false)
, mBlendState(NULL)
, mLastFrameStamp(0)
, fRawFootPrint(obj)
{
"modelEditorChanged", OnModelEditorChanged, this);
}
RawFootPrintDrawOverride::~RawFootPrintDrawOverride()
{
if (mBlendState)
{
mBlendState = NULL;
}
if (fModelEditorChangedCbId != 0)
{
fModelEditorChangedCbId = 0;
}
}
void RawFootPrintDrawOverride::OnModelEditorChanged(void *clientData)
{
RawFootPrintDrawOverride *ovr = static_cast<RawFootPrintDrawOverride*>(clientData);
}
{
}
float RawFootPrintDrawOverride::getMultiplier(
const MDagPath& objPath)
const
{
if (status)
{
MPlug plug(rawfootprintNode, rawfootPrint::size);
if (!plug.isNull())
{
if (plug.getValue(sizeVal))
{
}
}
}
return 1.0f;
}
bool RawFootPrintDrawOverride::isTransparentSort(
const MDagPath& objPath)
const
{
if (status)
{
MPlug plug(rawfootprintNode, rawfootPrint::transparencySort);
if (!plug.isNull())
{
bool isTransparent;
if (plug.getValue(isTransparent))
{
return isTransparent;
}
}
}
return false;
}
float RawFootPrintDrawOverride::getTransparency(
const MDagPath& objPath)
const
{
if (status)
{
MPlug plug(rawfootprintNode, rawfootPrint::transparency);
if (!plug.isNull())
{
float transparencyVal;
if (plug.getValue(transparencyVal))
{
return transparencyVal;
}
}
}
return 1.0f;
}
bool RawFootPrintDrawOverride::isBounded(
const MDagPath& ,
{
return true;
}
MMatrix RawFootPrintDrawOverride::transform(
{
float multiplier = getMultiplier(objPath);
transform[0][0] *= multiplier;
transform[1][1] *= multiplier;
transform[2][2] *= multiplier;
return transform;
}
{
MPoint corner1( -0.17, 0.0, -0.7 );
MPoint corner2( 0.17, 0.0, 0.3 );
float multiplier = getMultiplier(objPath);
corner1 = corner1 * multiplier;
corner2 = corner2 * multiplier;
RawFootPrintDrawOverride *nonConstThis = (RawFootPrintDrawOverride *)this;
nonConstThis->mCurrentBoundingBox.clear();
nonConstThis->mCurrentBoundingBox.expand( corner1 );
nonConstThis->mCurrentBoundingBox.expand( corner2 );
return mCurrentBoundingBox;
}
bool RawFootPrintDrawOverride::disableInternalBoundingBoxDraw() const
{
return mCustomBoxDraw;
}
bool RawFootPrintDrawOverride::excludedFromPostEffects() const
{
return mExcludeFromPostEffects;
}
bool RawFootPrintDrawOverride::isTransparent() const
{
return mTransparencySort;
}
MUserData* RawFootPrintDrawOverride::prepareForDraw(
{
static bool sExcludedFromPostEffects =
(getenv("MAYA_RAWFOOTPRINT_EXCLUDEDFROMPOSTEFFECTS") != NULL);
mExcludeFromPostEffects = !shadedMode || sExcludedFromPostEffects;
mTransparencySort = isTransparentSort(objPath);
RawFootPrintData* data = dynamic_cast<RawFootPrintData*>(oldData);
if (!data)
{
data = new RawFootPrintData();
data->mLastFrameStamp = 0;
}
data->fMultiplier = getMultiplier(objPath);
{
data->fColor[0] = color.
r;
data->fColor[1] = color.
g;
data->fColor[2] = color.
b;
}
else
{
data->fColor[0] = 0.6f;
data->fColor[1] = 0.6f;
data->fColor[2] = 0.6f;
}
data->fColor[3] = getTransparency(objPath);
data->fCustomBoxDraw = mCustomBoxDraw;
data->fCurrentBoundingBox = mCurrentBoundingBox;
if (!mBlendState)
{
{
}
}
data->mBlendState = mBlendState;
return data;
}
void RawFootPrintDrawOverride::addUIDrawables(
{
MColor textColor( 0.1f, 0.8f, 0.8f, 1.0f );
}
{
bool debugCameraInformation = false;
if (debugCameraInformation)
{
printf("Context Camera Info:\n");
printf("====================\n");
printf("-- Frustum: W = %g, H = %g, D= %g. Min = %g,%g,%g. Max = %g,%g,%g\n",
max[0], max[1], max[2]);
float nearV, farV;
printf("-- Depth Range: near=%g, far=%g\n", nearV, farV);
printf("-- View direction = %s\n", alongNegZ ? "-Z" : "+Z");
printf("-- View position = %g,%g,%g\n", vPos[0], vPos[1], vPos[2]);
printf("-- View direction = %g,%g,%g\n", vDir [0], vDir [1], vDir [2]);
printf("-- View up = %g,%g,%g\n", vals[0], vals[1], vals[2]);
printf("-- View right = %g,%g,%g\n", vals[0], vals[1], vals[2]);
printf("-- View near clip value = %g\n", vNear[0]);
printf("-- View far clip value = %g\n", vFar[0]);
double distW = vPos[0]*vDir[0] +
vPos[1]*vDir[1] +
vPos[2]*vDir[2];
double distNearW = -1.0 * (distW + vNear[0]);
printf("-- World space near plane dist=%g. Dir=%g,%g,%g\n", distNearW,
vDir[0], vDir[1], vDir[2]);
double distFarW = distW + vFar[0];
printf("-- World space far plane dist=%g. Dir=%g,%g,%g\n", distFarW,
-vDir[0], -vDir[1], -vDir[2]);
int uiX, uiY, uiWidth, uiHeight;
double windowAspect = (double)uiWidth / (double)uiHeight;
double left, bottom, right, top;
if (!viewportMode)
{
activeCamera.getRenderingFrustum(windowAspect, left, right, bottom, top);
}
else
{
static bool overscan = true;
static bool squeeze = false;
const bool panAndZoom = activeCamera.panZoomEnabled();
activeCamera.getViewingFrustum(windowAspect, left, right, bottom, top, overscan, squeeze, panAndZoom );
}
double nearD = activeCamera.unnormalizedNearClippingPlane();
double farD = activeCamera.unnormalizedFarClippingPlane();
printf("Camera Info:\n");
printf("============\n");
printf("-- Shape %s, Frustum: left=%g, bottom=%g, right=%g, top=%g near=%g, far=%g\n",
activeCamera.name().asChar(), left, bottom, right, top, nearD, farD);
MPoint eyePoint = activeCamera.eyePoint();
MVector viewDirection = activeCamera.viewDirection();
MVector upDirection = activeCamera.upDirection();
MVector rightDirection = activeCamera.rightDirection();
printf("-- Object space values: eyePoint=%g,%g,%g. vdir=%g,%g,%g. vup=%g,%g,%g, vright=%g,%g,%g\n",
eyePoint[0], eyePoint[1], eyePoint[2],
viewDirection[0], viewDirection[1], viewDirection[2],
upDirection[0], upDirection[1], upDirection[2],
rightDirection[0], rightDirection[1], rightDirection[2]);
printf("-- World space values: eyePoint=%g,%g,%g. vdir=%g,%g,%g. vup=%g,%g,%g, vright=%g,%g,%g\n",
eyePointW[0], eyePointW[1], eyePointW[2],
viewDirectionW[0], viewDirectionW[1], viewDirectionW[2],
upDirectionW[0], upDirectionW[1], upDirectionW[2],
rightDirectionW[0], rightDirectionW[1], rightDirectionW[2]);
distW = eyePointW[0]*viewDirectionW[0] +
eyePointW[1]*viewDirectionW[1] +
eyePointW[2]*viewDirectionW[2];
distNearW = -1.0 * (distW + nearD);
printf("-- World space near plane: Dir=%g,%g,%g. Dist=%g.\n",
viewDirectionW[0], viewDirectionW[1], viewDirectionW[2], distNearW);
distFarW = distW + farD;
printf("-- World space far plane: Dir=%g,%g,%g, Dist=%g. \n",
-viewDirectionW[0], -viewDirectionW[1], -viewDirectionW[2], distFarW);
activeCamera.getFilmFrustum( -nearD, clipPts );
unsigned int i = 0;
for ( i = 0; i < 4; i ++ )
{
MPoint pt = clipPts[i] * icMat;
printf("-- Near clip point[%d] = %g,%g,%g\n", i, pt[0], pt[1], pt[2]);
}
activeCamera.getFilmFrustum( -farD, clipPts );
for ( int i = 0; i < 4; i ++ )
{
MPoint pt = clipPts[i] * icMat;
printf("-- Far clip point[%d] = %g,%g,%g\n", i, pt[0], pt[1], pt[2]);
}
}
}
{
bool debugTypeExclusions = false;
if (debugTypeExclusions)
{
MUint64 excluded =
if (excluded > 0)
{
}
}
bool debugClassificationExclusions = false;
if (debugClassificationExclusions )
{
MString info(
"Classification strings excluded: ");
for (
unsigned int i=0; i<classifications.
length(); i++)
{
info += classifications[i];
info += ";";
}
}
}
{
bool debugBackground = false;
if (debugBackground)
{
}
}
{
bool debugPostEffects = false;
if (debugPostEffects)
{
{
}
}
}
{
bool debugDestination = false;
if (debugDestination)
{
MString destinationType =
" 3d viewport";
bool found3dView = false;
{
{
found3dView = true;
}
}
destinationType = " 2d viewport";
destinationType = "n image";
printf("rawfootprint node render destination is a%s. Destination name=%s. Found M3dView=%d\n",
destinationType.
asChar(), destinationIdentifier.
asChar(), found3dView);
}
}
{
bool debugRenderOverride = false;
if (debugRenderOverride)
{
{
}
}
}
const RawFootPrintData* footData)
{
bool debugDisplayStyle = false;
if (debugDisplayStyle)
{
bool drawAsBoundingbox =
(displayStyle & MHWRender::MFrameContext::kFlatShaded));
if (displayStyle & MHWRender::MFrameContext::kFlatShaded)
MGlobal::displayInfo(
"Flat shaded display style on");
}
}
{
bool debugFogStatus = false;
if (debugFogStatus)
{
{
info += col[0]; info += ",";
info += col[1]; info += ",";
info += col[2]; info += ",";
info += col[3];
}
}
}
{
static bool debugPassInformation = false;
if (debugPassInformation)
{
MString info(
"rawfootprint node drawing in pass[");
info += passId.
asChar(); info +=
"]";
{
for (
unsigned int i=0; i<passSem.
length(); i++)
{
info += " ";
info += passSem[i].asChar();
}
info += "]";
}
{
if (passShaderOverride) {
}
}
}
}
{
if (!theRenderer)
{
return;
}
const RawFootPrintData* footData = dynamic_cast<const RawFootPrintData*>(data);
if (!footData)
{
return;
}
static bool traceFrameStamp = false;
if (traceFrameStamp)
{
if (currentFrameStamp != footData->mLastFrameStamp)
{
bool updateColorPassFrameStamp = true;
{
updateColorPassFrameStamp = false;
}
if (updateColorPassFrameStamp)
{
printf("RawFootPrintDrawOverride: frame stamp change from %ld to %ld\n",
(long)footData->mLastFrameStamp, (long)currentFrameStamp);
}
((RawFootPrintData*)footData)->mLastFrameStamp = currentFrameStamp;
}
}
if ( objectOverrideInfo.
fOverrideEnabled && !objectOverrideInfo.
fEnableVisible )
{
return;
}
if (!objectOverrideInfo.
fPlaybackVisible &&
(animPlay || animScrub))
{
return;
}
footPrint_DebugCameraInformation(context);
footPrint_DebugObjectTypeExclusions(context);
footPrint_DebugBackground(context);
footPrint_DebugPostEffects(context);
footPrint_DebugDestination(context);
footPrint_DebugRenderOverride(context);
footPrint_DebugDisplayStyle(context, footData);
footPrint_DebugFogStatus(context);
footPrint_DebugPassInformation(context);
bool drawAsBoundingbox =
(displayStyle & MHWRender::MFrameContext::kFlatShaded));
bool overideTemplated = objectOverrideInfo.fOverrideEnabled &&
if (overideTemplated)
{
drawWireframe = true;
}
bool overrideNoShaded = objectOverrideInfo.fOverrideEnabled && !objectOverrideInfo.
fEnableShading;
if (overideTemplated || overrideNoShaded)
{
drawShaded = false;
}
if ( drawAsBoundingbox && !footData->fCustomBoxDraw )
{
drawAsBoundingbox = false;
}
{
if (!animPlay && !animScrub)
{
;
}
}
bool inSelection = false;
bool inBeautyPass = false;
bool inTransparencyPass = false;
const MString beautyPassSemantic(
"shadedBeautyGraphSemantic");
for (
unsigned int i=0; i<passSem.
length(); i++)
{
{
inSelection = true;
}
else if (passSem[i] == beautyPassSemantic)
{
inBeautyPass = true;
}
{
passShaderOverride->
setParameter(
"isSingleSided", (displayStyle & MHWRender::MFrameContext::kTwoSidedLighting) == 0);
passShaderOverride->
setParameter(
"mayaNormalMultiplier", -1.0f);
}
{
inTransparencyPass = true;
}
}
float color[4] = {
footData->fColor[0] * footData->fColor[3],
footData->fColor[1] * footData->fColor[3],
footData->fColor[2] * footData->fColor[3],
footData->fColor[3]
};
bool requireBlending = false;
if (!inSelection)
{
if (displayStyle & MHWRender::MFrameContext::kXray)
{
requireBlending = !passShaderOverride;
color[3] = 0.3f;
}
}
(displayStyle & MHWRender::MFrameContext::kFlatShaded)))
{
if (stateMgr && requireBlending)
{
if (footData->mBlendState)
{
}
}
if (!inTransparencyPass)
{
if (pOldRasterState)
{
if (desc.cullMode != cullMode)
{
desc.cullMode = cullMode;
if (rasterState)
{
}
}
}
}
}
RawFootPrintDrawAgentGL& drawAgentRef = RawFootPrintDrawAgentGL::getDrawAgent();
RawFootPrintDrawAgent* drawAgentPtr = &drawAgentRef;
#ifdef _WIN32
{
RawFootPrintDrawAgentDX& drawAgentRef = RawFootPrintDrawAgentDX::getDrawAgent();
drawAgentPtr = &drawAgentRef;
}
#endif
{
RawFootPrintDrawAgentCoreProfile& drawAgentRef = RawFootPrintDrawAgentCoreProfile::getDrawAgent();
drawAgentPtr = &drawAgentRef;
}
assert( drawAgentPtr );
if (drawAgentPtr) {
drawAgentPtr->setColor(
MColor(color[0], color[1], color[2], color[3]));
drawAgentPtr->setMatrix( context, selectInfo);
drawAgentPtr->beginDraw( context, passShaderOverride );
if (drawAsBoundingbox)
{
drawAgentPtr->drawBoundingBox();
}
else {
if (drawWireframe || overideTemplated || overrideNoShaded)
{
drawAgentPtr->drawWireframe();
}
if (!overideTemplated && !overrideNoShaded && drawShaded)
{
drawAgentPtr->drawShaded();
}
}
drawAgentPtr->endDraw();
}
if ( passShaderOverride ) {
}
if(stateMgr && (displayStyle & MHWRender::MFrameContext::kGouraudShaded ||
displayStyle & MHWRender::MFrameContext::kFlatShaded))
{
if (stateMgr && pOldBlendState)
{
}
if (pOldRasterState)
{
}
if (rasterState)
{
rasterState = NULL;
}
}
}
bool RawFootPrintDrawAgentCoreProfile::initShadersCoreProfile()
{
static const char* vertexShaderText =
"#version 330 \n"
"in vec3 Pm; \n"
"uniform mat4 MVP; \n"
"void main() { \n"
" gl_Position = MVP * vec4(Pm,1.0); \n"
"}";
GLuint vertexShaderID = GLCP::CreateShader(GL_VERTEX_SHADER);
GLCP::ShaderSource(vertexShaderID, 1, &vertexShaderText , NULL);
GLCP::CompileShader(vertexShaderID);
GLint result;
GLCP::GetShaderiv(vertexShaderID, GL_COMPILE_STATUS, &result);
if(result==GL_FALSE){
GLint errLength;
GLCP::GetShaderiv(vertexShaderID, GL_INFO_LOG_LENGTH, &errLength);
char* errorMessage = (char*)malloc(errLength+1);
GLCP::GetShaderInfoLog(vertexShaderID, errLength, NULL, &errorMessage[0]);
fprintf(stdout, "Compilation of vertex shader failed:\n%s\n", &errorMessage[0]);
free(errorMessage);
return false;
}
static const char* fragmentShaderText =
"#version 330 \n"
"uniform vec4 color = vec4( 1.0f, 1.0f, 1.0f, 1.0f ); \n"
"out vec4 colorOut; \n"
"void main() { \n"
" colorOut = color; \n"
"}";
GLuint fragmentShaderID = GLCP::CreateShader(GL_FRAGMENT_SHADER);
GLCP::ShaderSource(fragmentShaderID, 1, &fragmentShaderText , NULL);
GLCP::CompileShader(fragmentShaderID);
GLCP::GetShaderiv(fragmentShaderID, GL_COMPILE_STATUS, &result);
if(result==GL_FALSE){
GLint errLength;
GLCP::GetShaderiv(fragmentShaderID, GL_INFO_LOG_LENGTH, &errLength);
char* errorMessage = (char*)malloc(errLength+1);
GLCP::GetShaderInfoLog(fragmentShaderID, errLength, NULL, &errorMessage[0]);
fprintf(stdout, "Compilation of fragment shader failed:\n%s\n", &errorMessage[0]);
free(errorMessage);
return false;
}
mShaderProgram = GLCP::CreateProgram();
GLCP::AttachShader(mShaderProgram, vertexShaderID);
GLCP::AttachShader(mShaderProgram, fragmentShaderID);
GLCP::LinkProgram(mShaderProgram);
GLCP::GetProgramiv(mShaderProgram, GL_LINK_STATUS, &result);
if(result==GL_FALSE){
GLint errLength;
GLCP::GetProgramiv(mShaderProgram, GL_INFO_LOG_LENGTH, &errLength);
char* errorMessage = (char*)malloc(errLength+1);
GLCP::GetProgramInfoLog(mShaderProgram, errLength, NULL, &errorMessage[0]);
fprintf(stdout, "Linking of shader program failed:\n%s\n", &errorMessage[0]);
free(errorMessage);
return false;
}
mWVPIndex = GLCP::GetUniformLocation(mShaderProgram, "MVP");
mColorIndex = GLCP::GetUniformLocation(mShaderProgram, "color");
mVtxAttrib = GLCP::GetAttribLocation( mShaderProgram, "Pm" );
GLCP::DeleteShader(vertexShaderID);
GLCP::DeleteShader(fragmentShaderID);
return true;
}
bool RawFootPrintDrawAgentCoreProfile::initBuffersCoreProfile()
{
GLCP::GenVertexArrays(1, &mBBoxVAO);
GLCP::BindVertexArray(mBBoxVAO);
GLCP::GenBuffers(1, &mBoundingboxVertexBuffer);
GLCP::BindBuffer(GL_ARRAY_BUFFER, mBoundingboxVertexBuffer);
GLCP::BufferData(GL_ARRAY_BUFFER, sizeof(bbData), (void*)bbData, GL_STATIC_DRAW);
GLCP::GenBuffers(1, &mBoundingboxVertexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBoundingboxVertexBuffer);
GLCP::BufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(bbWireIndices), (void*)bbWireIndices, GL_STATIC_DRAW);
GLCP::EnableVertexAttribArray(mVtxAttrib);
GLCP::VertexAttribPointer(mVtxAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
GLCP::BindVertexArray(0);
GLCP::GenBuffers(1, &mSoleVertexBuffer);
GLCP::BindBuffer(GL_ARRAY_BUFFER, mSoleVertexBuffer);
GLCP::BufferData(GL_ARRAY_BUFFER, sizeof(sole), (void*)sole, GL_STATIC_DRAW);
GLCP::GenBuffers(1, &mHeelVertexBuffer);
GLCP::BindBuffer(GL_ARRAY_BUFFER, mHeelVertexBuffer);
GLCP::BufferData(GL_ARRAY_BUFFER, sizeof(heel), (void*)heel, GL_STATIC_DRAW);
GLCP::GenBuffers(1, &mSoleWireIndexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mSoleWireIndexBuffer);
GLCP::BufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(soleWireIndices), (void*)soleWireIndices, GL_STATIC_DRAW);
GLCP::GenBuffers(1, &mHeelWireIndexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mHeelWireIndexBuffer);
GLCP::BufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(heelWireIndices), (void*)heelWireIndices, GL_STATIC_DRAW);
GLCP::GenBuffers(1, &mSoleShadedIndexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mSoleShadedIndexBuffer);
GLCP::BufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(soleShadedIndices), (void*)soleShadedIndices, GL_STATIC_DRAW);
GLCP::GenBuffers(1, &mHeelShadedIndexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mHeelShadedIndexBuffer);
GLCP::BufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(heelShadedIndices), (void*)heelShadedIndices, GL_STATIC_DRAW);
GLCP::UseProgram(mShaderProgram);
GLCP::GenVertexArrays(1, &mSoleWireframeVAO);
GLCP::BindVertexArray(mSoleWireframeVAO);
GLCP::BindBuffer(GL_ARRAY_BUFFER, mSoleVertexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mSoleWireIndexBuffer);
GLCP::EnableVertexAttribArray(mVtxAttrib);
GLCP::VertexAttribPointer(mVtxAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
GLCP::BindVertexArray(0);
GLCP::GenVertexArrays(1, &mHeelWireframeVAO);
GLCP::BindVertexArray(mHeelWireframeVAO);
GLCP::BindBuffer(GL_ARRAY_BUFFER, mHeelVertexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mHeelWireIndexBuffer);
GLCP::EnableVertexAttribArray(mVtxAttrib);
GLCP::VertexAttribPointer(mVtxAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
GLCP::BindVertexArray(0);
GLCP::GenVertexArrays(1, &mSoleShadedVAO);
GLCP::BindVertexArray(mSoleShadedVAO);
GLCP::BindBuffer(GL_ARRAY_BUFFER, mSoleVertexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mSoleShadedIndexBuffer);
GLCP::EnableVertexAttribArray(mVtxAttrib);
GLCP::VertexAttribPointer(mVtxAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
GLCP::BindVertexArray(0);
GLCP::GenVertexArrays(1, &mHeelShadedVAO);
GLCP::BindVertexArray(mHeelShadedVAO);
GLCP::BindBuffer(GL_ARRAY_BUFFER, mHeelVertexBuffer);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mHeelShadedIndexBuffer);
GLCP::EnableVertexAttribArray(mVtxAttrib);
GLCP::VertexAttribPointer(mVtxAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
GLCP::BindVertexArray(0);
GLCP::UseProgram(0);
GLCP::BindBuffer(GL_ARRAY_BUFFER, 0);
GLCP::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
return true;
}
bool RawFootPrintDrawAgentCoreProfile::releaseCoreProfileResources()
{
if (mShaderProgram)
{
GLCP::DeleteProgram(mShaderProgram);
mShaderProgram = 0;
}
if (mBBoxVAO)
{
GLCP::DeleteVertexArrays(1, &mBBoxVAO);
mBBoxVAO = 0;
}
if (mSoleWireframeVAO)
{
GLCP::DeleteVertexArrays(1, &mSoleWireframeVAO);
mSoleWireframeVAO = 0;
}
if (mHeelWireframeVAO)
{
GLCP::DeleteVertexArrays(1, &mHeelWireframeVAO);
mHeelWireframeVAO = 0;
}
if (mSoleShadedVAO)
{
GLCP::DeleteVertexArrays(1, &mSoleShadedVAO);
mSoleShadedVAO = 0;
}
if (mHeelShadedVAO)
{
GLCP::DeleteVertexArrays(1, &mHeelShadedVAO);
mHeelShadedVAO = 0;
}
if (mBoundingboxVertexBuffer)
{
GLCP::DeleteBuffers(1, &mBoundingboxVertexBuffer);
mBoundingboxVertexBuffer = 0;
}
if (mBoundingboxIndexBuffer)
{
GLCP::DeleteBuffers(1, &mBoundingboxIndexBuffer);
mBoundingboxIndexBuffer = 0;
}
if (mSoleVertexBuffer)
{
GLCP::DeleteBuffers(1, &mSoleVertexBuffer);
mSoleVertexBuffer = 0;
}
if (mHeelVertexBuffer)
{
GLCP::DeleteBuffers(1, &mHeelVertexBuffer);
mHeelVertexBuffer = 0;
}
if (mSoleWireIndexBuffer)
{
GLCP::DeleteBuffers(1, &mSoleWireIndexBuffer);
mSoleWireIndexBuffer = 0;
}
if (mSoleShadedIndexBuffer)
{
GLCP::DeleteBuffers(1, &mSoleShadedIndexBuffer);
mSoleShadedIndexBuffer = 0;
}
if (mHeelWireIndexBuffer)
{
GLCP::DeleteBuffers(1, &mHeelWireIndexBuffer);
mHeelWireIndexBuffer = 0;
}
if (mHeelShadedIndexBuffer)
{
GLCP::DeleteBuffers(1, &mHeelShadedIndexBuffer);
mHeelShadedIndexBuffer = 0;
}
return true;
}
#ifdef _WIN32
bool RawFootPrintDrawAgentDX::initShadersDX()
{
assert( mDevicePtr );
if ( !mDevicePtr )
return false;
HRESULT hr;
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
ID3DBlob* vsBlob = NULL;
ID3DBlob* psBlob = NULL;
ID3DBlob* pErrorBlob;
if (!mVertexShaderPtr)
{
#if _MSC_VER < 1700
hr = D3DX11CompileFromFile(
mEffectLocation.asChar(),
NULL,
NULL,
"mainVS",
"vs_5_0",
dwShaderFlags,
0,
NULL,
&vsBlob,
&pErrorBlob,
NULL);
#else
hr = D3DCompileFromFile(
mEffectLocation.asWChar(),
NULL,
NULL,
"mainVS",
"vs_5_0",
dwShaderFlags,
0,
&vsBlob,
&pErrorBlob);
#endif
if (FAILED(hr))
{
printf("Failed to compile vertex shader\n");
if (pErrorBlob) pErrorBlob->Release();
return false;
}
if (pErrorBlob) pErrorBlob->Release();
hr = mDevicePtr->CreateVertexShader(
vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), NULL, &mVertexShaderPtr);
if (FAILED(hr))
{
printf("Failed to create vertex shader\n");
vsBlob->Release();
return false;
}
}
if (!mVertexLayoutPtr)
{
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
int numLayoutElements = sizeof layout/sizeof layout[0];
hr = mDevicePtr->CreateInputLayout(
layout, numLayoutElements, vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), &mVertexLayoutPtr);
vsBlob->Release();
if (FAILED(hr))
{
printf("Failed to create input layout\n");
return false;
}
}
if (!mPixelShaderPtr)
{
#if _MSC_VER < 1700
hr = D3DX11CompileFromFile(
mEffectLocation.asChar(),
NULL,
NULL,
"mainPS",
"ps_5_0",
dwShaderFlags,
0,
NULL,
&psBlob,
&pErrorBlob,
NULL);
#else
hr = D3DCompileFromFile(
mEffectLocation.asWChar(),
NULL,
NULL,
"mainPS",
"ps_5_0",
dwShaderFlags,
0,
&psBlob,
&pErrorBlob);
#endif
if (FAILED(hr))
{
printf("Failed to compile vertex shader\n");
mVertexShaderPtr->Release();
mVertexLayoutPtr->Release();
if (pErrorBlob) pErrorBlob->Release();
return false;
}
if (pErrorBlob) pErrorBlob->Release();
hr = mDevicePtr->CreatePixelShader(
psBlob->GetBufferPointer(), psBlob->GetBufferSize(), NULL, &mPixelShaderPtr);
psBlob->Release();
if (FAILED(hr))
{
printf("Failed to create pixel shader\n");
mVertexShaderPtr->Release();
mVertexLayoutPtr->Release();
return false;
}
}
return true;
}
bool RawFootPrintDrawAgentDX::initBuffersDX()
{
assert( mDevicePtr );
if ( !mDevicePtr )
return false;
HRESULT hr;
D3D11_BUFFER_DESC bd;
ZeroMemory(&bd, sizeof(bd));
D3D11_SUBRESOURCE_DATA InitData;
ZeroMemory(&InitData, sizeof(InitData));
if (!mBoundingboxVertexBufferPtr)
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(float) * 3 * 8;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = bbData;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mBoundingboxVertexBufferPtr);
if (FAILED(hr)) return false;
}
if( !mBoundingboxIndexBufferPtr ){
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(unsigned short) * 2 * 12;
bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = bbWireIndices;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mBoundingboxIndexBufferPtr);
if (FAILED(hr)) return false;
}
if (!mSoleVertexBufferPtr[0])
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(float) * 3 * soleCount;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = sole;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mSoleVertexBufferPtr[0]);
if (FAILED(hr)) return false;
}
if (!mSoleVertexBufferPtr[1])
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(float) * 3 * soleCount;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = soleNorm;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mSoleVertexBufferPtr[1]);
if (FAILED(hr)) return false;
}
if (!mHeelVertexBufferPtr[0])
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(float) * 3 * heelCount;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = heel;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mHeelVertexBufferPtr[0]);
if (FAILED(hr)) return false;
}
if (!mHeelVertexBufferPtr[1])
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(float) * 3 * heelCount;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = heelNorm;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mHeelVertexBufferPtr[1]);
if (FAILED(hr)) return false;
}
if (!mSoleWireIndexBufferPtr)
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(unsigned short) * 2 * (soleCount-1);
bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = soleWireIndices;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mSoleWireIndexBufferPtr);
if (FAILED(hr)) return false;
}
if (!mHeelWireIndexBufferPtr)
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(unsigned short) * 2 * (heelCount-1);
bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = heelWireIndices;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mHeelWireIndexBufferPtr);
if (FAILED(hr)) return false;
}
if (!mSoleShadedIndexBufferPtr)
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(unsigned short) * 3 * (soleCount-2);
bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = soleShadedIndices;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mSoleShadedIndexBufferPtr);
if (FAILED(hr)) return false;
}
if (!mHeelShadedIndexBufferPtr)
{
bd.Usage = D3D11_USAGE_IMMUTABLE;
bd.ByteWidth = sizeof(unsigned short) * 3 * (heelCount-2);
bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = 0;
InitData.pSysMem = heelShadedIndices;
hr = mDevicePtr->CreateBuffer(&bd, &InitData, &mHeelShadedIndexBufferPtr);
if (FAILED(hr)) return false;
}
if (!mConstantBufferPtr)
{
bd.Usage = D3D11_USAGE_DEFAULT;
bd.ByteWidth = sizeof(ConstantBufferDef);
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
bd.CPUAccessFlags = 0;
hr = mDevicePtr->CreateBuffer(&bd, NULL, &mConstantBufferPtr);
if (FAILED(hr)) return false;
}
return true;
}
bool RawFootPrintDrawAgentDX::releaseDXResources()
{
if (mBoundingboxVertexBufferPtr)
{
mBoundingboxVertexBufferPtr->Release();
mBoundingboxVertexBufferPtr = NULL;
}
if (mBoundingboxIndexBufferPtr)
{
mBoundingboxIndexBufferPtr->Release();
mBoundingboxIndexBufferPtr = NULL;
}
if (mSoleVertexBufferPtr[0])
{
mSoleVertexBufferPtr[0]->Release();
mSoleVertexBufferPtr[0] = NULL;
}
if (mSoleVertexBufferPtr[1])
{
mSoleVertexBufferPtr[1]->Release();
mSoleVertexBufferPtr[1] = NULL;
}
if (mHeelVertexBufferPtr[0])
{
mHeelVertexBufferPtr[0]->Release();
mHeelVertexBufferPtr[0] = NULL;
}
if (mHeelVertexBufferPtr[1])
{
mHeelVertexBufferPtr[1]->Release();
mHeelVertexBufferPtr[1] = NULL;
}
if (mSoleWireIndexBufferPtr)
{
mSoleWireIndexBufferPtr->Release();
mSoleWireIndexBufferPtr = NULL;
}
if (mSoleShadedIndexBufferPtr)
{
mSoleShadedIndexBufferPtr->Release();
mSoleShadedIndexBufferPtr = NULL;
}
if (mHeelWireIndexBufferPtr)
{
mHeelWireIndexBufferPtr->Release();
mHeelWireIndexBufferPtr = NULL;
}
if (mHeelShadedIndexBufferPtr)
{
mHeelShadedIndexBufferPtr->Release();
mHeelShadedIndexBufferPtr = NULL;
}
if (mVertexShaderPtr)
{
mVertexShaderPtr->Release();
mVertexShaderPtr = NULL;
}
if (mPixelShaderPtr)
{
mPixelShaderPtr->Release();
mPixelShaderPtr = NULL;
}
if (mVertexLayoutPtr)
{
mVertexLayoutPtr->Release();
mVertexLayoutPtr = NULL;
}
if (mConstantBufferPtr)
{
mConstantBufferPtr->Release();
mConstantBufferPtr = NULL;
}
return true;
}
#endif // _WIN32
{
stat = addAttribute( size );
if (!stat) {
return stat;
}
stat = addAttribute( transparencySort );
if (!stat) {
return stat;
}
stat = addAttribute( transparency );
if (!stat) {
return stat;
}
return MS::kSuccess;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerNode(
"rawfootPrint",
rawfootPrint::id,
&rawfootPrint::creator,
&rawfootPrint::initialize,
&rawfootPrint::drawDbClassification);
if (!status) {
status.
perror(
"registerNode");
return status;
}
rawfootPrint::drawDbClassification,
rawfootPrint::drawRegistrantId,
RawFootPrintDrawOverride::Creator);
if (!status) {
status.
perror(
"registerDrawOverrideCreator");
return status;
}
return status;
}
{
rawfootPrint::drawDbClassification,
rawfootPrint::drawRegistrantId);
if (!status) {
status.
perror(
"deregisterDrawOverrideCreator");
return status;
}
status = plugin.deregisterNode( rawfootPrint::id );
if (!status) {
status.
perror(
"deregisterNode");
return status;
}
#ifdef _WIN32
{
RawFootPrintDrawAgentDX& drawAgentRef = RawFootPrintDrawAgentDX::getDrawAgent();
drawAgentRef.releaseDXResources();
}
#endif
{
RawFootPrintDrawAgentCoreProfile& drawAgentRef = RawFootPrintDrawAgentCoreProfile::getDrawAgent();
drawAgentRef.releaseCoreProfileResources();
}
return status;
}