psEffectAnchor::psEffectAnchor() { engine = csQueryRegistry<iEngine> (psCSSetup::object_reg); objEffectPos = csVector3(0,0,0); objBasePos = csVector3(0,0,0); objTargetOffset = csVector3(0,0,0); objOffset = csVector3(0,0,0); posTransf.Identity(); targetTransf.Identity(); dir = DT_NONE; keyFrames.AttachNew(new psEffectAnchorKeyFrameGroup); isReady = false; animLength = 10; FillInLerps(); }
bool psEffectAnchor::Load(iDocumentNode *node) { name = node->GetAttributeValue("name"); csRef<iDocumentNode> dataNode; // direction dataNode = node->GetNode("dir"); dir = DT_NONE; if (dataNode) { SetDirectionType(dataNode->GetContentsValue()); } // KEYFRAMES csRef<iDocumentNodeIterator> xmlbinds; xmlbinds = node->GetNodes("keyFrame"); csRef<iDocumentNode> keyNode; animLength = 0; psEffectAnchorKeyFrame * prevKeyFrame = 0; while (xmlbinds->HasNext()) { keyNode = xmlbinds->Next(); psEffectAnchorKeyFrame * keyFrame = new psEffectAnchorKeyFrame(keyNode, prevKeyFrame); if (keyFrame->time > animLength) animLength = keyFrame->time; prevKeyFrame = keyFrame; keyFrames->Push(keyFrame); } animLength += 10; // TODO: sort keyframes by time here // linearly interpolate values where an action wasn't specified FillInLerps(); return true; }
bool psEffectObj::Load(iDocumentNode *node, iLoaderContext* /*ldr_context*/) { csRef<iDocumentNode> dataNode; // birth dataNode = node->GetNode("birth"); if (dataNode) { birth = dataNode->GetContentsValueAsFloat(); if (birth > 0) isAlive = false; } // death dataNode = node->GetNode("death"); if (dataNode) { killTime = dataNode->GetContentsValueAsInt(); } else { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Effect obj %s is missing a <death> tag. If you want an infinite effect use <death>none</death>\n", name.GetData()); return false; // effect is invalid without a death tag } // time scaling dataNode = node->GetNode("scale"); if (dataNode) { if(dataNode->GetAttributeValueAsBool("death")) autoScale |= SCALING_DEATH; if(dataNode->GetAttributeValueAsBool("birth")) autoScale |= SCALING_BIRTH; if(dataNode->GetAttributeValueAsBool("frames")) autoScale |= SCALING_FRAMES; else if(dataNode->GetAttributeValueAsBool("loop")) autoScale |= SCALING_LOOP; } // anchor dataNode = node->GetNode("attach"); if (dataNode) SetAnchorName(dataNode->GetContentsValue()); // render priority dataNode = node->GetNode("priority"); if (dataNode) priority = engine->GetRenderPriority(dataNode->GetContentsValue()); else priority = engine->GetAlphaRenderPriority(); // z func if (node->GetNode("znone")) zFunc = CS_ZBUF_NONE; else if (node->GetNode("zfill")) zFunc = CS_ZBUF_FILL; else if (node->GetNode("zuse")) zFunc = CS_ZBUF_USE; else if (node->GetNode("ztest")) zFunc = CS_ZBUF_TEST; // mix mode dataNode = node->GetNode("mixmode"); if (dataNode) { csString mix = dataNode->GetContentsValue(); mix.Downcase(); if (mix == "copy") mixmode = CS_FX_COPY; else if (mix == "mult") mixmode = CS_FX_MULTIPLY; else if (mix == "mult2") mixmode = CS_FX_MULTIPLY2; else if (mix == "alpha") mixmode = CS_FX_ALPHA; else if (mix == "transparent") mixmode = CS_FX_TRANSPARENT; else if (mix == "destalphaadd") mixmode = CS_FX_DESTALPHAADD; else if (mix == "srcalphaadd") mixmode = CS_FX_SRCALPHAADD; else if (mix == "premultalpha") mixmode = CS_FX_PREMULTALPHA; else mixmode = CS_FX_ADD; } else mixmode = CS_FX_ADD; // direction dataNode = node->GetNode("dir"); if (dataNode) { csString dirName = dataNode->GetContentsValue(); dirName.Downcase(); if (dirName == "target") dir = DT_TARGET; else if (dirName == "origin") dir = DT_ORIGIN; else if (dirName == "totarget") dir = DT_TO_TARGET; else if (dirName == "camera") dir = DT_CAMERA; else if (dirName == "billboard") dir = DT_BILLBOARD; else dir = DT_NONE; } else dir = DT_NONE; // KEYFRAMES csRef<iDocumentNodeIterator> xmlbinds; xmlbinds = node->GetNodes("keyFrame"); csRef<iDocumentNode> keyNode; animLength = 0; psEffectObjKeyFrame *prevKeyFrame = 0; while (xmlbinds->HasNext()) { keyNode = xmlbinds->Next(); psEffectObjKeyFrame * keyFrame = new psEffectObjKeyFrame(keyNode, prevKeyFrame); if (keyFrame->time > animLength) animLength = keyFrame->time; prevKeyFrame = keyFrame; keyFrames->Push(keyFrame); } animLength += 10; // TODO: sort keyframes by time here // linearly interpolate values where an action wasn't specified FillInLerps(); return true; }