Exemplo n.º 1
0
        public override void Run(RenderControl render)
        {
            mGeometry = GeometryBuilder.CreatePlane(20000, 20000, worldWidth - 1, worldDepth - 1);
            var position = mGeometry.GetGeometry().GetAttribute(0);

            position.SetDataUsage(EnumBufferDataUsage.DYNAMIC_DRAW);
            var mPosition = new Float32Array(position.GetData());

            for (uint i = 0; i < position.GetCount() / 3; i++)
            {
                float z = (float)(35 * Math.Sin(i / 2));
                mPosition.SetValue(i * 3 + 2, z);
            }

            var material = BasicMaterial.Create("basic-water");
            var img      = FileImage.Create(GetResourcePath("textures/water.png"));
            var texture  = new ImageTexture2D();

            texture.SetSource(img);
            var desc = texture.GetDesc();

            desc.SetWrapS(EnumTextureWrappingType.REPEAT);
            desc.SetWrapT(EnumTextureWrappingType.REPEAT);
            texture.SetRepeat(new Vector2(5, 5));

            material.AddTexture("map", texture);
            var color = Vector3.ColorFromHex(0x0044ff);

            material.SetUniform("diffuse", Uniform.Create(color));


            var node = new PrimitiveSceneNode(mGeometry, material);

            node.SetPickable(false);
            node.SetCulling(false);

            render.ShowSceneNode(node);
        }
Exemplo n.º 2
0
    public void ResetToDefaultShape(PrimitiveShape shape)
    {
        Parameters.PathParameters.TwistBegin   = 0f;
        Parameters.PathParameters.TwistEnd     = 0f;
        Parameters.PathParameters.RadiusOffset = 0f;
        Parameters.PathParameters.Taper        = new Vector2(0f, 0f);
        Parameters.PathParameters.Revolutions  = 1f;
        Parameters.PathParameters.Skew         = 0f;
        switch (shape)
        {
        case PrimitiveShape.Sphere:
            //rotation.setQuat(90.f* DEG_TO_RAD, LLVector3::y_axis);
            Parameters.SetType(ProfileType.CircleHalf, HoleType.HoleSame, PathType.Circle);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(1f, 1f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.Torus:
            //	rotation.setQuat(90.f* DEG_TO_RAD, LLVector3::y_axis);
            Parameters.SetType(ProfileType.Circle, HoleType.HoleSame, PathType.Circle);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(1f, 0.25f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.SquareTorus:
            //	rotation.setQuat(90.f* DEG_TO_RAD, LLVector3::y_axis);
            Parameters.SetType(ProfileType.Square, HoleType.HoleSame, PathType.Circle);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(1f, 0.25f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.TriangleTorus:
            //	rotation.setQuat(90.f* DEG_TO_RAD, LLVector3::y_axis);
            Parameters.SetType(ProfileType.EqualTri, HoleType.HoleSame, PathType.Circle);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(1f, 0.25f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.SphereHemi:
            Parameters.SetType(ProfileType.CircleHalf, HoleType.HoleSame, PathType.Circle);
            //Parameters.SetBeginAndEndS(0.5f, 1f);
            Parameters.SetBeginAndEndT(0f, 0.5f);
            Parameters.SetRatio(1f, 0.25f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.Cube:
            Parameters.SetType(ProfileType.Square, HoleType.HoleSame, PathType.Line);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(1f, 1f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.Prism:
            Parameters.SetType(ProfileType.Square, HoleType.HoleSame, PathType.Line);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(0f, 1f);
            Parameters.SetShear(-0.5f, 0);
            break;

        case PrimitiveShape.Pyramid:
            Parameters.SetType(ProfileType.Square, HoleType.HoleSame, PathType.Line);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(0f, 0f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.Tetrahedron:
            Parameters.SetType(ProfileType.EqualTri, HoleType.HoleSame, PathType.Line);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(0f, 0f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.Cylinder:
            Parameters.SetType(ProfileType.Circle, HoleType.HoleSame, PathType.Line);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(1f, 1f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.CylinderHemi:
            Parameters.SetType(ProfileType.Circle, HoleType.HoleSame, PathType.Line);
            Parameters.SetBeginAndEndS(0.25f, 0.75f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(1f, 1f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.Cone:
            Parameters.SetType(ProfileType.Circle, HoleType.HoleSame, PathType.Line);
            Parameters.SetBeginAndEndS(0f, 1f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(0f, 0f);
            Parameters.SetShear(0f, 0f);
            break;

        case PrimitiveShape.ConeHemi:
            Parameters.SetType(ProfileType.Circle, HoleType.HoleSame, PathType.Line);
            Parameters.SetBeginAndEndS(0.25f, 0.75f);
            Parameters.SetBeginAndEndT(0f, 1f);
            Parameters.SetRatio(0f, 0f);
            Parameters.SetShear(0f, 0f);
            break;
        }
    }