void gkScene::setAmbientColor(const gkColor& col) { if (isInstanced()) { GK_ASSERT(m_manager); m_manager->setAmbientLight(col); } else { m_baseProps.m_material.m_ambient = col; } }
void gkGameObjectInstance::cloneObjects(gkScene* scene, const gkTransformState& from, int time, const gkVector3& linearVelocity, bool tsLinLocal, const gkVector3& angularVelocity, bool tsAngLocal) { if (!isInstanced()) return; GK_ASSERT(scene); const gkMatrix4 plocal = from.toMatrix(); Objects::Iterator iter = m_objects.iterator(); while (iter.hasMoreElements()) { gkGameObject* oobj = iter.getNext().second; gkGameObject* nobj = scene->cloneObject(oobj, time); // be sure this info was not cloned! GK_ASSERT(!nobj->isGroupInstance()); // Update transform relative to owner gkGameObjectProperties& props = nobj->getProperties(); gkMatrix4 clocal; props.m_transform.toMatrix(clocal); // merge back to transform state props.m_transform = gkTransformState(plocal * clocal); nobj->createInstance(); if (props.isRigidOrDynamic() || props.isGhost()) { if (!linearVelocity.isZeroLength()) nobj->setLinearVelocity(linearVelocity, tsLinLocal ? TRANSFORM_LOCAL : TRANSFORM_PARENT); } if (props.isRigid()) { if (!angularVelocity.isZeroLength()) nobj->setAngularVelocity(angularVelocity, tsAngLocal ? TRANSFORM_LOCAL : TRANSFORM_PARENT); } } }
void gkScene::setZenithColor(const gkColor& col) { if (isInstanced()) { GK_ASSERT(m_manager && m_viewport); m_viewport->getViewport()->setBackgroundColour(col); } else { // save for reinstanced state. m_baseProps.m_material.m_horizon = col; } }
void gkScene::beginFrame(void) { if (!isInstanced()) return; // end any objects up for removal endObjects(); GK_ASSERT(m_physicsWorld); m_physicsWorld->resetContacts(); #ifdef OGREKIT_OPENAL_SOUND // process sounds waiting to be finished gkSoundManager::getSingleton().collectGarbage(); #endif }
static void convertInputElements(D3D11_INPUT_ELEMENT_DESC* out, JBKShaderInputElement* elements, uint32_t elementCount) { uint32_t offsets[16] = { 0 }; for (uint32_t i = 0; i < elementCount; i++) { uint32_t slot = elements[i].slot; JBKShaderFormat format = elements[i].format; uint8_t instanced = isInstanced(format); out[i].SemanticName = elements[i].name; out[i].SemanticIndex = elements[i].index; out[i].Format = JBKD3DUtils_ConvertFormat(format); out[i].InputSlot = slot; out[i].AlignedByteOffset = offsets[slot]; out[i].InputSlotClass = instanced ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA; out[i].InstanceDataStepRate = instanced ? 1 : 0; offsets[slot] += getElementSize(format); } }
gkDebugger* gkScene::getDebugger(void) { if (isInstanced() && !m_debugger) m_debugger = new gkDebugger(this); return m_debugger; }
void gkScene::update(gkScalar tickRate) { if (!isInstanced()) return; GK_ASSERT(m_physicsWorld); // update simulation if (m_updateFlags & UF_PHYSICS) { gkStats::getSingleton().startClock(); m_physicsWorld->step(tickRate); gkStats::getSingleton().stopPhysicsClock(); } // update logic bricks if (m_updateFlags & UF_LOGIC_BRICKS) { gkStats::getSingleton().startClock(); gkLogicManager::getSingleton().update(tickRate); gkStats::getSingleton().stopLogicBricksClock(); } #ifdef OGREKIT_USE_NNODE // update node trees if (m_updateFlags & UF_NODE_TREES) { gkStats::getSingleton().startClock(); gkNodeManager::getSingleton().update(tickRate); gkStats::getSingleton().stopLogicNodesClock(); } #endif // update animations if (m_updateFlags & UF_ANIMATIONS) { gkStats::getSingleton().startClock(); updateObjectsAnimations(tickRate); gkStats::getSingleton().stopAnimationsClock(); } #ifdef OGREKIT_OPENAL_SOUND // update sound manager. if (m_updateFlags & UF_SOUNDS) { gkStats::getSingleton().startClock(); gkSoundManager::getSingleton().update(this); gkStats::getSingleton().stopSoundClock(); } #endif if (m_updateFlags & UF_DBVT) { gkStats::getSingleton().startClock(); if (m_markDBVT) { m_markDBVT = false; m_physicsWorld->handleDbvt(m_startCam); } gkStats::getSingleton().stopDbvtClock(); } if (m_updateFlags & UF_DEBUG) { if (m_debugger) { m_physicsWorld->DrawDebug(); m_debugger->flush(); } } // tick life span tickClones(); // Free any endObjects(); }