Пример #1
0
Any Entity::toAny() const {
    Any a = m_sourceAny;
    debugAssert(! a.isNil());
    if (a.isNil()) {
        // Fallback for release mode failure
        return a;
    }

    if (m_movedSinceLoad) {
        a["frame"] = m_frame;
    }

    const shared_ptr<SplineTrack>& splineTrack = dynamic_pointer_cast<SplineTrack>(m_track);
    if (notNull(splineTrack) && splineTrack->changed()) {
        // Update the spline
        const PhysicsFrameSpline& spline = splineTrack->spline();
        if (spline.control.size() == 1) {
            // Write out in short form for the single control point
            const PhysicsFrame& p = spline.control[0];
            if (p.rotation == Quat()) {
                // No rotation
                a["track"] = p.translation;
            } else {
                // Full coordinate frame
                a["track"] = CFrame(p);
            }
        } else {
            // Write the full spline
            a["track"] = spline;
        }
    }

    a.setName("Entity");
    return a;
}
Пример #2
0
void App::playSculpture(const Ray& playRay) {
  int maxDistance = 0;
  int startIndex = g_sampleWindowIndex;
  for (auto piece : m_sonicSculpturePieces) {
    const shared_ptr<AudioSample>& sample = piece->getAudioSampleFromRay(playRay);
    if (sample->buffer.size() > 0) {
        maxDistance = max(maxDistance, (int)ceil(sample->buffer.size() / 512.0f));
        Synthesizer::global->queueSound(sample);
        m_lastInterestingEventTime = System::time();
    }
  }
  if (maxDistance > 0) {
    PlayPlane pp;
    pp.direction = playRay.direction();
    pp.origin = playRay.origin();
    pp.beginWindowIndex = startIndex;
    pp.endWindowIndex = startIndex + maxDistance;

    Vector3 zAxis = -playRay.direction();
	Vector3 xAxis;
	if (abs(zAxis.dot(Vector3::unitY())) < 0.9f) {
	  xAxis = zAxis.unitCross(Vector3::unitY());
	} else {
	  xAxis = zAxis.unitCross(Vector3::unitX());
	}
	Vector3 yAxis = zAxis.cross(xAxis);

	pp.frame = CFrame(Matrix3::fromColumns(xAxis, yAxis, zAxis), pp.origin);


    m_playPlanes.append(pp);
  }
}
Пример #3
0
void ArticulatedViewer::onGraphics3D(RenderDevice* rd, App* app, const shared_ptr<LightingEnvironment>& lighting, Array<shared_ptr<Surface> >& allSurfaces) {
    // app->gbuffer()->setSpecification(m_gbufferSpecification);
    app->gbuffer()->resize(app->framebuffer()->width(), app->framebuffer()->height());
    app->gbuffer()->prepare(rd, app->activeCamera(), 0, -(float)app->previousSimTimeStep(), app->settings().depthGuardBandThickness, app->settings().colorGuardBandThickness);

    app->renderer()->render(rd, app->framebuffer(), app->depthPeelFramebuffer(), *lighting, app->gbuffer(), allSurfaces);

    Array<Point3> skeletonLines;
    
    m_model->getSkeletonLines(m_pose, m_offset, skeletonLines);
    
    rd->pushState(); {
        rd->setObjectToWorldMatrix(CFrame());
        rd->setDepthTest(RenderDevice::DEPTH_ALWAYS_PASS);
        for (int i = 0; i < skeletonLines.size(); i += 2) {
            Draw::lineSegment(LineSegment::fromTwoPoints(skeletonLines[i], skeletonLines[i + 1]), rd, Color3::red());
        }
    } rd->popState();
    

    //Surface::renderWireframe(rd, posed3D);

    if (m_selectedMesh != NULL) {
        // Find the index array that matches the selected mesh and render it
        for (int p = 0; p < allSurfaces.size(); ++p) {
            const shared_ptr<UniversalSurface>& s = dynamic_pointer_cast<UniversalSurface>(allSurfaces[p]);

            if (s->gpuGeom()->index == m_selectedMesh->gpuIndexArray) {
                // These have the same index array, so they must be the same surface
                s->renderWireframeHomogeneous(rd, Array<shared_ptr<Surface> >(s), Color3::green(), false);
                break;
            }
        }
    }

    float x, y, z, yaw, pitch, roll;
    app->activeCamera()->frame().getXYZYPRDegrees(x,y,z,yaw, pitch, roll);
    screenPrintf("[Camera position: Translation(%f, %f, %f) Rotation(%f, %f, %f)]\n", x,y,z,yaw,pitch,roll);
    screenPrintf("[Shown scaled by %f and offset by (%f, %f, %f)]\n",
                 m_scale, m_offset.x, m_offset.y, m_offset.z);
    
    screenPrintf("Model Faces: %d,  Vertices: %d\n", m_numFaces, m_numVertices);
    if (m_selectedPart != NULL) {
        screenPrintf(" Selected Part `%s', Mesh `%s', Material `%s', cpuIndexArray[%d...%d]\n", 
                     m_selectedPart->name.c_str(), 
                     m_selectedMesh->name.c_str(), 
					 m_selectedMesh->material->name().c_str(),
                     m_selectedTriangleIndex, m_selectedTriangleIndex + 2);
        screenPrintf(" Selected part->cframe = %s\n",
                     m_selectedPart->cframe.toXYZYPRDegreesString().c_str());
    }

    screenPrintf("Hierarchy:");
    // Hierarchy (could do this with a PartCallback)
    for (int i = 0; i < m_model->rootArray().size(); ++i) {
        printHierarchy(m_model, m_model->rootArray()[i], "");
    }
}
Пример #4
0
 virtual CFrame computeFrame(SimTime time) const override {
     shared_ptr<Entity> e = m_scene->entity(m_entityName);
     if (notNull(e)) {
         return e->frame();
     } else {
         // Maybe during initialization and the other entity does not yet exist
         return CFrame();
     }
 }
