3D library
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
3D library
Hello,
I'm converting to Livecode a 3D library that I used on another programming language. I want to release it under GPL.
I'm working on arrays, a lot of arrays, so I need some trick to reduce the line to write.
For example I wrote this:
function r3d_translate x,y,z
#Create a translation matrix:
#1 0 0 X
#0 1 0 Y
#0 0 1 Z
#0 0 0 1
repeat with i=1 to 4
repeat with j=1 to 4
if i = j then
put 1 into temp[j]
else
put 0 into temp[j]
end if
end repeat
end repeat
put x into temp[1][4]
put y into temp[2][4]
put z into temp[3][4]
return temp
end r3d_translate
Is there a better solution or more elegant solution to write it?
I'm converting to Livecode a 3D library that I used on another programming language. I want to release it under GPL.
I'm working on arrays, a lot of arrays, so I need some trick to reduce the line to write.
For example I wrote this:
function r3d_translate x,y,z
#Create a translation matrix:
#1 0 0 X
#0 1 0 Y
#0 0 1 Z
#0 0 0 1
repeat with i=1 to 4
repeat with j=1 to 4
if i = j then
put 1 into temp[j]
else
put 0 into temp[j]
end if
end repeat
end repeat
put x into temp[1][4]
put y into temp[2][4]
put z into temp[3][4]
return temp
end r3d_translate
Is there a better solution or more elegant solution to write it?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: 3D library
I'm working on the conversion of this old libray, it doesn't use OpenGL, just flat 2D polygons.
I already converted all matrix functions needed, now I need more information about creating a 2D drawing in Livecode.
Where I can found these information?
This is my goal:
I already converted all matrix functions needed, now I need more information about creating a 2D drawing in Livecode.
Where I can found these information?
This is my goal:
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: 3D library
Hi malte,
I noticed that Livecode permit to draw using the "paint tools". I need to know how to create and specify the vertexes (x,y) of a polygon.
I noticed that Livecode permit to draw using the "paint tools". I need to know how to create and specify the vertexes (x,y) of a polygon.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: 3D library
Hi, you might be way better off using the graphic primitive. Using the paint tools will be much slower.
Best,
Malte
Best,
Malte
-
- VIP Livecode Opensource Backer
- Posts: 4015
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: 3D library
Hi Max,
have a look at this thread
http://forums.runrev.com/viewtopic.php?f=9&t=7824
last stack is a sort of pseudo 3D made with graphic objects
or this thread
http://forums.runrev.com/viewtopic.php?f=9&t=13399
Kind regards
Bernd
have a look at this thread
http://forums.runrev.com/viewtopic.php?f=9&t=7824
last stack is a sort of pseudo 3D made with graphic objects
or this thread
http://forums.runrev.com/viewtopic.php?f=9&t=13399
Kind regards
Bernd
Re: 3D library
I imagined that a single image was faster and less memory consuming; but your are saying me that is better graphic polygonal object for each 3D object?malte wrote:Hi, you might be way better off using the graphic primitive. Using the paint tools will be much slower.
Unfortunately if I use polygonal objects, I need one fore each face of the solid; because I need to change each face luminosity (color) to give a correct 3D effect.
Look at this picture:
It's just a simple cube with only 3 faces shown, but they are 3 polygons.
I'm not an expert, but are you sure that using polygons is the best way?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: 3D library
I write here some code to explain me better.
A the present I'm using the following code:
on mouseUp
set the style of the templateGraphic to polygon
create graphic face1
create graphic face2
create graphic face3
put "40,60" & return into temp
put "60,40" & return after temp
put "40,20" & return after temp
put "20,40" & return after temp
put "40,60" & return after temp
set the points of graphic face1 to temp
set the opaque of graphic face1 to true
set the backgroundcolor of graphic face1 to 230,0,0
put "40,60" & return into temp
put "20,40" & return after temp
put "20,80" & return after temp
put "40,100" & return after temp
put "40,60" & return after temp
set the points of graphic face2 to temp
set the opaque of graphic face2 to true
set the backgroundcolor of graphic face2 to 255,0,0
put "40,60" & return into temp
put "60,40" & return after temp
put "60,80" & return after temp
put "40,100" & return after temp
put "40,60" & return after temp
set the points of graphic face3 to temp
set the opaque of graphic face3 to true
set the backgroundcolor of graphic face3 to 200,0,0
end mouseUp
but I'd prefer images, something like :
What do you think?
What is the best solution?
A the present I'm using the following code:
on mouseUp
set the style of the templateGraphic to polygon
create graphic face1
create graphic face2
create graphic face3
put "40,60" & return into temp
put "60,40" & return after temp
put "40,20" & return after temp
put "20,40" & return after temp
put "40,60" & return after temp
set the points of graphic face1 to temp
set the opaque of graphic face1 to true
set the backgroundcolor of graphic face1 to 230,0,0
put "40,60" & return into temp
put "20,40" & return after temp
put "20,80" & return after temp
put "40,100" & return after temp
put "40,60" & return after temp
set the points of graphic face2 to temp
set the opaque of graphic face2 to true
set the backgroundcolor of graphic face2 to 255,0,0
put "40,60" & return into temp
put "60,40" & return after temp
put "60,80" & return after temp
put "40,100" & return after temp
put "40,60" & return after temp
set the points of graphic face3 to temp
set the opaque of graphic face3 to true
set the backgroundcolor of graphic face3 to 200,0,0
end mouseUp
but I'd prefer images, something like :
Code: Select all
set the rect of the templateImage to 100,100,400,400
create image
choose polygon tool
#here I don't know how to continue...
What is the best solution?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 4015
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: 3D library
Hi Max,
I think you should go with graphics.
If you want to go with images then here is some code, combining your two scripts.
Kind regards
Bernd
I think you should go with graphics.
If you want to go with images then here is some code, combining your two scripts.
Code: Select all
set the rect of the templateImage to 10,10,400,400
create image
choose polygon tool
#here I don't know how to continue...
put "40,60" & return into temp
put "60,40" & return after temp
put "40,20" & return after temp
put "20,40" & return after temp
put "40,60" & return after temp
repeat with i = 2 to the number of lines of temp
drag from line i - 1 of temp to line i of temp
end repeat
choose pointer tool
Bernd
-
- Posts: 24
- Joined: Thu May 15, 2014 4:40 pm
Re: 3D library
MaxV, this is the REBOL language, right? Just wanted to ask, I have seen it rarely, but looks powerful, easier to write than C# and cool outfit. Is it close to LiveCode?
Re: 3D library
Yes, it is. It's very simpler and powerful. It's like Livecode, but you have to write jus few line of text, no IDE, no binary file format.
Now it's opensource and you can get the source here: https://github.com/rebol/rebol
A simple e guide to Rebol is here: http://www.re-bol.com/rebol.html
Now it's opensource and you can get the source here: https://github.com/rebol/rebol
A simple e guide to Rebol is here: http://www.re-bol.com/rebol.html
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: 3D library
However Rebol now is abandoned, so I switched to Livecode.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: 3D library
Hi there,
I'm very interested in this.
I'm a designer (sailing boats mainly) and amateur programmer.
I use Rhino as 3d modeler and it has a graphical programming language called grasshopper (see my page).
I'd love to see lc and gh working together.
I don't have time right now to check all these posts but
I'll be back!
F.
I'm very interested in this.
I'm a designer (sailing boats mainly) and amateur programmer.
I use Rhino as 3d modeler and it has a graphical programming language called grasshopper (see my page).
I'd love to see lc and gh working together.
I don't have time right now to check all these posts but
I'll be back!
F.
Re: 3D library
I'm near to finish, I have just to correct last 2 functions (render and r3d_Render2dTriangles_Simple). You can see the developments here: https://github.com/angerangel/LCR3D/blob/master/r3d.txt
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: 3D library
Nice, I wasn't expecting so much! Thank you so much for sharing! I'll take a look soon and post my questions.
Can you put an example of
Can you put an example of
I'll make a tool in grasshopper to format meshes correctly. I already imported polylines with a bunch of attributes the other day.#"world" contains a list of object to render:
# it has
#[1]["model"] (contains faces and points of the boject)
#[1]["properties"] (contains traslation, rotation and other transormationof the object, very usefu in animation)
#[1]["color"] (the color to render the object)