void Ball::Init() { // Only called by real balls, not temporary objects created for physics/rendering collisionMass = 1.0f; m_orientation.Identity(); m_inversebodyinertiatensor.Identity((float)(5.0/2.0)/(radius*radius)); m_angularvelocity.Set(0,0,0); m_angularmomentum.Set(0,0,0); m_ballanim.m_pball = this; fFrozen = false; // world limits on ball displacements // x_min = g_pplayer->m_ptable->m_left + radius; // x_max = g_pplayer->m_ptable->m_right - radius; // y_min = g_pplayer->m_ptable->m_top + radius; // y_max = g_pplayer->m_ptable->m_bottom - radius; z_min = g_pplayer->m_ptable->m_tableheight + radius; z_max = (g_pplayer->m_ptable->m_glassheight - radius); m_coll.obj = NULL; m_fDynamic = C_DYNAMIC; // assume dynamic m_pballex = NULL; m_vpVolObjs = new VectorVoid; m_color = RGB(255,255,255); m_disableLighting = false; if (g_pplayer->m_ptable->m_szBallImage[0] == '\0') { m_szImage[0] = '\0'; m_pin = NULL; } else { lstrcpy(m_szImage, g_pplayer->m_ptable->m_szBallImage); m_pin = g_pplayer->m_ptable->GetImage(m_szImage); } if (g_pplayer->m_ptable->m_szBallImageFront[0] == '\0') { m_szImageFront[0] = '\0'; m_pinFront = NULL; } else { lstrcpy(m_szImageFront, g_pplayer->m_ptable->m_szBallImageFront); m_pinFront = g_pplayer->m_ptable->GetImage(m_szImageFront); } RenderSetup(); }
void Player::Draw() { Matrix objpos; Matrix worldviewproj; Matrix rotation; // draw mesh { objpos.SetIdentity(); //while( mRotationRate < 0 ) mRotationRate += 360; //while( mRotationRate > 360 ) mRotationRate -= 360; mRotation->Set(mRotationRate,mRotation->y, mRotation->z, mRotation->w); objpos.Rotate(mRotation->x + 270,mRotation->y,mRotation->z,mRotation->w); mPosition->x += mVelocity->x; mPosition->z += mVelocity->z; objpos.SetPosition(*mPosition); worldviewproj = objpos; Matrix viewProj = *gCamera->GetViewProjection(); worldviewproj.Multiply( &viewProj ); RenderSetup(&worldviewproj); GLuint PositionHandle = mShader->getAttribute("a_Position"); GLuint TintHandle = mShader->getAttribute("a_Tint"); GLuint UVHandle = mShader->getAttribute("a_UVCoord"); if(PositionHandle != -1) { glVertexAttribPointer(PositionHandle, 3, GL_FLOAT, GL_FALSE, sizeof(VertDef), &mModel->m_pVerts->pos ); glEnableVertexAttribArray( PositionHandle ); } if(TintHandle != -1) { glVertexAttribPointer( TintHandle, 4, GL_FLOAT, GL_FALSE, sizeof(VertDef), &mModel->m_pVerts->col ); glEnableVertexAttribArray( TintHandle ); } if(UVHandle != -1) { glVertexAttribPointer( UVHandle, 2, GL_FLOAT, GL_FALSE, sizeof(VertDef), &mModel->m_pVerts->uv ); glEnableVertexAttribArray( UVHandle ); } glDrawElements(GL_TRIANGLES, mModel->m_NumIndices, GL_UNSIGNED_SHORT, mModel->m_pIndices); } mShader->DisableAttributes(); }
avtDataObject_p IceTNetworkManager::Render( bool checkThreshold, intVector networkIds, bool getZBuffer, int annotMode, int windowID, bool leftEye) { int t0 = visitTimer->StartTimer(); DataNetwork *origWorkingNet = workingNet; avtDataObject_p retval; EngineVisWinInfo &viswinInfo = viswinMap[windowID]; viswinInfo.markedForDeletion = false; VisWindow *viswin = viswinInfo.viswin; std::vector<avtPlot_p>& imageBasedPlots = viswinInfo.imageBasedPlots; renderings = 0; TRY { this->StartTimer(); RenderSetup(windowID, networkIds, getZBuffer, annotMode, leftEye, checkThreshold); bool plotDoingTransparencyOutsideTransparencyActor = false; for(size_t i = 0 ; i < networkIds.size() ; i++) { workingNet = NULL; UseNetwork(networkIds[i]); if(this->workingNet->GetPlot()->ManagesOwnTransparency()) { plotDoingTransparencyOutsideTransparencyActor = true; } } workingNet = NULL; // We can't easily figure out a compositing order, which IceT requires // in order to properly composite transparent geometry. Thus if there // is some transparency, fallback to our parent implementation. avtTransparencyActor* trans = viswin->GetTransparencyActor(); bool transparenciesExist = trans->TransparenciesExist() || plotDoingTransparencyOutsideTransparencyActor; if (transparenciesExist) { debug2 << "Encountered transparency: falling back to old " "SR / compositing routines." << std::endl; retval = NetworkManager::RenderInternal(); } else { bool needZB = !imageBasedPlots.empty() || renderState.shadowMap || renderState.depthCues; // Confusingly, we need to set the input to be *opposite* of what VisIt // wants. This is due to (IMHO) poor naming in the IceT case; on the // input side: // ICET_DEPTH_BUFFER_BIT set: do Z-testing // ICET_DEPTH_BUFFER_BIT not set: do Z-based compositing. // On the output side: // ICET_DEPTH_BUFFER_BIT set: readback of Z buffer is allowed // ICET_DEPTH_BUFFER_BIT not set: readback of Z does not work. // In VisIt's case, we calculated a `need Z buffer' predicate based // around the idea that we need the Z buffer to do Z-compositing. // However, IceT \emph{always} needs the Z buffer internally -- the // flag only differentiates between `compositing' methodologies // (painter-style or `over' operator) on input. GLenum inputs = ICET_COLOR_BUFFER_BIT; GLenum outputs = ICET_COLOR_BUFFER_BIT; // Scratch all that, I guess. That might be the correct way to go // about things in the long run, but IceT only gives us back half an // image if we don't set the depth buffer bit. The compositing is a // bit wrong, but there's not much else we can do.. // Consider removing the `hack' if a workaround is found. if (/*hack*/true/*hack*/) // || !this->MemoMultipass(viswin)) { inputs |= ICET_DEPTH_BUFFER_BIT; } if(needZB) { outputs |= ICET_DEPTH_BUFFER_BIT; } ICET(icetInputOutputBuffers(inputs, outputs)); // If there is a backdrop image, we need to tell IceT so that it can // composite correctly. if(viswin->GetBackgroundMode() != AnnotationAttributes::Solid) { ICET(icetEnable(ICET_CORRECT_COLORED_BACKGROUND)); } else { ICET(icetDisable(ICET_CORRECT_COLORED_BACKGROUND)); } if (renderState.renderOnViewer) { RenderCleanup(); avtDataObject_p dobj = NULL; CATCH_RETURN2(1, dobj); } debug5 << "Rendering " << viswin->GetNumPrimitives() << " primitives." << endl; int width, height, width_start, height_start; // This basically gets the width and the height. // The distinction is for 2D rendering, where we only want the // width and the height of the viewport. viswin->GetCaptureRegion(width_start, height_start, width, height, renderState.viewportedMode); this->TileLayout(width, height); CallInitializeProgressCallback(this->RenderingStages()); // IceT mode is different from the standard network manager; we don't // need to create any compositor or anything: it's all done under the // hood. // Whether or not to do multipass rendering (opaque first, translucent // second) is all handled in the callback; from our perspective, we // just say draw, read back the image, and post-process it. // IceT sometimes omits large parts of Curve plots when using the // REDUCE strategy. Use a different compositing strategy for Curve // plots to avoid the problem. if(viswin->GetWindowMode() == WINMODE_CURVE) ICET(icetStrategy(ICET_STRATEGY_VTREE)); else ICET(icetStrategy(ICET_STRATEGY_REDUCE)); ICET(icetDrawFunc(render)); ICET(icetDrawFrame()); // Now that we're done rendering, we need to post process the image. debug3 << "IceTNM: Starting readback." << std::endl; avtImage_p img = this->Readback(viswin, needZB); // Now its essentially back to the same behavior as our parent: // shadows // depth cueing // post processing if (renderState.shadowMap) this->RenderShadows(img); if (renderState.depthCues) this->RenderDepthCues(img); // If the engine is doing more than just 3D annotations, // post-process the composited image. RenderPostProcess(img); CopyTo(retval, img); } RenderCleanup(); } CATCHALL { RenderCleanup(); RETHROW; } ENDTRY workingNet = origWorkingNet; visitTimer->StopTimer(t0, "Ice-T Render"); return retval; }