Пример #5
0
std::ostream& operator<< (std::ostream &out, Frame &CFrame)
{
	for(size_t j=0; j<CFrame.GetNRow(); j++)
	{
		for(size_t i=0; i<CFrame.GetNCol(); i++)
		{
			out << CFrame(i,j) << " ";
		}
		out << std::endl;
	}
	return out;
}
void PhysicsFrameSplineEditor::addControlPoint() {
    if (m_spline.control.size() == 0) {
        m_spline.append(CFrame());
    } else if (m_spline.control.size() == 1) {
        // Adding the 2nd point
        CFrame f = m_spline.control.last();
        f.translation += f.lookVector();
        m_spline.append(f);

        resizeControlPointDropDown(m_spline.control.size());
        // Select the new point
        setSelectedControlPointIndex(m_selectedControlPointIndex + 1);
    } else {
        // Adding between two points
        float t0 = m_spline.time[m_selectedControlPointIndex];
        float newT = t0;
        float evalT = 0;
        if (m_selectedControlPointIndex < m_spline.control.size() - 1) {
            // Normal interval
            newT = m_spline.time[m_selectedControlPointIndex + 1];
            evalT = (t0 + newT) / 2;
        } else if (m_spline.extrapolationMode == SplineExtrapolationMode::CYCLIC) {
            // After the end on a cyclic spline
            newT = m_spline.getFinalInterval() + t0;
            evalT = (t0 + newT) / 2;
        } else {
            // After the end on a non-cyclic spline of length at least
            // 2; assume that we want to step the distance of the previous
            // interval
            newT = evalT = 2.0f * t0 - m_spline.time[m_selectedControlPointIndex - 1];
        }

        const PhysicsFrame f = m_spline.evaluate(evalT);
        m_spline.control.insert(m_selectedControlPointIndex + 1, f);
        m_spline.time.insert(m_selectedControlPointIndex + 1, newT);

        // Select the new point
        resizeControlPointDropDown(m_spline.control.size());
        setSelectedControlPointIndex(m_selectedControlPointIndex + 1);

        // Fix the rest of the times to be offset by the inserted duration
        float shift = newT - t0;
        for (int i = m_selectedControlPointIndex + 1; i < m_spline.time.size(); ++i) {
            m_spline.time[i] += shift;
        }
        
    }

}
Пример #7
0
Matrix4::Matrix4(const Any& any) {
    any.verifyNameBeginsWith("Matrix4", "CFrame", "CoordinateFrame");
    any.verifyType(Any::ARRAY);

    const std::string& name = any.name();
    if (name == "Matrix4") {
        any.verifySize(16);

        for (int r = 0; r < 4; ++r) {
            for (int c = 0; c < 4; ++c) {
                elt[r][c] = any[r * 4 + c];
            }
        }
    } else if (name == "Matrix4::scale") {
        if (any.size() == 1) {
            *this = scale(any[0].floatValue());
        } else if (any.size() == 3) {
            *this = scale(any[0], any[1], any[2]);
        } else {
            any.verify(false, "Matrix4::scale() takes either 1 or 3 arguments");
        }
    } else if (name == "Matrix4::rollDegrees") {
        any.verifySize(1);
        *this = rollDegrees(any[0].floatValue());
    } else if (name == "Matrix4::yawDegrees") {
        any.verifySize(1);
        *this = yawDegrees(any[0].floatValue());
    } else if (name == "Matrix4::pitchDegrees") {
        any.verifySize(1);
        *this = pitchDegrees(any[0].floatValue());
    } else if (name == "Matrix4::translation") {
        if (any.size() == 3) {
            *this = translation(any[0], any[1], any[2]);
        } else {
            any.verify(false, "Matrix4::translation() requires 3 arguments");
        }    
    } else if (name == "Matrix4::diagonal") {
        any.verifySize(4);
        *this = diagonal(any[0], any[1], any[2], any[3]);
    } else if (name == "Matrix4::identity") {
        *this = identity();
    } else if (beginsWith(name, "CFrame") || beginsWith(name, "CoordinateFrame")) {
        *this = CFrame(any);
    } else {
        any.verify(false, "Expected Matrix4 constructor");
    }
}
Пример #8
0
void VisibleEntity::debugDrawVisualization(RenderDevice* rd, VisualizationMode mode) {
    alwaysAssertM(mode == SKELETON, "Bounds visualization not implemented");
    Array<Point3> skeletonLines;
    switch (m_modelType) {
    case ARTICULATED_MODEL:
        m_artModel->getSkeletonLines(m_artPose, m_frame, skeletonLines);
        break;
    default:
        break;
    }
    rd->pushState(); {
        rd->setObjectToWorldMatrix(CFrame());
        rd->setDepthTest(RenderDevice::DEPTH_ALWAYS_PASS);
        for (int i = 0; i < skeletonLines.size(); i += 2) {
            Draw::lineSegment(LineSegment::fromTwoPoints(skeletonLines[i], skeletonLines[i+1]), rd, Color3::red());
        }
    } rd->popState();
}
std::string PhysicsFrameSplineEditor::selectedNodePFrameAsString() const {
    if (m_selectedControlPointIndex >= 0 && m_selectedControlPointIndex < m_spline.control.size()) {

        const PhysicsFrame& pframe = m_spline.control[m_selectedControlPointIndex];

        // Cache the string so that we don't have to reparse it for every rendering
        if (m_cachedPhysicsFrameValue != pframe) {
            m_cachedPhysicsFrameValue = pframe;
            m_cachedPhysicsFrameString = CFrame(m_cachedPhysicsFrameValue).toAny().unparse();
        }

        return m_cachedPhysicsFrameString;

    } else {

        return "Point3(0, 0, 0)";

    }
}
Пример #10
0
CoordinateFrame::CoordinateFrame(const Any& any) {
    *this = CFrame();

    const std::string& n = toUpper(any.name());

    if (beginsWith(n, "VECTOR3")) {
        translation = any;
    } else if (beginsWith(n, "MATRIX3")) {
        rotation = any;
    } else if ((n == "CFRAME") || (n == "COORDINATEFRAME")) {
        any.verifyType(Any::TABLE, Any::ARRAY);
        if (any.type() == Any::ARRAY) {
            any.verifySize(2);
            rotation    = any[0];
            translation = any[1];
        } else {
            for (Any::AnyTable::Iterator it = any.table().begin(); it.hasMore(); ++it) {
                const std::string& n = toLower(it->key);
                if (n == "translation") {
                    translation = Vector3(it->value);
                } else if (n == "rotation") {
                    rotation = Matrix3(it->value);
                } else {
                    any.verify(false, "Illegal table key: " + it->key);
                }
            }
        }
    } else if (beginsWith(n, "PHYSICSFRAME") || beginsWith(n, "PFRAME")) {
        *this = PhysicsFrame(any);
    } else {
        any.verifyName("CFrame::fromXYZYPRDegrees", "CoordinateFrame::fromXYZYPRDegrees");
        any.verifyType(Any::ARRAY);
        any.verifySize(3, 6);

        int s = any.size();

        *this = fromXYZYPRDegrees(any[0], any[1], any[2],
                                  (s > 3) ? any[3].number() : 0.0f,
                                  (s > 4) ? any[4].number() : 0.0f,
                                  (s > 5) ? any[5].number() : 0.0f);
    }
}
Пример #11
0
void App::onInit() {
	tick();

    message("Loading...");
	renderDevice->setSwapBuffersAutomatically(true);

	m_world = new World(m_worldScene);

    // Create one random number generator per thread
    m_rng.resize(GThread::numCores());
    for (int i = 0; i < m_rng.size(); ++i) {
        //m_rng[i].reset(0xF018A4D2 ^ i, false);
		//m_rng[i].reset(uint32(System::time()) ^ i);
    }
	Array<Plane,10> clipPlanes;
	float a,b,c,d;

    showRenderingStats = false;
    createDeveloperHUD();
    developerWindow->setVisible(false);
    developerWindow->cameraControlWindow->setVisible(false);
    m_debugCamera->filmSettings().setAntialiasingEnabled(false);
	m_debugCamera->filmSettings().setAntialiasingHighQuality(false);
	m_debugCamera->filmSettings().setBloomStrength(0.0f);
	m_debugCamera->setFrame(m_world->frame);
	m_debugCamera->setFieldOfView(m_world->FOVDeg*pi()/180.0,FOVDirection::VERTICAL);
	m_debugCamera->getClipPlanes(Rect2D(Vector2(window()->width(),window()->height())),clipPlanes);

	clipPlanes[0].getEquation(a,b,c,d);
	m_focalPlane = Plane::fromEquation(-a,-b,-c,-(d-(m_world->focalDist)));	
	
    makeGUI();
    // Force re-render on first frame
    m_prevCFrame = CFrame(Matrix3::zero());
	float time = tock("Loading scene");

	//Initialize StatsData class 
	m_featureData.init(m_imgWidth,m_imgHeight,m_sampleBudget,m_samplesPerIteration);
	//Initialize filter with the features data pointers;
	m_CBFilter.init(&m_featureData);
}
Пример #12
0
void App::onInit() {
    message("Loading...");
	
    m_world = new World();
	
    showRenderingStats = false;
    createDeveloperHUD();
    developerWindow->setVisible(false);
    developerWindow->cameraControlWindow->setVisible(false);
    m_debugCamera->filmSettings().setAntialiasingEnabled(true);
    m_debugCamera->filmSettings().setContrastToneCurve();

    // Starting position
    m_debugCamera->setFrame(CFrame::fromXYZYPRDegrees(24.3f, 0.4f, 2.5f, 68.7f, 1.2f, 0.0f));
    m_debugCamera->frame();

    makeGUI();

    // Force re-render on first frame
    m_prevCFrame = CFrame(Matrix3::zero());
}
Пример #13
0
CoordinateFrame::CoordinateFrame(const Any& any) {
    *this = CFrame();

    const String& n = toUpper(any.name());

    if (beginsWith(n, "VECTOR3") || beginsWith(n, "POINT3")) {
        translation = Point3(any);
    } else if (beginsWith(n, "MATRIX3")) {
        rotation = Matrix3(any);
    } else if (beginsWith(n, "MATRIX4")) {
        *this = Matrix4(any).approxCoordinateFrame();
    } else if ((n == "CFRAME") || (n == "COORDINATEFRAME")) {
        any.verifyType(Any::TABLE, Any::ARRAY);
        if (any.type() == Any::ARRAY) {
            any.verifySize(2);
            rotation    = any[0];
            translation = any[1];
        } else {
            AnyTableReader r(any);
            r.getIfPresent("translation", translation);
            r.getIfPresent("rotation", rotation);
            r.verifyDone();
        }
    } else if (beginsWith(n, "PHYSICSFRAME") || beginsWith(n, "PFRAME")) {
        *this = PhysicsFrame(any);
//    } else if (beginsWith(n, "UPRIGHTFRAME") || beginsWith(n, "UFRAME")) {
//        *this = UprightFrame(any);
    } else {
        any.verifyName("CFrame::fromXYZYPRDegrees", "CoordinateFrame::fromXYZYPRDegrees");
        any.verifyType(Any::ARRAY);
        any.verifySize(3, 6);

        int s = any.size();

        *this = fromXYZYPRDegrees(any[0], any[1], any[2], 
                                  (s > 3) ? (float)any[3].number() : 0.0f,
                                  (s > 4) ? (float)any[4].number() : 0.0f,
                                  (s > 5) ? (float)any[5].number() : 0.0f);
    }
}
Пример #14
0
Box Frustum::boundingBox(float minObjectSpaceDepth) const {

    debugAssert(minObjectSpaceDepth > 0);
    const float minFarPlaneZ = -minObjectSpaceDepth;

    AABox aabb;

    // Object space axes; we don't care about translation because we move back to world space at the end
    const Vector3& X = (vertexPos[1] - vertexPos[0]).xyz().direction();
    const Vector3& Y = (vertexPos[2] - vertexPos[1]).xyz().direction();
    const Vector3& Z = X.cross(Y);

    const Point3&  C = vertexPos[0].xyz();

    // Compute the world-to-object matrix, which is the transpose
    // of the object
    const Matrix3& M = Matrix3::fromRows(X, Y, Z);

    for (int v = 0; v < 8; ++v) {
        // World-space point
        const Vector4& P = vertexPos[v];

        // Object-space point (ignoring translation)
        const Point3&  Q = M * P.xyz() - C;

        // Project the point if infinite
        if ((P.w == 0.0f) || (Q.z < minFarPlaneZ)) {
            // Project onto z = minFarPlaneZ
            const float s = minFarPlaneZ / Q.z;
            aabb.merge(Point3(Q.x * s, Q.y * s, minFarPlaneZ));
        } else {
            // World-space point
            aabb.merge( M * (Q / P.w) );
        }
    }

    // Transform box to world space
    return CFrame(M.transpose(), C).toWorldSpace(aabb);
}
void ArticulatedModel::loadHeightfield(const Specification& specification) {
    Part* part = addPart("root");
    Geometry* geom = addGeometry("geom");
    Mesh* mesh = addMesh("mesh", part, geom);
    mesh->material = UniversalMaterial::create();

    shared_ptr<Image1> im = Image1::fromFile(specification.filename);

    geom->cpuVertexArray.hasTangent = false;
    geom->cpuVertexArray.hasTexCoord0 = true;

    const bool spaceCentered = true;
    const bool generateBackFaces = specification.heightfieldOptions.generateBackfaces;
    const Vector2& textureScale  = specification.heightfieldOptions.textureScale;

    Array<Point3> vertex;
    Array<Point2> texCoord;
    MeshAlg::generateGrid
    (vertex, texCoord, mesh->cpuIndexArray,
     im->width(), im->height(), textureScale,
     spaceCentered,
     generateBackFaces,
     CFrame(Matrix4::scale((float)im->width(), 1.0, (float)im->height()).upper3x3()),
     im);


    // Copy the vertex data into the mesh
    geom->cpuVertexArray.vertex.resize(vertex.size());
    CPUVertexArray::Vertex* vertexPtr = geom->cpuVertexArray.vertex.getCArray();
    for (uint32 i = 0; i < (uint32)vertex.size(); ++i) {
        CPUVertexArray::Vertex& v = vertexPtr[i];
        v.position = vertex[i];
        v.texCoord0 = texCoord[i];
        v.tangent.x = v.normal.x = fnan();
    } // for
}
Пример #16
0
#include "Local.h"
#include "Monsters/Bitch.h"

