Posts: 136
Threads: 10
Likes Received: 37 in 31 posts
Likes Given: 29
Joined: Oct 2023
Reputation:
3
LitDev,
How are the values of 0 and 1 derived in the following line? I still don't understand this.
LD3DView.AddImage(view3D,square,"0 1:1 1:1 0:1 0:0 0:0 1",image,"D")
is 0 1 representing x and y?
is : just a separator for the nodes
is there 6 nodes?
why 11 for the second node?
JR
Posts: 451
Threads: 34
Likes Received: 359 in 246 posts
Likes Given: 178
Joined: Aug 2023
Reputation:
17
Hi,
The textxtures parameter help info is:
A space or colon deliminated list of the texture coordinates for each node. Each node has 2 values between 0 and 1 indicating the x,y image mapping to the node. The may be defaulted to "" if the texture has previously been set.
So the space and colon are deliminators and I used : to separate between x y pairs to make it easier to read.
The are 2 triangles on this 3D object (square). Although 2 nodes could be shared they were specified separately so there are 6 nodes. There are are also 6 x y pairs of textiure cordinates, one for each triangle node.
So the purpose of the each texture node is to say what coorcinates ont the image the node corresponds to. The first is 0 0 which is bottom left of the image mapped to the first node. The second is 1 0 which is bottom right of the image mapped to the second node tec.
The mapping coordinates do not have to be whole numbers, see the effect using just the left half of the image for example "0 1:0.5 1:0.5 0:0.5 0:0 0:0 1".
Posts: 136
Threads: 10
Likes Received: 37 in 31 posts
Likes Given: 29
Joined: Oct 2023
Reputation:
3
LitDev,
So the purpose of each texture node is to say what coordinates on the image the node corresponds to. The first is 0 0 which is bottom left of the image mapped to the first node. The second is 1 0 which is bottom right of the image mapped to the second node. 0 1:1 1:1 0:1 0:0 0:0 1
Still confused!
The above 2 lines aren't making any sense to me which is what you wrote. You said the first node 0 0 is bottom left of the image. Isn't 01 the value for first node? 11 the second node value. 10 the third node value. 10 the 4th node value. 00 the 5th node value and 01 the 6th node value?
Since I am only doing a square which is 2 triangles put together. The first node is down in the left hand corner. Where is the second, third and 4th nodes? Do they just go around the square counter clockwise? I understand why you use 6 because of the 2 triangles which has 6 vertex's.
Thanks for helping!
JR
Posts: 12
Threads: 3
Likes Received: 10 in 8 posts
Likes Given: 29
Joined: Jan 2024
Reputation:
5
02-24-2024, 06:45 AM
(This post was last modified: 02-24-2024, 07:46 AM by stevantosic.)
JR
Maybe you should start with single triangle:
triangle = LD3DView.AddGeometry(view3D,"-0.5 -0.5 0.5:0.5 -0.5 0.5:0.5 0.5 0.5","0 1 2","" , "Red","D")
'LD3DView.AddImage(view3D,triangle, "0 0:1 0:1 1",image,"D") '
LD3DView.AddImage(view3D,triangle, "0 1:1 1:1 0",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y
or
triangle2 = LD3DView.AddGeometry(view3D,"-0.5 -0.5 0.5:0.5 -0.5 0.5:0 0.5 0.5","0 1 2","" , "Red","D")
'LD3DView.AddImage(view3D,triangle2, "0 0:1 0:0.5 1",image,"D") '
LD3DView.AddImage(view3D,triangle2, "0 1:1 1:0.5 0",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y
st
Posts: 136
Threads: 10
Likes Received: 37 in 31 posts
Likes Given: 29
Joined: Oct 2023
Reputation:
3
st,
That helps a lot. Make it simple. Now, I understand that you flip all of the y values. How would you set this up to show only the left triangle? I have been trying this, but haven't succeded yet.
Posts: 12
Threads: 3
Likes Received: 10 in 8 posts
Likes Given: 29
Joined: Jan 2024
Reputation:
5
Code: triangleL = LD3DView.AddGeometry(view3D,"0.5 0.5 0.5:-0.5 0.5 0.5:-0.5 -0.5 0.5","0 1 2","" , "Red","D")
'LD3DView.AddImage(view3D,triangleL, "1 1:0 1:0 0",image,"D") '
LD3DView.AddImage(view3D,triangleL, "1 0:0 0:0 1",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y
Changing parameters slowly one by one is a good way to see what is happening on the scene.
st
Posts: 136
Threads: 10
Likes Received: 37 in 31 posts
Likes Given: 29
Joined: Oct 2023
Reputation:
3
st,
Thanks a lot. Now, I cam figure out how it works!
JR
Posts: 12
Threads: 3
Likes Received: 10 in 8 posts
Likes Given: 29
Joined: Jan 2024
Reputation:
5
03-01-2024, 08:13 PM
(This post was last modified: 03-02-2024, 07:28 PM by stevantosic.)
Maintain aspect ratio:
LDNetwork.SetSSL()
flickr = LDUtilities.FixFlickr()
imageURL = Flickr.GetRandomPicture("word")
tmpFile = File.GetTemporaryFilePath()
LDNetwork.DownloadFile(tmpFile,imageURL)
image = ImageList.LoadImage(tmpFile)
File.DeleteFile(tmpFile)
view3D = LD3DView.AddView(GraphicsWindow.Width,GraphicsWindow.Height,"True")
LD3DView.AutoControl("True","True",2,1)
LD3DView.AddAmbientLight(view3D,"White")
a = ImageList.GetWidthOfImage(image)
b = ImageList.GetHeightOfImage(image)
k = LDMath.FixDecimal(a/b, 2)
TextWindow.WriteLine(k)
pointsR = "-x -0.5 0.5:x -0.5 0.5:x 0.5 0.5"
pointsL = "x 0.5 0.5:-x 0.5 0.5:-x -0.5 0.5"
pointsR = LDText.Replace(pointsR, "x", 0.5 * k)
TextWindow.WriteLine(pointsR)
pointsL = LDText.Replace(pointsL, "x", 0.5 * k)
TextWindow.WriteLine(pointsL)
triangleR = LD3DView.AddGeometry(view3D, pointsR,"0 1 2","" , "Red","D")
'LD3DView.AddImage(view3D,triangleR, "0 0:1 0:1 1",image,"D") '
LD3DView.AddImage(view3D,triangleR, "0 1:1 1:1 0",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y
triangleL = LD3DView.AddGeometry(view3D,pointsL,"0 1 2","" , "Red","D")
'LD3DView.AddImage(view3D,triangleL, "1 1:0 1:0 0",image,"D") '
LD3DView.AddImage(view3D,triangleL, "1 0:0 0:0 1",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y
LD3DView.TranslateGeometry(view3D,triangleR,0,0,8)
LD3DView.TranslateGeometry(view3D,triangleL,0,0,8)
Posts: 136
Threads: 10
Likes Received: 37 in 31 posts
Likes Given: 29
Joined: Oct 2023
Reputation:
3
st,
I would have never thought of maintaining the ratio. Good program!
JR
|