////////////////////////////////////////////////////////////////////////// // drawEllipsoid void ScnDebugRenderComponent::drawEllipsoid( const MaVec3d& Position, const MaVec3d& Size, const RsColour& Colour, BcU32 Layer ) { // Draw outer circles for all axis. BcU32 LOD = 16; BcF32 Angle = 0.0f; BcF32 AngleInc = ( BcPI * 2.0f ) / BcF32( LOD ); // Draw axis lines. for( BcU32 i = 0; i < LOD; ++i ) { MaVec2d PosA( BcCos( Angle ), -BcSin( Angle ) ); MaVec2d PosB( BcCos( Angle + AngleInc ), -BcSin( Angle + AngleInc ) ); MaVec3d XAxisA = MaVec3d( 0.0f, PosA.x() * Size.y(), PosA.y() * Size.z() ); MaVec3d YAxisA = MaVec3d( PosA.x() * Size.x(), 0.0f, PosA.y() * Size.z() ); MaVec3d ZAxisA = MaVec3d( PosA.x() * Size.x(), PosA.y() * Size.y(), 0.0f ); MaVec3d XAxisB = MaVec3d( 0.0f, PosB.x() * Size.y(), PosB.y() * Size.z() ); MaVec3d YAxisB = MaVec3d( PosB.x() * Size.x(), 0.0f, PosB.y() * Size.z() ); MaVec3d ZAxisB = MaVec3d( PosB.x() * Size.x(), PosB.y() * Size.y(), 0.0f ); drawLine( XAxisA + Position, XAxisB + Position, Colour, 0 ); drawLine( YAxisA + Position, YAxisB + Position, Colour, 0 ); drawLine( ZAxisA + Position, ZAxisB + Position, Colour, 0 ); Angle += AngleInc; } // Draw a cross down centre. MaVec3d XAxis = MaVec3d( Size.x(), 0.0f, 0.0f ); MaVec3d YAxis = MaVec3d( 0.0f, Size.y(), 0.0f ); MaVec3d ZAxis = MaVec3d( 0.0f, 0.0f, Size.z() ); drawLine( Position - XAxis, Position + XAxis, Colour, Layer ); drawLine( Position - YAxis, Position + YAxis, Colour, Layer ); drawLine( Position - ZAxis, Position + ZAxis, Colour, Layer ); }
void hackgrav(bodyptr p, bool intree) { pskip = p; /* exclude p from f.c. */ SETV(pos0, PosB(p)); /* set field point */ phi0 = 0.0; /* init total potential */ CLRV(acc0); /* and total acceleration */ n2bterm = nbcterm = 0; /* count body & cell terms */ skipself = FALSE; /* watch for tree-incest */ treescan((nodeptr) &root->cellnode); /* scan tree from root */ if (intree && ! skipself) { /* did tree-incest occur? */ if (! scanopt(options, "allow-incest")) /* treat as catastrophic? */ error("hackgrav: tree-incest detected\n"); if (! treeincest) /* for the first time? */ eprintf("\n[hackgrav: tree-incest detected]\n"); treeincest = TRUE; /* don't repeat warning */ } Phi(p) = phi0; /* store total potential */ SETV(Acc(p), acc0); /* and acceleration */ }
JNIEXPORT jintArray JNICALL Java_be_beeles_1place_jambiLight_utils_screenCapture_impl_ScreenCapperJNIMock_captureViaJNI(JNIEnv *env, jobject javaObject) { // get a new bitmap hOldBitmap = (HBITMAP)SelectObject(hMemoryDC, hBitmap); BitBlt(hMemoryDC, 0, 0, width, height, hScreenDC, 0, 0, SRCCOPY); hBitmap = (HBITMAP)SelectObject(hMemoryDC, hOldBitmap); GetDIBits(hScreenDC, hBitmap, 0, height, ScreenData, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); jintArray pixelValues = env->NewIntArray(pixels); jint *narr = env->GetIntArrayElements(pixelValues, NULL); int count = 0; for(int i = height-1 ; i >= 0 ; i--) { for(int j = 0 ; j < width ; j++) { narr[count] = ((PosR(j,i) & 0xff) << 16) + ((PosG(j,i) & 0xff) << 8) + (PosB(j,i) & 0xff); count++; } } /*//Rainbows! r = (int)(sin(frequency * rbCount + 0) * 127 + 128); g = (int)(sin(frequency * rbCount + 2) * 127 + 128); b = (int)(sin(frequency * rbCount + 4) * 127 + 128); if (rbCount < 32) { rbCount++; } else { rbCount = 0; } for (int i=0; i < pixels; i++) { narr[i] = ((r & 0xff) << 16) + ((g & 0xff) << 8) + (b & 0xff); }*/ env->ReleaseIntArrayElements(pixelValues, narr, NULL); return pixelValues; }
// // D3DSkyNode11::VOnRestore - Chapter 16, page 556 // HRESULT D3DSkyNode11::VOnRestore(Scene *pScene) { HRESULT hr; V_RETURN(SceneNode::VOnRestore(pScene)); m_camera = pScene->GetCamera(); V_RETURN (m_D3D11VertexShader.OnRestore(pScene)); V_RETURN (m_D3D11PixelShader.OnRestore(pScene)); // Create the vertex buffer m_numVerts = 24; m_sides = 5; // Fill the vertex buffer. We are setting the tu and tv texture // coordinates, which range from 0.0 to 1.0 D3D11VertexPosTexture *m_Vertices = AC_NEW D3D11VertexPosTexture[m_numVerts]; AC_ASSERT(m_Vertices && "Out of memory in D3DSkyNode11::VOnRestore()"); if (!m_Vertices) return E_FAIL; float dim = 50.0f; // create Pos vectors centered Vec3 PosA(-dim/2.0f, dim/2.0f, -dim/2.0f); Vec3 PosB(dim/2.0f, dim/2.0f, -dim/2.0f); Vec3 PosC(-dim/2.0f, -dim/2.0f, -dim/2.0f); Vec3 PosD(dim/2.0f, -dim/2.0f, -dim/2.0f); Vec3 PosE(dim/2.0f, dim/2.0f, dim/2.0f); Vec3 PosF(-dim/2.0f, dim/2.0f, dim/2.0f); Vec3 PosG(dim/2.0f,-dim/2.0f, dim/2.0f); Vec3 PosH(-dim/2.0f, -dim/2.0f, dim/2.0f); // create Texture vectors Vec2 UvA(0.0f, 1.0f); Vec2 UvB(1.0f, 1.0f); Vec2 UvC(0.0f, 0.0f); Vec2 UvD(1.0f, 0.0f); // N m_Vertices[0] = D3D11VertexPosTexture(PosH, UvA); m_Vertices[1] = D3D11VertexPosTexture(PosG, UvB); m_Vertices[2] = D3D11VertexPosTexture(PosF, UvC); m_Vertices[3] = D3D11VertexPosTexture(PosE, UvD); // E m_Vertices[4] = D3D11VertexPosTexture(PosE, UvC); m_Vertices[5] = D3D11VertexPosTexture(PosG, UvA); m_Vertices[6] = D3D11VertexPosTexture(PosB, UvD); m_Vertices[7] = D3D11VertexPosTexture(PosD, UvB); // S m_Vertices[8] = D3D11VertexPosTexture(PosA, UvD); m_Vertices[9] = D3D11VertexPosTexture(PosB, UvC); m_Vertices[10] = D3D11VertexPosTexture(PosC, UvB); m_Vertices[11] = D3D11VertexPosTexture(PosD, UvA); // W m_Vertices[12] = D3D11VertexPosTexture(PosH, UvB); m_Vertices[13] = D3D11VertexPosTexture(PosF, UvD); m_Vertices[14] = D3D11VertexPosTexture(PosC, UvA); m_Vertices[15] = D3D11VertexPosTexture(PosA, UvC); // U m_Vertices[16] = D3D11VertexPosTexture(PosC, UvA); m_Vertices[17] = D3D11VertexPosTexture(PosD, UvB); m_Vertices[18] = D3D11VertexPosTexture(PosH, UvC); m_Vertices[19] = D3D11VertexPosTexture(PosG, UvD); // D m_Vertices[20] = D3D11VertexPosTexture(PosF, UvA); m_Vertices[21] = D3D11VertexPosTexture(PosE, UvB); m_Vertices[22] = D3D11VertexPosTexture(PosA, UvC); m_Vertices[23] = D3D11VertexPosTexture(PosB, UvD); WORD *m_Indices = AC_NEW WORD[m_sides * 6]; m_Indices[0] = 2; m_Indices[1] = 1; m_Indices[2] = 0; m_Indices[3] = 2; m_Indices[4] = 3; m_Indices[5] = 1; m_Indices[6] = 6; m_Indices[7] = 5; m_Indices[8] = 4; m_Indices[9] = 6; m_Indices[10] = 7; m_Indices[11] = 5; m_Indices[12] = 10; m_Indices[13] = 9; m_Indices[14] = 8; m_Indices[15] = 10; m_Indices[16] = 11; m_Indices[17] = 9; m_Indices[18] = 14; m_Indices[19] = 13; m_Indices[20] = 12; m_Indices[21] = 14; m_Indices[22] = 15; m_Indices[23] = 13; m_Indices[24] = 22; m_Indices[25] = 21; m_Indices[26] = 20; m_Indices[27] = 22; m_Indices[28] = 23; m_Indices[29] = 21; //m_Indices[30] = 18; //m_Indices[31] = 17; //m_Indices[32] = 16; //m_Indices[33] = 18; //m_Indices[34] = 19; //m_Indices[35] = 17; V_RETURN (m_D3D11VertexBuffer.OnRestore(m_Vertices, m_numVerts, m_Indices, m_sides * 2)); SAFE_DELETE_ARRAY(m_Vertices); SAFE_DELETE_ARRAY(m_Indices); return S_OK; }