bool GMonitorGraph::OnUpdateTimer() { if (module->GetInput( 0 ) != NULL) { float *in=module->GetInput( 0 )->GetSignal(); float i; for (i=0; i<size; i+=t) { if (n>=size) { n=0; t = timeValue; list<float> pointsList; for (unsigned int j=0; j<size;j++) { float value = (buffor[j]); pointsList.push_back(value*scaleValue); } Glib::ArrayHandle<float> arrayHandle(pointsList); curve.set_vector(arrayHandle); } buffor[n] = in[(int)floor(i)]; buffor[n] = in[0]; n++; } } return true; }
void ApexVertexBuffer::resize(uint32_t vertexCount) { mParams->vertexCount = vertexCount; NvParameterized::Handle handle(*mParams); VERIFY_PARAM(mParams->getParameterHandle("buffers", handle)); int32_t buffersSize = 0; VERIFY_PARAM(mParams->getArraySize(handle, buffersSize)); for (int32_t i = 0; i < buffersSize; i++) { RenderDataFormat::Enum outFormat = mFormat.getBufferFormat((uint32_t)i); NvParameterized::Handle elementHandle(*mParams); VERIFY_PARAM(handle.getChildHandle(i, elementHandle)); NvParameterized::Interface* currentReference = NULL; VERIFY_PARAM(mParams->getParamRef(elementHandle, currentReference)); // BUFFER_FORMAT_ADD This is just a bookmark for places where to add buffer formats if (currentReference == NULL && vertexCount > 0) { const char* className = NULL; switch (outFormat) { case RenderDataFormat::UBYTE1: case RenderDataFormat::BYTE_UNORM1: case RenderDataFormat::BYTE_SNORM1: className = BufferU8x1::staticClassName(); break; case RenderDataFormat::UBYTE2: case RenderDataFormat::BYTE_UNORM2: case RenderDataFormat::BYTE_SNORM2: className = BufferU8x2::staticClassName(); break; case RenderDataFormat::UBYTE3: case RenderDataFormat::BYTE_UNORM3: case RenderDataFormat::BYTE_SNORM3: className = BufferU8x3::staticClassName(); break; case RenderDataFormat::UBYTE4: case RenderDataFormat::BYTE_UNORM4: case RenderDataFormat::BYTE_SNORM4: case RenderDataFormat::R8G8B8A8: case RenderDataFormat::B8G8R8A8: className = BufferU8x4::staticClassName(); break; case RenderDataFormat::SHORT1: case RenderDataFormat::USHORT1: case RenderDataFormat::SHORT_UNORM1: case RenderDataFormat::SHORT_SNORM1: case RenderDataFormat::HALF1: className = BufferU16x1::staticClassName(); break; case RenderDataFormat::SHORT2: case RenderDataFormat::USHORT2: case RenderDataFormat::SHORT_UNORM2: case RenderDataFormat::SHORT_SNORM2: case RenderDataFormat::HALF2: className = BufferU16x2::staticClassName(); break; case RenderDataFormat::SHORT3: case RenderDataFormat::USHORT3: case RenderDataFormat::SHORT_UNORM3: case RenderDataFormat::SHORT_SNORM3: case RenderDataFormat::HALF3: className = BufferU16x3::staticClassName(); break; case RenderDataFormat::SHORT4: case RenderDataFormat::USHORT4: case RenderDataFormat::SHORT_UNORM4: case RenderDataFormat::SHORT_SNORM4: case RenderDataFormat::HALF4: className = BufferU16x4::staticClassName(); break; case RenderDataFormat::UINT1: className = BufferU32x1::staticClassName(); break; case RenderDataFormat::UINT2: className = BufferU32x2::staticClassName(); break; case RenderDataFormat::UINT3: className = BufferU32x3::staticClassName(); break; case RenderDataFormat::UINT4: className = BufferU32x4::staticClassName(); break; case RenderDataFormat::FLOAT1: className = BufferF32x1::staticClassName(); break; case RenderDataFormat::FLOAT2: className = BufferF32x2::staticClassName(); break; case RenderDataFormat::FLOAT3: className = BufferF32x3::staticClassName(); break; case RenderDataFormat::FLOAT4: case RenderDataFormat::R32G32B32A32_FLOAT: case RenderDataFormat::B32G32R32A32_FLOAT: className = BufferF32x4::staticClassName(); break; default: PX_ALWAYS_ASSERT(); break; } if (className != NULL) { currentReference = GetInternalApexSDK()->getParameterizedTraits()->createNvParameterized(className); } if (currentReference != NULL) { NvParameterized::Handle arrayHandle(*currentReference); VERIFY_PARAM(currentReference->getParameterHandle("data", arrayHandle)); PX_ASSERT(arrayHandle.isValid()); VERIFY_PARAM(arrayHandle.resizeArray((int32_t)vertexCount)); mParams->setParamRef(elementHandle, currentReference); } } else if (vertexCount > 0) { NvParameterized::Interface* oldReference = currentReference; PX_ASSERT(oldReference != NULL); currentReference = GetInternalApexSDK()->getParameterizedTraits()->createNvParameterized(oldReference->className()); if (currentReference != NULL) { VERIFY_PARAM(currentReference->copy(*oldReference)); NvParameterized::Handle arrayHandle(*currentReference); VERIFY_PARAM(currentReference->getParameterHandle("data", arrayHandle)); VERIFY_PARAM(arrayHandle.resizeArray((int32_t)vertexCount)); } VERIFY_PARAM(mParams->setParamRef(elementHandle, currentReference)); oldReference->destroy(); } else if (vertexCount == 0) { VERIFY_PARAM(mParams->setParamRef(elementHandle, NULL)); if (currentReference != NULL) { currentReference->destroy(); } } } }
MStatus weightList::compute( const MPlug& plug, MDataBlock& block) { MStatus status = MS::kSuccess; unsigned i, j; MObject thisNode = thisMObject(); MPlug wPlug(thisNode, aWeights); // Write into aWeightList for( i = 0; i < 3; i++) { status = wPlug.selectAncestorLogicalIndex( i, aWeightsList ); MDataHandle wHandle = wPlug.constructHandle(block); MArrayDataHandle arrayHandle(wHandle, &status); McheckErr(status, "arrayHandle construction failed\n"); MArrayDataBuilder arrayBuilder = arrayHandle.builder(&status); McheckErr(status, "arrayBuilder accessing/construction failed\n"); for( j = 0; j < i+2; j++) { MDataHandle handle = arrayBuilder.addElement(j,&status); McheckErr(status, "addElement to arrayBuilder failed\n"); float val = 1.0f*(i+j); handle.set(val); } status = arrayHandle.set(arrayBuilder); McheckErr(status, "set arrayBuilder failed\n"); wPlug.setValue(wHandle); wPlug.destructHandle(wHandle); } // Read from aWeightList and print out result MArrayDataHandle arrayHandle = block.inputArrayValue(aWeightsList, &status); McheckErr(status, "arrayHandle construction for aWeightsList failed\n"); unsigned count = arrayHandle.elementCount(); for( i = 0; i < count; i++) { arrayHandle.jumpToElement(i); MDataHandle eHandle = arrayHandle.inputValue(&status).child(aWeights); McheckErr(status, "handle evaluation failed\n"); MArrayDataHandle eArrayHandle(eHandle, &status); McheckErr(status, "arrayHandle construction for aWeights failed\n"); unsigned eCount = eArrayHandle.elementCount(); for( j = 0; j < eCount; j++) { eArrayHandle.jumpToElement(j); float weight = eArrayHandle.inputValue(&status).asFloat(); McheckErr(status, "weight evaluation error\n"); fprintf(stderr, "weightList[%u][%u] = %g\n",i,j,weight); } } // Read from aWeightList and print out result using the more // efficient jumpToArrayElement() call arrayHandle = block.inputArrayValue(aWeightsList, &status); McheckErr(status, "arrayHandle construction for aWeightsList failed\n"); count = arrayHandle.elementCount(); for( i = 0; i < count; i++) { arrayHandle.jumpToArrayElement(i); MDataHandle eHandle = arrayHandle.inputValue(&status).child(aWeights); McheckErr(status, "handle evaluation failed\n"); MArrayDataHandle eArrayHandle(eHandle, &status); McheckErr(status, "arrayHandle construction for aWeights failed\n"); unsigned eCount = eArrayHandle.elementCount(); for( j = 0; j < eCount; j++) { eArrayHandle.jumpToArrayElement(j); float weight = eArrayHandle.inputValue(&status).asFloat(); McheckErr(status, "weight evaluation error\n"); fprintf(stderr, "weightList[%d][%d] = %g\n",i,j,weight); } } return status; }