CMaiden::CMaiden (uint32 ID) :
IMonster(ID)
{
}

void CMaiden::Moan ()
{
	Entity->PlaySound (CHAN_VOICE, (frand() < 0.5) ? Sounds[SOUND_IDLE1] : Sounds[SOUND_IDLE2], 255, ATTN_IDLE);
}

CFrame ChickFramesFidget [] =
{
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0,  ConvertDerivedFunction(&CMaiden::Moan)),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
Пример #17
0
CFrame::CFrame(CFrame& Frame) 
{
	CFrame(Frame.m_sx,Frame.m_sy);
	memcpy(m_pFrame, Frame.m_pFrame, sizeof(PIXEL)*m_sx*m_sy);
}
PhysicsFrameSplineEditor::PhysicsFrameSplineEditor(const GuiText& caption, GuiPane* dockPane, shared_ptr<GuiTheme> theme) : 
    GuiWindow(caption,
              theme,
              Rect2D::xywh(0,0,100,40), 
              GuiTheme::TOOL_WINDOW_STYLE,
              GuiWindow::HIDE_ON_CLOSE),
    m_selectedControlPointIndex(0),
    m_isDocked(dockPane != NULL)
    {

    m_cachedPhysicsFrameString = CFrame(m_cachedPhysicsFrameValue).toAny().unparse();
    m_spline.append(CFrame());

    m_surface.reset(new SplineSurface(this));
    m_nodeManipulator = ThirdPersonManipulator::create();
    m_nodeManipulator->setEnabled(false);

    GuiPane* p = dockPane;

    if (p == NULL) {
        // Place into the window
        p = pane();
    } else {
        // No need to show the window
        setVisible(false);
    }
    
    GuiPane* cpPane = p->addPane("Control Point", GuiTheme::ORNATE_PANE_STYLE);
    cpPane->moveBy(0, -15);

    Array<std::string> indexList;
    getIndexRange(1, indexList);
    m_selectedControlPointDropDown = cpPane->addDropDownList("Control point: ", indexList, &m_selectedControlPointIndex, 
                                        GuiControl::Callback(this, &PhysicsFrameSplineEditor::controlPointDropDownCallback));
    cpPane->addNumberBox("Time", Pointer<float>(this, &PhysicsFrameSplineEditor::selectedNodeTime, &PhysicsFrameSplineEditor::setSelectedNodeTime), "s");
    cpPane->addTextBox("", Pointer<std::string>(this, &PhysicsFrameSplineEditor::selectedNodePFrameAsString, &PhysicsFrameSplineEditor::setSelectedNodePFrameFromString));

    cpPane->beginRow(); {
        GuiButton* b = cpPane->addButton("Add new", this, &PhysicsFrameSplineEditor::addControlPoint);
        b->moveBy(-2, -7);
        m_removeSelectedButton = cpPane->addButton("Remove", this, &PhysicsFrameSplineEditor::removeSelectedControlPoint);
    } cpPane->endRow();
    cpPane->pack();
    GuiPane* exPane = p->addPane("Extrapolation Mode", GuiTheme::NO_PANE_STYLE);
    exPane->beginRow(); {
        GuiControl* linearButton  = exPane->addRadioButton("Linear", SplineExtrapolationMode::LINEAR, this, 
                                        &PhysicsFrameSplineEditor::extrapolationMode, &PhysicsFrameSplineEditor::setExtrapolationMode);
        GuiControl* clampedButton = exPane->addRadioButton("Clamped", SplineExtrapolationMode::CLAMP, this, 
                                        &PhysicsFrameSplineEditor::extrapolationMode, &PhysicsFrameSplineEditor::setExtrapolationMode);
        clampedButton->moveRightOf(linearButton);
        clampedButton->moveBy(-145, 0);
        GuiControl* cyclicButton  = exPane->addRadioButton("Cyclic", SplineExtrapolationMode::CYCLIC, this, 
                                        &PhysicsFrameSplineEditor::extrapolationMode, &PhysicsFrameSplineEditor::setExtrapolationMode);
        cyclicButton->moveRightOf(clampedButton);
        cyclicButton->moveBy(-140, 0);
    } exPane->endRow();
    exPane->pack();
    GuiPane* inPane = p->addPane("Interpolation Mode", GuiTheme::NO_PANE_STYLE);
    inPane->beginRow(); {
        GuiControl* linearButton = inPane->addRadioButton("Linear", SplineInterpolationMode::LINEAR, this, 
                                       &PhysicsFrameSplineEditor::interpolationMode, &PhysicsFrameSplineEditor::setInterpolationMode);
        GuiControl* cubicButton  = inPane->addRadioButton("Cubic", SplineInterpolationMode::CUBIC, this, 
                                       &PhysicsFrameSplineEditor::interpolationMode, &PhysicsFrameSplineEditor::setInterpolationMode); 
        cubicButton->moveRightOf(linearButton);
        cubicButton->moveBy(-145, 0);
    } inPane->endRow();
    inPane->pack();
    GuiPane* finalIntervalPane = p->addPane("Final Interval", GuiTheme::NO_PANE_STYLE);
    finalIntervalPane->moveRightOf(exPane);
    finalIntervalPane->moveBy(-100, -5);
    static int m_explicitFinalInterval = 0;
    m_finalIntervalChoice[0] = finalIntervalPane->addRadioButton("automatic", 0, &m_explicitFinalInterval);
    finalIntervalPane->beginRow(); {
        m_finalIntervalChoice[1] = finalIntervalPane->addRadioButton("", 1, &m_explicitFinalInterval);
        m_finalIntervalBox = finalIntervalPane->addNumberBox("", &m_spline.finalInterval, "s", GuiTheme::NO_SLIDER, -1.0f, 10000.0f, 0.001f);
        m_finalIntervalBox->setWidth(76);
        m_finalIntervalBox->moveBy(-2, 0);
    } finalIntervalPane->endRow();
    pack();

    setEnabled(false);
}
Пример #19
0
PhysicsFrameSplineEditor::PhysicsFrameSplineEditor(const GuiText& caption, GuiPane* dockPane, GuiTheme::Ref theme) : 
    GuiWindow(caption,
              theme,
              Rect2D::xywh(0,0,100,40), 
              GuiTheme::TOOL_WINDOW_STYLE,
              GuiWindow::HIDE_ON_CLOSE),
    m_selectedControlPointIndex(0),
    m_isDocked(dockPane != NULL) {

    m_cachedPhysicsFrameString = CFrame(m_cachedPhysicsFrameValue).toAny().unparse();
    m_spline.append(CFrame());

    m_surface = new SplineSurface(this);
    m_nodeManipulator = ThirdPersonManipulator::create();
    m_nodeManipulator->setEnabled(false);

    GuiPane* p = dockPane;

    if (p == NULL) {
        // Place into the window
        p = pane();
    } else {
        // No need to show the window
        setVisible(false);
    }
    
    GuiPane* cpPane = p->addPane("Control Point", GuiTheme::ORNATE_PANE_STYLE);
    cpPane->moveBy(0, -15);

    if (false) {
        static float x,y,z;
        //static const float translationControlWidth = 80;
        static const float rotationControlWidth    = 40;
        //static const float captionWidth = 10;
        static const float rotationPrecision = 0.1;
        //static const float translationPrecision = 0.001;
        static const std::string degrees = "\xba";
        cpPane->beginRow(); {
            GuiNumberBox<float>* c = NULL;
            static std::string s = "100.0, 100.0, 100.0";

            GuiControl* t = cpPane->addTextBox("xyz (", &s);
            t->setWidth(155);
            t->setCaptionWidth(26);
            cpPane->addLabel(") m");

            c = cpPane->addNumberBox("", &x, degrees, GuiTheme::NO_SLIDER, -finf(), finf(), rotationPrecision); 
            c->moveBy(20, 0);
            c->setCaptionWidth(0); c->setWidth(rotationControlWidth); c->setUnitsSize(8);

            c = cpPane->addNumberBox("", &y, degrees, GuiTheme::NO_SLIDER, -finf(), finf(), rotationPrecision); 
            c->setCaptionWidth(0); c->setWidth(rotationControlWidth); c->setUnitsSize(8);

            c = cpPane->addNumberBox("", &z, degrees, GuiTheme::NO_SLIDER, -finf(), finf(), rotationPrecision); 
            c->setCaptionWidth(0); c->setWidth(rotationControlWidth); c->setUnitsSize(8);
        } cpPane->endRow();
    }

    cpPane->addLabel("Control point: 0");
    cpPane->addNumberBox("Time", Pointer<float>(this, &PhysicsFrameSplineEditor::selectedNodeTime, &PhysicsFrameSplineEditor::setSelectedNodeTime), "s");
    cpPane->addTextBox("", Pointer<std::string>(this, &PhysicsFrameSplineEditor::selectedNodePFrameAsString, &PhysicsFrameSplineEditor::setSelectedNodePFrameFromString));

    cpPane->beginRow(); {
        GuiButton* b = cpPane->addButton("Add new", this, &PhysicsFrameSplineEditor::addControlPoint);
        b->moveBy(-2, -7);
        m_removeSelectedButton = cpPane->addButton("Remove", this, &PhysicsFrameSplineEditor::removeSelectedControlPoint);
    } cpPane->endRow();
    cpPane->pack();

    GuiControl* prev = p->addCheckBox("Loop with final interval", Pointer<bool>(this, &PhysicsFrameSplineEditor::cyclic, &PhysicsFrameSplineEditor::setCyclic));

    GuiPane* finalIntervalPane = p->addPane("", GuiTheme::NO_PANE_STYLE);
    finalIntervalPane->moveRightOf(prev);
    finalIntervalPane->moveBy(-1, -5);
    static int m_explicitFinalInterval = 0;
    m_finalIntervalChoice[0] = finalIntervalPane->addRadioButton("automatic", 0, &m_explicitFinalInterval);
    finalIntervalPane->beginRow(); {
        m_finalIntervalChoice[1] = finalIntervalPane->addRadioButton("", 1, &m_explicitFinalInterval);
        m_finalIntervalBox = finalIntervalPane->addNumberBox("", &m_spline.finalInterval, "s", GuiTheme::NO_SLIDER, -1.0f, 10000.0f, 0.001f);
        m_finalIntervalBox->setWidth(76);
        m_finalIntervalBox->moveBy(-2, 0);
    } finalIntervalPane->endRow();

    pack();

    setEnabled(false);
}
Пример #20
0
 virtual CFrame computeFrame(SimTime time) const override {
     return CFrame
         (m_rotation->computeFrame(time).rotation, 
          m_translation->computeFrame(time).translation);
 }
