#include "narrowPolyViewer.h"
#include <maya/MItDag.h>
#include <maya/MStringArray.h>
#include <maya/MGlobal.h>
#include <maya/MPoint.h>
#include <maya/MSelectionList.h>
#include <maya/MItSelectionList.h>
#include <maya/MFnMesh.h>
#include <maya/MItMeshVertex.h>
#include <maya/MItMeshPolygon.h>
#include <maya/MPointArray.h>
#include <maya/MIOStream.h>
#include <maya/MGL.h>
#include <math.h>
narrowPolyViewer::narrowPolyViewer()
: fDrawManips(true)
, fLightTest(false)
{
setMultipleDrawEnable(true);
tol = 10;
}
narrowPolyViewer::~narrowPolyViewer()
{
}
{
setMultipleDrawEnable(true);
fCameraList.clear();
unsigned ii = 0;
unsigned nCameras = cameraList.
length();
for (ii = 0; ii < nCameras; ++ii) {
fCameraList.append(cameraList[ii]);
}
refresh();
}
{
unsigned ii = 0;
unsigned nCameras = fCameraList.length();
for (ii = 0; ii < nCameras; ++ii) {
cameraList.
append(fCameraList[ii]);
}
}
{
unsigned ii = 0;
unsigned nCameras = fCameraList.length();
for (ii = 0; ii < nCameras; ++ii) {
cameraList.
append(fCameraList[ii].partialPathName());
}
}
{
MStatus ReturnStatus = fCameraList.append(camera);
refresh(true);
return ReturnStatus;
}
{
int ii = 0;
bool cameraRemoved = false;
int nCameras = (int)fCameraList.length();
for (ii = nCameras - 1; ii >= 0; ii--) {
if (camera == fCameraList[ii]) {
fCameraList.remove(ii);
cameraRemoved = true;
}
}
if (cameraRemoved) {
refresh();
}
}
MStatus narrowPolyViewer::removeAllCameras()
{
refresh();
return ReturnStatus;
}
MString narrowPolyViewer::getCameraHUDName()
{
MString hudName(
"narrowPolyViewer: ");
getCamera(cameraPath);
return hudName;
}
{
setViewSelected(true);
return setObjectsToView(list);
}
MStatus narrowPolyViewer::setIsolateSelectOff()
{
return setViewSelected(false);
}
{
return ReturnStatus;
}
for (; !it.isDone(); it.next()) {
continue;
}
fLightList.append(lightPath);
}
if (fLightList.length() > 0) {
fLightTest = true;
}
return ReturnStatus;
}
void narrowPolyViewer::preMultipleDraw()
{
fCurrentPass = 0;
fDrawManips = false;
MStatus status = getCamera(oldCamera);
status.
perror(
"M3dView::getCamera");
}
fOldCamera = oldCamera;
displayHUD();
fTestCameraList.clear();
beginGL();
for (; !itMeshPolygon.isDone(); itMeshPolygon.next())
{
if (length == 3)
{
for (int i=0; i<length; i++)
{
MPoint p1 = points[(i+1)%length];
MPoint p2 = points[(i+2)%length];
double angle = v1.angle(v2) * 180 / 3.14159;
#if 0
astr += angle;
astr += " tolerance : ";
astr += tol;
#endif
if ( (fabs( angle - tol ) < .0001) || angle < tol )
{
glBegin(GL_POLYGON);
glVertex3f((float)points[0].x, (float)points[0].y, (float)points[0].z);
glVertex3f((float)points[1].x, (float)points[1].y, (float)points[1].z);
glVertex3f((float)points[2].x, (float)points[2].y, (float)points[2].z);
glEnd();
break;
}
}
}
}
endGL();
}
void narrowPolyViewer::postMultipleDraw()
{
MStatus status = setCamera(fOldCamera);
fDrawManips = true;
updateViewingParameters();
status.
perror(
"M3dView::setCamera");
}
}
void narrowPolyViewer::preMultipleDrawPass(unsigned index)
{
fCurrentPass = index;
status.
perror(
"M3dView::setDisplayAxis");
}
if (
MS::kSuccess != (status = setDisplayAxisAtOrigin(
false))) {
status.
perror(
"M3dView::setDisplayAxisAtOrigin");
}
if (
MS::kSuccess != (status = setDisplayCameraAnnotation(
false))) {
status.
perror(
"M3dView::setDisplayCameraAnnotation");
}
if (fCurrentPass == 0) {
getCamera(dagPath);
} else {
unsigned nCameras = fCameraList.length();
if (fCurrentPass <= nCameras) {
dagPath = fCameraList[fCurrentPass-1];
} else {
cerr << "Error ... too many passes specified: "
<< fCurrentPass << endl;
return;
}
}
status.
perror(
"M3dView::setCamera");
return;
}
fTestCameraList.append(thisCameraPath);
if (dagPath == fOldCamera) {
fDrawManips = true;
}
status.
perror(
"M3dView::setFogEnabled");
}
if (!isFogEnabled()) {
}
setBackgroundFogEnabled(false);
} else {
fDrawManips = false;
"objectDisplay kDisplayGrid should be false!");
}
status.
perror(
"M3dView::setFogEnabled");
}
if (isFogEnabled()) {
}
}
if (fLightTest) {
unsigned step = 4;
unsigned min = 0 + (fCurrentPass * step);
unsigned max = (fCurrentPass * step);
if (max > 0) {
max--;
}
unsigned nLights = fLightList.length();
if (nLights < min) {
setLightingMode(kLightDefault);
} else {
if (nLights < max) {
max = nLights;
}
unsigned ii = 0;
for (ii = min; ii < max; ii++) {
list.
add(fLightList[ii].node());
}
setLightingMode(kLightSelected);
}
} else {
setLightingMode(kLightDefault);
}
if (fCurrentPass % 2 == 0) {
}
updateViewingParameters();
}
void narrowPolyViewer::postMultipleDrawPass(unsigned index)
{
}
bool narrowPolyViewer::okForMultipleDraw(
const MDagPath &dagPath)
{
return false;
}
return true;
}
unsigned narrowPolyViewer::multipleDrawPassCount()
{
return fCameraList.length() + 1;
}
void narrowPolyViewer::removingCamera(
MDagPath &cameraPath)
{
int ii = 0;
int nCameras = (int)fCameraList.length();
for (ii = nCameras - 1; ii >= 0; ii--) {
if (cameraPath == fCameraList[ii]) {
fCameraList.remove(ii);
}
}
}
void * narrowPolyViewer::creator()
{
return new narrowPolyViewer();
}
{
}
{
}
MString narrowPolyViewer::viewType() const
{
return MString(
"narrowPolyViewer");
}