game4tress 0 Newbie Poster

I'm creating a morphing module for a certain software and I'm trying to do something that I'm wrestling for quite long.

I've created a mesh divided in 9 parts. So I have a rectangle divided in 9 "sub-rectangles" and I've set a texture for the global rectangle. My idea, doable, or not, is that when I redefine the positions of the "sub-rectangles", the image is changed accordingly.
For instance, imagine a someone's face. When I change some of the coordinates, one of the teeth comes forward, because it's the section in the square corresponding to that tooth, leaving the rest of the face intact (some other squares may need to be set smaller or larger,... but that's another issue).
Although this teory is very interesting, the problem is that I'm not getting the result I wan't and I believe the problem comes from the way I'm applying textures. I'm not accustomed to 3D.

Can you please give me some help?

My thanks in advanced.

Here's the main code:

contentcontrol1.Content = myviewport3d

    myviewport3d.Children.Add(mymodelvisual)
    myviewport3d.Camera = mypccamera
    mymodel3dgroup.Children.Add(New DirectionalLight(Colors.White, New Vector3D(0, 0, 1)))
    mymodelvisual.Content = mymodel3dgroup
    ptn3DRight = New Point3D(7, 0, 0)


      mymesh.Positions.Add(New Point3D(0, 2, 0))
    mymesh.Positions.Add(New Point3D(3, 2, 0))
    mymesh.Positions.Add(New Point3D(3, 0, 0))
    mymesh.Positions.Add(New Point3D(0, 0, 0))

    mymesh.Positions.Add(New Point3D(0, 5, 0))
    mymesh.Positions.Add(New Point3D(3, 5, 0))
    mymesh.Positions.Add(New Point3D(3, 2, 0))
    mymesh.Positions.Add(New Point3D(0, 2, 0))


    mymesh.Positions.Add(New Point3D(0, 9, 0))
    mymesh.Positions.Add(New Point3D(3, 9, 0))
    mymesh.Positions.Add(New Point3D(3, 5, 0))
    mymesh.Positions.Add(New Point3D(0, 5, 0))


    mymesh.Positions.Add(New Point3D(3, 9, 0))
    mymesh.Positions.Add(New Point3D(5, 9, 0))
    mymesh.Positions.Add(New Point3D(5, 5, 0))
    mymesh.Positions.Add(New Point3D(3, 5, 0))


    mymesh.Positions.Add(New Point3D(5, 9, 0))
    mymesh.Positions.Add(New Point3D(7, 9, 0))
    mymesh.Positions.Add(New Point3D(7, 5, 0))
    mymesh.Positions.Add(New Point3D(5, 5, 0))

    mymesh.Positions.Add(New Point3D(5, 5, 0))
    mymesh.Positions.Add(New Point3D(7, 5, 0))
    mymesh.Positions.Add(New Point3D(7, 2, 0))
    mymesh.Positions.Add(New Point3D(5, 2, 0))

    mymesh.Positions.Add(New Point3D(5, 2, 0))
    mymesh.Positions.Add(New Point3D(7, 2, 0))
    mymesh.Positions.Add(New Point3D(7, 0, 0))
    mymesh.Positions.Add(New Point3D(5, 0, 0))

    mymesh.Positions.Add(New Point3D(3, 2, 0))
    mymesh.Positions.Add(New Point3D(5, 2, 0))
    mymesh.Positions.Add(New Point3D(5, 0, 0))
    mymesh.Positions.Add(New Point3D(3, 0, 0))


    mymesh.Positions.Add(New Point3D(3, 5, 0))
    mymesh.Positions.Add(New Point3D(5, 5, 0))
    mymesh.Positions.Add(New Point3D(5, 2, 0))
    mymesh.Positions.Add(New Point3D(3, 2, 0))


    mymesh.TriangleIndices.Add(0)
    mymesh.TriangleIndices.Add(1)
    mymesh.TriangleIndices.Add(2)
    mymesh.TriangleIndices.Add(2)
    mymesh.TriangleIndices.Add(3)
    mymesh.TriangleIndices.Add(0)

    mymesh.TextureCoordinates.Add(New Point(1, 0))
    mymesh.TextureCoordinates.Add(New Point(0, 0))
    mymesh.TextureCoordinates.Add(New Point(0, 1))
    mymesh.TextureCoordinates.Add(New Point(1, 1))
    Dim m As System.Windows.Media.Media3D.Material
    'Dim m = New System.Windows.Media.Media3D.Material()
    Dim df As System.Windows.Media.Media3D.DiffuseMaterial
    Dim spm As System.Windows.Media.Media3D.SpecularMaterial

    Dim ri As Uri = New Uri("d:\cc.png", UriKind.Absolute)
    Dim imgSource As ImageSource = New BitmapImage(ri)

    'myImage.Source = imgSource; 


    Dim ib = New ImageBrush()
    ib.ImageSource = New BitmapImage(New Uri("d:\cc.png", UriKind.Absolute))
    ib.Stretch = Stretch.Fill
    'ib.ViewboxUnits = BrushMappingMode.Absolute
    ib.AlignmentX = AlignmentX.Left
    ib.AlignmentY = AlignmentY.Top
    'ib.Viewport.Left = 0
    ib.Opacity = 1


    df = New System.Windows.Media.Media3D.DiffuseMaterial(ib)

    spm = New System.Windows.Media.Media3D.SpecularMaterial(ib, 85)
    'df.Color = Color.FromArgb(0, 12, 12, 12)
    mymodel3dgroup.Children.Add(New GeometryModel3D(mymesh, df))
    'mymodel3dgroup.Children.Add(New GeometryModel3D(mymesh, New DiffuseMaterial(Brushes.Blue)))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.