-
Sep 22nd, 2012, 04:24 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] when working with 3d pure vb ,what im trying to do is take a picture bmp ,etc
what im trying to do is take a picture bmp ,etc and ad it to a 3d domino ,ive tryed to load it into a buffer then put it in the picture box,
but that way all ways erases everything in the picture box.
whats the best way to put this image into the picture box without disrupting all the other stuff in the pic?
thanks
-
Sep 22nd, 2012, 10:17 PM
#2
Thread Starter
Fanatic Member
Re: when working with 3d pure vb ,what im trying to do is take a picture bmp ,etc
hey im haveing trouble in this part of the module Function BaryInterpolateLinear.
im trying to change it to a polygon,
im lost
Code:
Dim X1, Y1, X2, Y2, X3, Y3, X4, Y4, U1, V1, U2, V2, U3, V3, U4, V4
Dim IsRendering As Boolean
Private Sub Command1_Click()
X1 = PRender.Left 'top left corner left side
Y1 = PRender.Top 'top left corner top
X2 = PRender.Left + PTex.ScaleWidth
Y2 = PRender.Top
X3 = PRender.Left
Y3 = PRender.Top + PTex.ScaleHeight
X4 = PRender.Left + PTex.ScaleWidth
Y4 = PRender.Top + PTex.ScaleHeight
U1 = PTex.Left
V1 = PTex.Top
U2 = PTex.Left + PTex.ScaleWidth
V2 = PTex.Top
U3 = PTex.Left
V3 = PTex.Top + PTex.ScaleHeight
U4 = PTex.Left + PTex.ScaleWidth
V4 = PTex.Top + PTex.ScaleHeight
PRender.Cls
IsRendering = True
Render
IsRendering = False
End Sub
Sub Render()
Dim CurX, CurY, CurU, CurV
For CurY = 0 To PRender.ScaleHeight
For CurX = 0 To PRender.ScaleWidth
If IsInsidepoly(X1, Y1, X2, Y2, X3, Y3, X4, Y4, CurX, CurY) = True Then
CurU = BaryInterpolateLinear(X1, Y1, U1, X2, Y2, U2, X3, Y3, U3, X4, Y4, U4, CurX, CurY)
CurV = BaryInterpolateLinear(X1, Y1, V1, X2, Y2, V2, X3, Y3, V3, X4, Y4, V4, CurX, CurY)
PRender.PSet (Fix(CurX), Fix(CurY)), PTex.Point(CurU, CurV)
End If
Next CurX
DoEvents: If IsRendering = False Then Exit For
Next CurY
End Sub
module
Code:
' MODULE NAME: Filtering.BAS
' ==========================
'
' Module for common functions (interpolation functions...etc)
Option Explicit
Function BaryInterpolateLinear(X1, Y1, Val1, X2, Y2, Val2, X3, Y3, Val3, X4, Y4, Val4, PX, PY) As Single
'Linear triangle interpolation
'=============================
Dim D!, U!, V!, W!
D = 1 / (((X2 - X1) * (Y3 - Y1)) - ((Y2 - Y1) * (X3 - X1)))
U = (((X2 - PX) * (Y3 - PY)) - ((Y2 - PY) * (X3 - PX))) * D
V = (((X3 - PX) * (Y1 - PY)) - ((Y3 - PY) * (X1 - PX))) * D
W = 1 - (U + V)
BaryInterpolateLinear = (U * Val1) + (V * Val2) + (W * Val3)
End Function
Function IsInsidepoly(X1, Y1, X2, Y2, X3, Y3, X4, Y4, PX, PY) As Boolean
' FUNCTION : IsInsidepoly
' ===========================
'
' RETURNED VALUE: Boolean
'
' Check if a 2D point is inside a 2D poly.
Dim CRZ1!, CRZ2!, CRZ3!, CRZ4!
CRZ1 = (((X2 - PX) * (Y3 - PY)) - ((Y2 - PY) * (X3 - PX)))
CRZ2 = (((X1 - PX) * (Y2 - PY)) - ((Y1 - PY) * (X2 - PX)))
CRZ3 = (((X3 - PX) * (Y4 - PY)) - ((Y3 - PY) * (X4 - PX)))
CRZ4 = (((X4 - PX) * (Y1 - PY)) - ((Y4 - PY) * (X1 - PX)))
'The point is inside the poly
' if the vars (CRZ1, CRZ2 & CRZ3)
' has the same sign:
If ((CRZ1 > 0) And (CRZ2 > 0) And (CRZ3 > 0) And (CRZ4 > 0)) Or _
((CRZ1 < 0) And (CRZ2 < 0) And (CRZ3 < 0) And (CRZ4 > 0)) Then IsInsidepoly = True
End Function
-
Sep 24th, 2012, 01:45 PM
#3
Lively Member
Re: when working with 3d pure vb ,what im trying to do is take a picture bmp ,etc
Hm. On your form, try turning PRender.autoredraw=true ? Just thought I'd say...
-
Sep 26th, 2012, 12:44 AM
#4
Thread Starter
Fanatic Member
Re: when working with 3d pure vb ,what im trying to do is take a picture bmp ,etc
thanks all
i hand to change things in module and a few other places
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|