Пример #21
0
	Entity->PlaySound (CHAN_WEAPON, Sounds[SOUND_SIGHT]);
}

void CParasite::Tap ()
{
	Entity->PlaySound (CHAN_WEAPON, Sounds[SOUND_TAP], 255, ATTN_IDLE);
}

void CParasite::Scratch ()
{
	Entity->PlaySound (CHAN_WEAPON, Sounds[SOUND_SCRATCH], 255, ATTN_IDLE);
}

CFrame ParasiteFramesStartFidget [] =
{
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0)
};
CAnim ParasiteMoveStartFidget (CParasite::FRAME_stand18, CParasite::FRAME_stand21, ParasiteFramesStartFidget, ConvertDerivedFunction(&CParasite::DoFidget));

CFrame ParasiteFramesFidget [] =
{
	CFrame (&IMonster::AI_Stand, 0, ConvertDerivedFunction(&CParasite::Scratch)),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0, ConvertDerivedFunction(&CParasite::Scratch)),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0)
};
Пример #22
0
void ArticulatedViewer::onInit(const String& filename) {
    ArticulatedModel::clearCache();
    Texture::clearCache();

    m_filename = filename;

    m_selectedPart   = NULL;
    m_selectedMesh   = NULL;
    m_selectedTriangleIndex = -1;
    m_numFaces       = 0;
    m_numVertices    = 0;
    m_shadowMapDirty = true;

    UniversalMaterial::clearCache();
    
    const RealTime start = System::time();
    if (toLower(FilePath::ext(filename)) == "any") {

        if ((toLower(FilePath::ext(FilePath::base(filename))) == "material") ||
            (toLower(FilePath::ext(FilePath::base(filename))) == "universalmaterial")) {

            // Assume that this is an .UniversalMaterial.Any file. Load a square and apply the material
            Any any(Any::TABLE, "ArticulatedModel::Specification");
            any["filename"] = "model/crate/crate4xtex.obj";
            any["stripMaterials"] = true;
            any["preprocess"] = Any(Any::ARRAY);

            Any arg(Any::ARRAY, "setMaterial");
            arg.append(Any(Any::ARRAY, "all"));
            arg.append(Any::fromFile(filename));
            any["preprocess"].append(arg);

            Any arg2(Any::ARRAY, "setTwoSided");
            arg2.append(Any(Any::ARRAY, "all"));
            arg2.append(true);
            any["preprocess"].append(arg2);

            m_model = ArticulatedModel::create(ArticulatedModel::Specification(any));
        } else {

            // Assume that this is an .ArticulatedModel.Any file
            Any any;
            any.load(filename);

            m_model = ArticulatedModel::create(ArticulatedModel::Specification(any));
        }
    } else {
        m_model = ArticulatedModel::fromFile(filename);
    }
    debugPrintf("%s loaded in %f seconds\n", filename.c_str(), System::time() - start);


    Array<shared_ptr<Surface> > arrayModel;
    if (m_model->usesSkeletalAnimation()) {
        Array<G3D::String> animationNames;
        m_model->getAnimationNames(animationNames);
        // TODO: Add support for selecting animations.
        m_model->getAnimation(animationNames[0], m_animation); 
        m_animation.getCurrentPose(0.0f, m_pose);
    } 
    
    m_model->pose(arrayModel, CFrame(), m_pose);

    m_model->countTrianglesAndVertices(m_numFaces, m_numVertices);
    
    m_scale = 1;
    m_offset = Vector3::zero();
    bool overwrite = true;
    
    // Find the size of the bounding box of the entire model
    AABox bounds;
    if (arrayModel.size() > 0) {
        
        for (int x = 0; x < arrayModel.size(); ++x) {		
            
            //merges the bounding boxes of all the seperate parts into the bounding box of the entire object
            AABox temp;
            CFrame cframe;
            arrayModel[x]->getCoordinateFrame(cframe);
            arrayModel[x]->getObjectSpaceBoundingBox(temp);
            Box partBounds = cframe.toWorldSpace(temp);
            
            // Some models have screwed up bounding boxes
            if (partBounds.extent().isFinite()) {
                if (overwrite) {
                    partBounds.getBounds(bounds);
                    overwrite = false;
                } else {
                    partBounds.getBounds(temp);
                    bounds.merge(temp);
                }
            }
        }
        
        if (overwrite) {
            // We never found a part with a finite bounding box
            bounds = AABox(Vector3::zero());
        }
        
        Vector3 extent = bounds.extent();
        Vector3 center = bounds.center();
        
        // Scale to X units
        float scale = 1.0f / max(extent.x, max(extent.y, extent.z));
        
        if (scale <= 0) {
            scale = 1;
        }

        if (! isFinite(scale)) {
            scale = 1;
        }

        m_scale = scale;
        scale *= VIEW_SIZE;
        m_offset = -scale * center;
        

        if (! center.isFinite()) {
            center = Vector3();
        }

        // Transform parts in-place
        m_model->scaleWholeModel(scale);

        ArticulatedModel::CleanGeometrySettings csg;
        // Merging vertices is slow and topology hasn't changed at all, so preclude vertex merging
        csg.allowVertexMerging = false; 
        m_model->cleanGeometry(csg);
    }

    // Get the newly transformed animation
    if (m_model->usesSkeletalAnimation()) {
        Array<String> animationNames;
        m_model->getAnimationNames(animationNames);
        // TODO: Add support for selecting animations.
        m_model->getAnimation(animationNames[0], m_animation); 
        m_animation.getCurrentPose(0.0f, m_pose);
    } 

    // saveGeometry();
}
Пример #23
0
		IdealYaw = AngleModf(enemy_yaw - 30);
		break;
	case 1:
		IdealYaw = AngleModf(enemy_yaw);
		break;
	case 2:
		IdealYaw = AngleModf(enemy_yaw + 30);
		break;
	};

	MachineGun ();
}

CFrame CarrierFramesStand [] =
{
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0),
	CFrame (&IMonster::AI_Stand, 0)
};
CAnim CarrierMoveStand (CCarrier::FRAME_search01, CCarrier::FRAME_search13, CarrierFramesStand);
Пример #24
0
void RayTracer::debugDrawPhotonMap(RenderDevice* rd) {
    rd->setObjectToWorldMatrix(CFrame());
    for (PhotonMap::CellIterator cell = m_photonMap.beginCell(); cell.isValid(); ++cell) {
        Draw::box(cell.bounds(), rd);
    }
}