Sign in to follow this  

I cant see the texture in my model

Recommended Posts

Hi i have created a humanface with drawuserprimitives, and i setted a texture but the final result is only the model in wireframe,i set also the rendermode in solid but still doen´t appear the texture .Why happens this?and another question when i maximize the window i lost my model. Here is the code, thank,s: Imports Microsoft.DirectX.Direct3D Imports Microsoft.DirectX Public Class Form1 Private device As Device Dim verticest As CustomVertex.PositionColoredTextured() = New CustomVertex.PositionColoredTextured(1398) {} Dim indices As Short() = New Short(7991) {} Public Sub Initialize() Dim Present As PresentParameters = New PresentParameters Present.Windowed = True Present.SwapEffect = SwapEffect.Discard device = New Device(0, DeviceType.Hardware, Me.Handle, CreateFlags.SoftwareVertexProcessing, Present) device.RenderState.Lighting = False End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Text = "DirectX Tutorial using Visual Basic" Me.Setstyle(Controlstyles.AllPaintingInWmPaint Or Controlstyles.Opaque, True) Initialize() Dim nºarchivo As Integer = FreeFile() FileOpen(nºarchivo, My.Computer.FileSystem.SpecialDirectories.Desktop & "\cara.3d", OpenMode.Input) For i = 0 To 1398 Dim dato As String dato = LineInput(nºarchivo) Dim Datoparts As String() Datoparts = Split(dato, " ") verticest(i).SetPosition(New Vector3(NumerosDecimales(Datoparts(0)), NumerosDecimales(Datoparts(1)), NumerosDecimales(Datoparts(2)))) verticest(i).Color = Color.Blue.ToArgb verticest(i).Tu = (NumerosDecimales(dato(3))) verticest(i).Tv = 1 - (NumerosDecimales(dato(4))) Next For i = 0 To 2663 Dim dato As String dato = LineInput(nºarchivo) Dim Datoparts As String() Datoparts = Split(dato, " ") indices(3 * i) = Datoparts(0) indices((3 * i) + 1) = Datoparts(1) indices((3 * i) + 2) = Datoparts(2) Next End Sub Private Sub Form1_OnPaint(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Paint device.RenderState.CullMode = Cull.None device.RenderState.FillMode = FillMode.WireFrame device.Clear(ClearFlags.Target, Color.Black, 1, 0) Dim imagen As New Bitmap("C:\Users\Jorge\Desktop\fernando.bmp") Dim textura As New Texture(device, imagen, Usage.Dynamic, Pool.Default) device.MultiplyTransform(TransformType.Projection, Matrix.PerspectiveFovLH(Math.PI / 4, _ Me.Width / Me.Height, 1, 100)) device.MultiplyTransform(TransformType.World, Matrix.LookAtLH(New Vector3(0, 0, 10), New Vector3(0, 4, 0), New Vector3(0, 1, 0))) device.SetTexture(0, textura) device.BeginScene() device.VertexFormat = CustomVertex.PositionColoredTextured.Format device.DrawIndexedUserPrimitives(PrimitiveType.TriangleList, 0, 1399, 2664, indices, True, verticest) device.EndScene() device.Present() End Sub Public Function NumerosDecimales(ByVal coordenadas As String) Dim ceros As String Dim divisorregional Dim variableCalculo() As String Dim SeparadorDec As String Dim numdecx Dim numecerosdivisor Dim x SeparadorDec = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator ceros = "" variableCalculo = Split(coordenadas, ".") If coordenadas.ToString = "0" Or variableCalculo.Length = 1 Then divisorregional = 1 x = CSng(coordenadas / divisorregional) Return x Exit Function End If NumDecx = variableCalculo(1) numecerosdivisor = Len(NumDecx.ToString) For j = 1 To numecerosdivisor ceros = ceros & "0" Next If SeparadorDec = "." Then Divisorregional = 1 Else Divisorregional = Val(1 & ceros) End If x = CSng(coordenadas / divisorregional) Return x End Function End Class

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this