protected void CreateBracketMesh() { // System.err.println( iWidth + " " + iHeight + " " + iDepth ); Attributes kAttributes = new Attributes(); kAttributes.SetPChannels(3); int iVQuantity = 3; VertexBuffer pkVB = new VertexBuffer(kAttributes, iVQuantity); // generate geometry float[] afChannels = pkVB.GetData(); int iIndex = 0; afChannels[iIndex++] = 0; afChannels[iIndex++] = -1.0f; afChannels[iIndex++] = 0.0f; afChannels[iIndex++] = 0; afChannels[iIndex++] = 0.0f; afChannels[iIndex++] = 0.5f; afChannels[iIndex++] = 0; afChannels[iIndex++] = 0.95f; afChannels[iIndex++] = 1.0f; m_kBracketPoints = new Polypoint(pkVB); AlphaState kAlpha = new AlphaState(); kAlpha.BlendEnabled = true; kAlpha.SrcBlend = AlphaState.SrcBlendMode.SBF_ONE; kAlpha.DstBlend = AlphaState.DstBlendMode.DBF_ONE; m_kBracketPoints.AttachGlobalState(kAlpha); m_kBracketPoints.UpdateGS(); m_kBracketPoints.UpdateRS(); }
protected void CreateScene(GLAutoDrawable arg0) { int iWidth = m_iWidth; int iHeight = m_iHeight; int iDepth = m_kImageA.nDims == 3 ? m_kImageA.extents[2] : 1; m_kHistogramOutput = CreateRenderTarget(arg0, "Histogram2D", iWidth, iHeight); m_kHistogramOutputB = CreateRenderTarget(arg0, "Histogram2DB", iWidth, iHeight); m_kEntropyOut = CreateRenderTarget(arg0, "EntropyOut", 1, 1); if (CreateImageMesh(m_kImageA.extents[0], m_kImageA.extents[1], iDepth) == null) { CreateImageMesh(m_kImageA.extents[0], m_kImageA.extents[1], 1); m_iRenderLoops = iDepth; System.err.println("Switching to 2.5D"); } m_kImagePointsDual.AttachEffect(m_kImageEffectDual); m_kImageEffectDual.SetImageSize(m_kImageA.extents[0], m_kImageA.extents[1], iDepth); CreateHistogramMesh(m_iWidth, m_iHeight); m_akCollapse2D = new VolumeHistogramEffect(m_kHistogramOutput.GetTarget(0), VolumeHistogramEffect.NONE); m_akCollapseColumns = new VolumeHistogramEffect( m_kHistogramOutput.GetTarget(0), VolumeHistogramEffect.COLLAPSE_COLUMNS); m_akCollapseRows = new VolumeHistogramEffect( m_kHistogramOutput.GetTarget(0), VolumeHistogramEffect.COLLAPSE_ROWS); m_kHistogramPoints2D.AttachEffect(m_akCollapse2D); AlphaState pkAState = m_akCollapse2D.GetBlending(0); pkAState.BlendEnabled = true; pkAState.SrcBlend = AlphaState.SrcBlendMode.SBF_ONE; pkAState.DstBlend = AlphaState.DstBlendMode.DBF_ONE; m_kHistogramPoints2D.AttachEffect(m_akCollapseColumns); pkAState = m_akCollapseColumns.GetBlending(0); pkAState.BlendEnabled = true; pkAState.SrcBlend = AlphaState.SrcBlendMode.SBF_ONE; pkAState.DstBlend = AlphaState.DstBlendMode.DBF_ONE; m_kHistogramPoints2D.AttachEffect(m_akCollapseRows); pkAState = m_akCollapseRows.GetBlending(0); pkAState.BlendEnabled = true; pkAState.SrcBlend = AlphaState.SrcBlendMode.SBF_ONE; pkAState.DstBlend = AlphaState.DstBlendMode.DBF_ONE; double dSize = m_kImageA.dataSize; m_akImageReduceEntropy = new ImageReduceEffect(m_kHistogramOutputB.GetTarget(0), dSize); m_kEntropyPoints2D.AttachEffect(m_akImageReduceEntropy); /* m_kImageLineMinPass2a = new LineMinimizationEffect( m_kBracketOut.GetTarget(0), m_kEntropyOut.GetTarget(0), m_fMinDist, (float)dSize, m_kImageA.nDims ); m_kImageLineMinDual.SetImageSize( m_kImageA.extents[0],m_kImageA.extents[1],iDepth ); */ }
protected void CreateHistogramMesh(int iWidth, int iHeight) { Attributes kAttributes = new Attributes(); kAttributes.SetPChannels(3); int iVQuantity = iWidth * iHeight; VertexBuffer pkVB = new VertexBuffer(kAttributes, iVQuantity); // generate geometry float fInv0 = 1.0f / (iWidth); float fInv1 = 1.0f / (iHeight); float fU, fV; int i0, i1; float[] afChannels = pkVB.GetData(); int iIndex = 0; for (i1 = 0; i1 < iHeight; i1++) { fV = i1 * fInv1; for (i0 = 0; i0 < iWidth; i0++) { fU = i0 * fInv0; afChannels[iIndex++] = ((2.0f * fU - 1.0f)); afChannels[iIndex++] = ((2.0f * fV - 1.0f)); afChannels[iIndex++] = 0f; // System.err.println( ((2.0f*fU-1.0f)) + " " + ((2.0f*fV-1.0f))); } } m_kHistogramPoints2D = new Polypoint(pkVB); m_kEntropyPoints2D = new Polypoint(pkVB); AlphaState kAlpha = new AlphaState(); kAlpha.BlendEnabled = true; kAlpha.SrcBlend = AlphaState.SrcBlendMode.SBF_ONE; kAlpha.DstBlend = AlphaState.DstBlendMode.DBF_ONE; m_kHistogramPoints2D.AttachGlobalState(kAlpha); m_kHistogramPoints2D.UpdateGS(); m_kHistogramPoints2D.UpdateRS(); m_kEntropyPoints2D.AttachGlobalState(kAlpha); m_kEntropyPoints2D.UpdateGS(); m_kEntropyPoints2D.UpdateRS(); }
protected ResourceIdentifier CreateImageMesh(int iWidth, int iHeight, int iDepth) { // System.err.println( iWidth + " " + iHeight + " " + iDepth ); Attributes kAttributes = new Attributes(); kAttributes.SetPChannels(3); int iVQuantity = iWidth * iHeight * iDepth; VertexBuffer pkVB = new VertexBuffer(kAttributes, iVQuantity); // generate geometry float fInv0 = 1.0f / (iWidth - 1.0f); float fInv1 = 1.0f / (iHeight - 1.0f); float fInv2 = 1.0f / (iDepth); float fU, fV, fW; int i0, i1, i2; float[] afChannels = pkVB.GetData(); int iIndex = 0; for (i2 = 0; i2 < iDepth; i2++) { fW = i2 * fInv2; for (i1 = 0; i1 < iHeight; i1++) { fV = i1 * fInv1; for (i0 = 0; i0 < iWidth; i0++) { fU = i0 * fInv0; afChannels[iIndex++] = ((2.0f * fU - 1.0f)); afChannels[iIndex++] = ((2.0f * fV - 1.0f)); afChannels[iIndex++] = ((2.0f * fW - 1.0f)); } } } m_kImagePointsDual = new Polypoint(pkVB); m_kAlpha = new AlphaState(); m_kAlpha.BlendEnabled = true; m_kAlpha.SrcBlend = AlphaState.SrcBlendMode.SBF_ONE; m_kAlpha.DstBlend = AlphaState.DstBlendMode.DBF_ONE; m_kImagePointsDual.AttachGlobalState(m_kAlpha); m_kImagePointsDual.UpdateGS(); m_kImagePointsDual.UpdateRS(); return m_pkRenderer.LoadVBuffer(pkVB.GetAttributes(), pkVB.GetAttributes(), pkVB); }