My machine OGRE texture rotation problem ...
My machine OGRE texture rotation problem ...
My story ... (only for those who are interested)
In 2007 I invested all my money and time in a new idea of building a fully automated machine.
For the production of wooden tiny houses.
So, I did a lot of research, development and drawings ...
bought a lot of parts (mechanical, electrical, electronical, and other components, ...).
And yes, I had a the luck that in 2008 there was the big banking crisis.
I almost lost my company, I lost my home due to I divorced, and I had a lot of financial debts problems.
And as you have some troubles, you are all alone on the world, family, friends, they are all gone !!!
Today, all my financial debts are payed back, I'm still dreaming and I want to restart my project,
I still have all the mechanical, electrical parts, and electronic drivers.
But before building it, as it is a very complex and fully automated machine,
I want to create some simulation programs (using PB5.73x64LTS), mechanical, electrical, pneumatically, PLC, ...
Picture 1: The machine chassis (the arrows showing 2 of the 8 belt drivers in total)
Picture 2: Detail of the beltdriver without the belt
Picture 3: The belt mesh
Picture 4: the texture .png
So, finally my question ...
One of my problems in OGRE, I want to simulate the motions of the transportation belt on the machine.
Not all the belts are running at the same time, so they must be controlled separately.
1) So, I designed a belt in 3D-CAD (300mm wide, 475mm length and 2mm thick ),
2) I designed a .png file with arrows on the top. (300px x 475px)
If your object is for example a cylinder, you can use the rotation of the cylinder to simulate the motion.
But here it's a special belt model who runs around three cylinders, (see drawing below)
Q) How can I rotate the .png texture around the belt without rotating the belt and only the texture ?
Is this possible, is there a texture offset possibility ?
Or do I need to create several textures, that I can switch inside the program ?
For example 10 different textures for one mesh.
Again, for those who are interested ...
How do I work:
1 ) I design all the mechanical parts (sketches) on paper with the needed measurements.
2 ) I design them in a 3D-CAD program.
3 ) I export these data to BLENDER data via COLLADA files (.dea).
4 ) Then import all the COLLADA parts in BLENDER.
5 ) Followed by reconstructing all the parts to one big machine.
Positions and rotations, the scaling is done in the 3D-CAD program.
6 ) Then I use the BLENDER2OGRE exporter to create the .mesh files.
7 ) I import these parts in PB 5.73x64 LTS as geometry
8 ) Inside PB can do some camera motions ...
Greetings,
marc [aka MarcoPajotter]
In 2007 I invested all my money and time in a new idea of building a fully automated machine.
For the production of wooden tiny houses.
So, I did a lot of research, development and drawings ...
bought a lot of parts (mechanical, electrical, electronical, and other components, ...).
And yes, I had a the luck that in 2008 there was the big banking crisis.
I almost lost my company, I lost my home due to I divorced, and I had a lot of financial debts problems.
And as you have some troubles, you are all alone on the world, family, friends, they are all gone !!!
Today, all my financial debts are payed back, I'm still dreaming and I want to restart my project,
I still have all the mechanical, electrical parts, and electronic drivers.
But before building it, as it is a very complex and fully automated machine,
I want to create some simulation programs (using PB5.73x64LTS), mechanical, electrical, pneumatically, PLC, ...
Picture 1: The machine chassis (the arrows showing 2 of the 8 belt drivers in total)
Picture 2: Detail of the beltdriver without the belt
Picture 3: The belt mesh
Picture 4: the texture .png
So, finally my question ...
One of my problems in OGRE, I want to simulate the motions of the transportation belt on the machine.
Not all the belts are running at the same time, so they must be controlled separately.
1) So, I designed a belt in 3D-CAD (300mm wide, 475mm length and 2mm thick ),
2) I designed a .png file with arrows on the top. (300px x 475px)
If your object is for example a cylinder, you can use the rotation of the cylinder to simulate the motion.
But here it's a special belt model who runs around three cylinders, (see drawing below)
Q) How can I rotate the .png texture around the belt without rotating the belt and only the texture ?
Is this possible, is there a texture offset possibility ?
Or do I need to create several textures, that I can switch inside the program ?
For example 10 different textures for one mesh.
Again, for those who are interested ...
How do I work:
1 ) I design all the mechanical parts (sketches) on paper with the needed measurements.
2 ) I design them in a 3D-CAD program.
3 ) I export these data to BLENDER data via COLLADA files (.dea).
4 ) Then import all the COLLADA parts in BLENDER.
5 ) Followed by reconstructing all the parts to one big machine.
Positions and rotations, the scaling is done in the 3D-CAD program.
6 ) Then I use the BLENDER2OGRE exporter to create the .mesh files.
7 ) I import these parts in PB 5.73x64 LTS as geometry
8 ) Inside PB can do some camera motions ...
Greetings,
marc [aka MarcoPajotter]
Last edited by marc_256 on Thu Apr 18, 2024 5:06 pm, edited 1 time in total.
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
- pf shadoko
- Enthusiast
- Posts: 386
- Joined: Thu Jul 09, 2015 9:07 am
Re: My machine OGRE texture rotation problem ...
I'm not sure I understand
is this what you want?
is this what you want?
Code: Select all
InitEngine3D():InitSprite():InitKeyboard():InitMouse()
ExamineDesktops()
OpenWindow(0, 0,0, DesktopWidth(0)*0.8,DesktopHeight(0)*0.8, "CreateShader - [Esc] quit",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
Add3DArchive(#PB_Compiler_Home + "examples\3D\Data\Textures", #PB_3DArchive_FileSystem)
Add3DArchive(GetCurrentDirectory(), #PB_3DArchive_FileSystem )
Parse3DScripts()
CreateCamera(0, 0, 0, 100, 100):MoveCamera(0,0,2,-4):CameraLookAt(0,0,0,0)
CreateLight(0,$ffffff, -100, 100, 100)
AmbientColor($111111*8)
CameraBackColor(0,$444488)
CreateTexture(0,512,512)
StartDrawing(TextureOutput(0))
Box(0,0,512,512,$aaaaaa)
For j=0 To 1
For i=0 To 17
x=j*256+i
LineXY(x,16,240+x,256,$ff)
LineXY(x,511-16,240+x,256,$ff)
Next
Next
StopDrawing()
CreateMaterial(0,TextureID(0))
MaterialShininess(0,64,$ffffff)
MaterialFilteringMode(0,#PB_Material_Anisotropic)
MaterialCullingMode(0,#PB_Material_NoCulling)
ScrollMaterial(0,1,0,#PB_Material_Animated)
;{----------------------------------------------------------------- mesh conveyor belt
Structure f2:x.f:y.f:EndStructure
Global Dim lp.f2(1000)
Global n
Define.f x0,y0,r0,x1,y1,r1,x2,y2,r2, la, ai,af,a,da,u
Procedure.f lenght(*p0.f2,*p1.f2)
Protected.f dx=*p1\x-*p0\x,dy=*p1\y-*p0\y
ProcedureReturn Sqr(dx*dx+dy*dy)
EndProcedure
Procedure LpAdd(x.f,y.f)
lp(n)\x=x
lp(n)\y=y
n+1
EndProcedure
Procedure arc(x.f,y.f,r.f,ai.f,af.f)
Protected.f a,da=360/64
a=ai
While a=<af
a+da
LpAdd(x+Cos(Radian(a))*r,y+Sin(Radian(a))*r)
Wend
EndProcedure
x0= 1:y0= 0 :r0=0.3; coordinates x,y , radius cylinder
x1=-1:y1= 0 :r1=0.3
x2= 0:y2=-0.5:r2=0.3
la=1.5 ;conveyor belt width
da=30
arc(x0,y0,r0,-90+da,90)
arc(x1,y1,r1,90,270-da)
arc(x2,y2,r2,270-da,270+da)
arc(x0,y0,r0,-90+da,-90+da)
CreateMesh(0)
For i=0 To n-1:i2=i*2
If i:u+lenght(lp(i-1),lp(i)):EndIf
MeshVertex(lp(i)\x,lp(i)\y, la/2,u,1,$ffffff,0,1,0)
MeshVertex(lp(i)\x,lp(i)\y,-la/2,u,0,$ffffff,0,1,0)
If i:MeshFace(i2-2,i2-1,i2+1,i2):EndIf
Next
FinishMesh(1)
NormalizeMesh(0)
ScaleMaterial(0,u/10,1) ; to match start and end of conveyor belt
;}
CreateEntity(0,MeshID(0),MaterialID(0))
Define.f MouseX,Mousey,depx,depz,dist,val,blend
Repeat
While WindowEvent():Wend
ExamineKeyboard()
ExamineMouse()
;RotateEntity(0,0.2,0.2,0.2, #PB_Relative)
RenderWorld()
FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape) Or MouseButton(3)
WAW... My machine OGRE texture rotation problem ...
Hi pf shadoko,
Thanks for you tip and help.
Sorry for late answer, I was studying BLENDER and ogre export.
See the results below.
Hi All,
For my woodwork machine,
I wanted to use 8 x SBC with small screens 10.9 inch to show the user what is happening inside the machine.
And specially in production time, when there is a machine stop due to a problem.
I wanted to visualize the position of the problem on these small screens (GUI).
But 8 computers with quality graphic card inside (to expensive).
So, I wanted to develop/test this on a small 4GB RAM SBC (Single Board Computer)
OS : Win 10 pro x64
Dev. : PB 5.73 LTS x64 in DEBUG mode !!!!
Graphics : OpenGL selected
3D_Engine : OGRE_3D (PB_AntialiasingMode_x6)
Game Engine : ByMe
Blender2Ogre : Xml to .PBI Data file converter (ByMe)
The results are impossible to believe ...
This works even in DEBUG mode !!!!!!
I lost a lot of time to more understand BLENDER and the Blender2Ogre (material/texture) export.
For now, all the meshes and textures are in place, but the following step is to animate the belts independently on the beltdrivers.
The results in PB 5.73 LTS ... See below.
Greetings,
Marc


Thanks for you tip and help.
Sorry for late answer, I was studying BLENDER and ogre export.
See the results below.
Hi All,
For my woodwork machine,
I wanted to use 8 x SBC with small screens 10.9 inch to show the user what is happening inside the machine.
And specially in production time, when there is a machine stop due to a problem.
I wanted to visualize the position of the problem on these small screens (GUI).
But 8 computers with quality graphic card inside (to expensive).
So, I wanted to develop/test this on a small 4GB RAM SBC (Single Board Computer)
OS : Win 10 pro x64
Dev. : PB 5.73 LTS x64 in DEBUG mode !!!!
Graphics : OpenGL selected
3D_Engine : OGRE_3D (PB_AntialiasingMode_x6)
Game Engine : ByMe
Blender2Ogre : Xml to .PBI Data file converter (ByMe)
The results are impossible to believe ...
This works even in DEBUG mode !!!!!!
I lost a lot of time to more understand BLENDER and the Blender2Ogre (material/texture) export.
For now, all the meshes and textures are in place, but the following step is to animate the belts independently on the beltdrivers.
The results in PB 5.73 LTS ... See below.
Greetings,
Marc


- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
- pf shadoko
- Enthusiast
- Posts: 386
- Joined: Thu Jul 09, 2015 9:07 am
Re: My machine OGRE texture rotation problem ...
to animate the belts independently, you need to use one material per belt and adjust speed with scrollmaterial
Re: My machine OGRE texture rotation problem ...
Hi pf shadoko
Thanks again for the nice tip you gave me, but it is not working as it shout be ...
Yes, is it me or is it PB ...
PB 5.73x64 LTS also tested with PB5.73x86 LTS
Win 10 Pro x64
When I use round Deg with Rotate ... 0.0 / 45.0 / 90.0 / 135.0 / 180.0 / 225.0 / 270.0 / 315.0 / 360.0
I have a problem ...
See also my early post of drawing rotated text problem.
https://www.purebasic.fr/english/viewto ... 66#p600566
This time is the problem in OGRE3D engine, and specially ScrollMaterial ()
I never used ScrollMaterial(), so I lost a lot of time to find the problem (by accident) ...
To solve it I made a less complex mesh and created a plane, but with the same problem.
This is NOT working: (First/Top belt) see the RotateMaterial 0.0 angle
But this IS working: (Second/Top belt) see the RotateMaterial 0.001 angle
If I change the angle (Deg) from 0.0 to 0.001 the ScrollMaterial() is working well ???
But this IS also working: (Third/Top belt) see ScaleMaterial ()
The following is NOT working at all: (Right/Top belt) See ScrollMaterial ( , , , #PB_Material_Animated)
even if I change the angle ??
The ScrollMaterial is jumping every frame but not moving at all.
I show the data results on the screen, they are changing but not in the 3D Engine envirement.
My first self made movie ever !?@#$%!^@&
Movie : MyFirstMovie
Is this a bug ?, or I'm doing something wrong about ScrollMaterial() ?
Thanks,
Marc
Thanks again for the nice tip you gave me, but it is not working as it shout be ...
Yes, is it me or is it PB ...

PB 5.73x64 LTS also tested with PB5.73x86 LTS
Win 10 Pro x64
When I use round Deg with Rotate ... 0.0 / 45.0 / 90.0 / 135.0 / 180.0 / 225.0 / 270.0 / 315.0 / 360.0
I have a problem ...
See also my early post of drawing rotated text problem.
https://www.purebasic.fr/english/viewto ... 66#p600566
This time is the problem in OGRE3D engine, and specially ScrollMaterial ()
I never used ScrollMaterial(), so I lost a lot of time to find the problem (by accident) ...
To solve it I made a less complex mesh and created a plane, but with the same problem.
This is NOT working: (First/Top belt) see the RotateMaterial 0.0 angle
Code: Select all
RotateMaterial (MyMaterial, 0.0, #PB_Material_Fixed)
ScaleMaterial (MyMaterial, 1.0, 1.0)
ScrollMaterial (MyMaterial, MaterialDeltaX, MaterialDeltaY, #PB_Material_Fixed)
Code: Select all
RotateMaterial (MyMaterial, 0.001, #PB_Material_Fixed)
ScaleMaterial (MyMaterial, 1.0, 1.0)
ScrollMaterial (MyMaterial, MaterialDeltaX, MaterialDeltaY, #PB_Material_Fixed)
But this IS also working: (Third/Top belt) see ScaleMaterial ()
Code: Select all
RotateMaterial (MyMaterial, 0.001, #PB_Material_Fixed)
ScaleMaterial (MyMaterial, 0.5, 0.5)
ScrollMaterial (MyMaterial, MaterialDeltaX, MaterialDeltaY, #PB_Material_Fixed)
The following is NOT working at all: (Right/Top belt) See ScrollMaterial ( , , , #PB_Material_Animated)
even if I change the angle ??
Code: Select all
RotateMaterial (MyMaterial, 0.001, #PB_Material_Fixed)
ScaleMaterial (MyMaterial, 1.0, 1.0)
ScrollMaterial (MyMaterial, 0, 10, #PB_Material_Animated)
I show the data results on the screen, they are changing but not in the 3D Engine envirement.
My first self made movie ever !?@#$%!^@&

Movie : MyFirstMovie
Is this a bug ?, or I'm doing something wrong about ScrollMaterial() ?
Thanks,
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
- pf shadoko
- Enthusiast
- Posts: 386
- Joined: Thu Jul 09, 2015 9:07 am
Re: My machine OGRE texture rotation problem ...
rotatematerial has no place here
scalematerial:
- the x parameter is the total length of your belt divided by the number of repetitions of the texture you want. (line 79 of my example)
- the y parameter must be 1 :no scale change in y axe
scrollmaterial:
- the x parameter defines the offset or its speed in #PB_Material_Animated mode (offset at each frame, so speed depends on framerate).
- the y parameter must be 0 : no scroll in y axe
scalematerial:
- the x parameter is the total length of your belt divided by the number of repetitions of the texture you want. (line 79 of my example)
- the y parameter must be 1 :no scale change in y axe
scrollmaterial:
- the x parameter defines the offset or its speed in #PB_Material_Animated mode (offset at each frame, so speed depends on framerate).
- the y parameter must be 0 : no scroll in y axe
Re: My machine OGRE texture rotation problem ...
pf shadoko, thanks for your help,
- error in line
MaterialShininess(0,64,$ffffff) => MaterialShininess(0, 64)
- error in line I added one MeshFace
MeshFace(i2-2,i2-1,i2+1,i2) => MeshFace (i2, i2-2, i2+1) + MeshFace (i2-2, i2-1, i2+1)
Can you test my program below for me please ...
You say that [RotateMaterial] has no place here.
If I don't use it, there is nothing happening at all, if I set it to 0.001 deg, all works well.
What I use:
PB 5.73 x64 LTS
Win 10 pro x64
OpenGL
Uncomment line 151 / Comment line 154
than
Comment line 151 / Uncomment line 154
You can START/STOP belt motion with [SPACEBAR] and use the mousewheel to speed UP/DOWN.
Thanks,
Marc
First I adapted your program for PB 5.73 x64, and my needs.
- error in line
MaterialShininess(0,64,$ffffff) => MaterialShininess(0, 64)
- error in line I added one MeshFace
MeshFace(i2-2,i2-1,i2+1,i2) => MeshFace (i2, i2-2, i2+1) + MeshFace (i2-2, i2-1, i2+1)
Can you test my program below for me please ...
You say that [RotateMaterial] has no place here.
If I don't use it, there is nothing happening at all, if I set it to 0.001 deg, all works well.
What I use:
PB 5.73 x64 LTS
Win 10 pro x64
OpenGL
Uncomment line 151 / Comment line 154
than
Comment line 151 / Uncomment line 154
You can START/STOP belt motion with [SPACEBAR] and use the mousewheel to speed UP/DOWN.
Thanks,
Marc
Code: Select all
;- To do the test : Comment line 151 / Comment line 154 or visa versa
EnableExplicit
Structure f2
x.f
y.f
EndStructure
Define.f x0, y0, r0, x1, y1, r1, x2, y2, r2, la, ai, af, a, da, u
Define.f MouseX, Mousey, depx, depz, dist, val, blend
Define i.w
Define j.w
Define x.w
Define i2.w
Declare arc (x.f, y.f, r.f, ai.f, af.f)
Declare LpAdd (x.f, y.f)
Declare.f lenght (*p0.f2,*p1.f2)
Global Dim lp.f2 (1000)
Global n
Global ScrollMaterialX_l.l
Global ScrollMaterialY_l.l
Global ScrollStatus.b
Global ScrollSpeed.w
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ScrollMaterialX_l = 0
ScrollMaterialY_l = 0
ScrollStatus = 0
ScrollSpeed = 100
ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0)*0.8, DesktopHeight(0)*0.8, "CreateShader - [Esc] quit", #PB_Window_ScreenCentered)
OpenWindowedScreen ( WindowID (0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
CreateCamera (0, 0, 0, 100, 100)
MoveCamera (0, 100, 100, -500, #PB_Absolute | #PB_World)
CameraLookAt (0, 0, 0, 0)
CreateLight (0, $FFFFFF, -100, 100, 100)
AmbientColor ($111111*8)
CameraBackColor (0, $444488)
CreateTexture (1, 475, 300) ; 475
StartDrawing ( TextureOutput (1))
Box (0, 0, 475, 300, $FFAAAAAA) ; 475
For x = 0 To 475 Step 95
LineXY (x, 10, x+90, 150, $FF0000FF)
LineXY (x+1, 10, x+91, 150, $FF0000FF)
LineXY (x+90, 150, x, 290, $FF0000FF)
LineXY (x+91, 150, x+1, 290, $FF0000FF)
Next
StopDrawing ()
CreateMaterial (0, TextureID (1))
MaterialShininess (0, 64) ;,$ffffff)
MaterialFilteringMode (0, #PB_Material_Anisotropic)
MaterialCullingMode (0, #PB_Material_NoCulling)
; ScrollMaterial (0, 1, 0, #PB_Material_Animated)
x0 = 160
y0 = 0
r0 = 20 ; 0.3 coordinates x,y , radius cylinder
x1 = 0 ;-1
y1 = 0
r1 = 20 ;0.3
x2 = 80
y2 = -25 ; -0.5
r2 = 30 ;0.3
la = 300 ;1.5 conveyor belt width
da = 30
arc (x0, y0, r0, -90+da, 90)
arc (x1, y1, r1, 90, 270-da)
arc (x2, y2, r2, 270-da, 270+da)
arc (x0, y0, r0, -90+da, -90+da)
CreateMesh (0)
For i=0 To n-1
i2 = i*2
If i
u + lenght (lp (i-1), lp (i))
EndIf
MeshVertex (lp(i)\x, lp(i)\y, la/2, u, 1, $ffffff, 0, 1, 0)
MeshVertex (lp(i)\x, lp(i)\y, -la/2, u, 0, $ffffff, 0, 1, 0)
If i
MeshFace (i2, i2-2, i2+1) ;i2+1) ,i2)
MeshFace (i2-2, i2-1, i2+1) ;,i2)
EndIf
Next
FinishMesh (#True) ; 1 ; 1
NormalizeMesh (0)
; ScaleMaterial (0, u/2, 1) ; u/10 to match start and end of conveyor belt
ScaleMaterial (0, u, 1) ; u/10 to match start and end of conveyor belt
CreateEntity (0, MeshID (0), MaterialID (0))
Repeat
While WindowEvent ()
Wend
If ScrollStatus = 1
If ScrollMaterialY_l < 100000
ScrollMaterialY_l = ScrollMaterialY_l + ScrollSpeed
Else
ScrollMaterialY_l = 0
EndIf
EndIf
ExamineKeyboard ()
If KeyboardReleased (#PB_Key_Space)
If ScrollStatus = 0
ScrollStatus = 1
ElseIf ScrollStatus = 1
ScrollStatus = 0
EndIf
EndIf
ExamineMouse ()
If MouseWheel() > 0
If ScrollSpeed < 1000
ScrollSpeed = ScrollSpeed + 10
EndIf
ElseIf MouseWheel() < 0
If ScrollSpeed > -1000
ScrollSpeed = ScrollSpeed - 10
EndIf
EndIf
;- TEST = UNCOMMENT
; RotateMaterial (0, 0.0, #PB_Material_Fixed)
;- TEST = COMMENT
RotateMaterial (0, 0.001, #PB_Material_Fixed)
ScrollMaterial (0, 0, ScrollMaterialY_l, #PB_Material_Fixed) ;, 0)
RenderWorld ()
StartDrawing (ScreenOutput())
DrawingMode (#PB_2DDrawing_Transparent)
DrawText (10, 10, "To Quit program = Esc Key", $FF101010, $FF000000)
DrawText (10, 25, "Start/Stop Scolling = SpaceBar", $FF101010, $FF000000)
DrawText (10, 40, "BeltSpeed Up/Down = +-MouseWheel", $FF101010, $FF000000)
DrawText (10, 75, "Scroll X : " + Str (ScrollMaterialX_l), $FF101010, $FF000000)
DrawText (10, 90, "Scroll Y : " + Str (ScrollMaterialY_l), $FF101010, $FF000000)
If ScrollStatus = 0
DrawText (10, 115, "Scroll Start/Stop : STOPPED", $FF101010, $FF000000)
Else
DrawText (10, 115, "Scroll Start/Stop : RUNNING", $FF101010, $FF000000)
EndIf
DrawText (10, 130, "ScrollSpeed : " + Str (ScrollSpeed), $FF101010, $FF000000)
StopDrawing ()
FlipBuffers ()
Delay (1)
Until KeyboardReleased(#PB_Key_Escape) Or MouseButton(3)
End
Procedure.f lenght (*p0.f2, *p1.f2)
Protected.f dx = *p1\x-*p0\x
Protected.f dy = *p1\y-*p0\y
ProcedureReturn Sqr (dx * dx + dy * dy)
EndProcedure
Procedure LpAdd (x.f, y.f)
lp(n)\x = x
lp(n)\y = y
n+1
EndProcedure
Procedure arc (x.f, y.f, r.f, ai.f, af.f)
Protected.f a, da = 360/64
a = ai
While a = <af
a+da
LpAdd (x + Cos ( Radian (a))*r, y + Sin ( Radian (a))*r)
Wend
EndProcedure
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
- pf shadoko
- Enthusiast
- Posts: 386
- Joined: Thu Jul 09, 2015 9:07 am
Re: My machine OGRE texture rotation problem ...
you're using values that are far too large!
it's the x parameter you need to modify
if you have a 60Hz framerate, a 1/60 offset will shift the length of your texture every second
I've made a few small changes to your code
note: startdrawing(screenoutput()) isn't very good (very slow), better use a sprite
it's the x parameter you need to modify
if you have a 60Hz framerate, a 1/60 offset will shift the length of your texture every second
I've made a few small changes to your code
note: startdrawing(screenoutput()) isn't very good (very slow), better use a sprite
Code: Select all
;- To do the test : Comment line 151 / Comment line 154 or visa versa
EnableExplicit
Structure f2
x.f
y.f
EndStructure
Define.f x0, y0, r0, x1, y1, r1, x2, y2, r2, la, ai, af, a, da, u
Define.f MouseX, Mousey, depx, depz, dist, val, blend
Define i.w
Define j.w
Define x.w
Define i2.w
Declare arc (x.f, y.f, r.f, ai.f, af.f)
Declare LpAdd (x.f, y.f)
Declare.f lenght (*p0.f2,*p1.f2)
Global Dim lp.f2 (1000)
Global n
Global ScrollMaterialX_l.f
Global ScrollStatus.b
Global ScrollSpeed.f
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ScrollMaterialX_l = 0
ScrollStatus = 0
ScrollSpeed = 0.001
ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0)*0.8, DesktopHeight(0)*0.8, "CreateShader - [Esc] quit", #PB_Window_ScreenCentered)
OpenWindowedScreen ( WindowID (0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
CreateCamera (0, 0, 0, 100, 100)
MoveCamera (0, 100, 100, -500, #PB_Absolute | #PB_World)
CameraLookAt (0, 0, 0, 0)
CreateLight (0, $FFFFFF, -100, 100, 100)
AmbientColor ($111111*8)
CameraBackColor (0, $444488)
CreateTexture (1, 475, 300) ; 475
StartDrawing ( TextureOutput (1))
Box (0, 0, 475, 300, $FFAAAAAA) ; 475
For x = 0 To 475 Step 95
LineXY (x, 10, x+90, 150, $FF0000FF)
LineXY (x+1, 10, x+91, 150, $FF0000FF)
LineXY (x+90, 150, x, 290, $FF0000FF)
LineXY (x+91, 150, x+1, 290, $FF0000FF)
Next
StopDrawing ()
CreateMaterial (0, TextureID (1))
MaterialShininess (0, 64):SetMaterialColor(0,#PB_Material_SpecularColor,$ffffff)
MaterialFilteringMode (0, #PB_Material_Anisotropic)
MaterialCullingMode (0, #PB_Material_NoCulling)
; ScrollMaterial (0, 1, 0, #PB_Material_Animated)
x0 = 160
y0 = 0
r0 = 20 ; 0.3 coordinates x,y , radius cylinder
x1 = 0 ;-1
y1 = 0
r1 = 20 ;0.3
x2 = 80
y2 = -25 ; -0.5
r2 = 30 ;0.3
la = 300 ;1.5 conveyor belt width
da = 30
arc (x0, y0, r0, -90+da, 90)
arc (x1, y1, r1, 90, 270-da)
arc (x2, y2, r2, 270-da, 270+da)
arc (x0, y0, r0, -90+da, -90+da)
CreateMesh (0)
For i=0 To n-1
i2 = i*2
If i
u + lenght (lp (i-1), lp (i))
EndIf
MeshVertex (lp(i)\x, lp(i)\y, la/2, u, 1, $ffffff, 0, 1, 0)
MeshVertex (lp(i)\x, lp(i)\y, -la/2, u, 0, $ffffff, 0, 1, 0)
If i
MeshFace (i2, i2-2, i2+1) ;i2+1) ,i2)
MeshFace (i2-2, i2-1, i2+1) ;,i2)
EndIf
Next
FinishMesh (#True) ; 1 ; 1
NormalizeMesh (0)
; ScaleMaterial (0, u/2, 1) ; u/10 to match start and end of conveyor belt
ScaleMaterial (0, u, 1) ; u/10 to match start and end of conveyor belt
CreateEntity (0, MeshID (0), MaterialID (0))
Repeat
While WindowEvent ()
Wend
If ScrollStatus = 1
ScrollMaterialx_l + ScrollSpeed
EndIf
ExamineKeyboard ()
If KeyboardReleased (#PB_Key_Space)
If ScrollStatus = 0
ScrollStatus = 1
ElseIf ScrollStatus = 1
ScrollStatus = 0
EndIf
EndIf
ExamineMouse ()
If MouseWheel() > 0
If ScrollSpeed < 0.1
ScrollSpeed + 0.001
EndIf
ElseIf MouseWheel() < 0
If ScrollSpeed > -0.1
ScrollSpeed - 0.001
EndIf
EndIf
;- TEST = UNCOMMENT
RotateMaterial (0, 0.0, #PB_Material_Fixed)
;- TEST = COMMENT
; RotateMaterial (0, 0.001, #PB_Material_Fixed)
ScrollMaterial (0,ScrollMaterialx_l,0 , #PB_Material_Fixed) ;, 0)
RenderWorld ()
StartDrawing (ScreenOutput())
DrawingMode (#PB_2DDrawing_Transparent)
DrawText (10, 10, "To Quit program = Esc Key", $FF101010, $FF000000)
DrawText (10, 25, "Start/Stop Scolling = SpaceBar", $FF101010, $FF000000)
DrawText (10, 40, "BeltSpeed Up/Down = +-MouseWheel", $FF101010, $FF000000)
DrawText (10, 75, "Scroll X : " + StrF(ScrollMaterialX_l,3), $FF101010, $FF000000)
If ScrollStatus = 0
DrawText (10, 115, "Scroll Start/Stop : STOPPED", $FF101010, $FF000000)
Else
DrawText (10, 115, "Scroll Start/Stop : RUNNING", $FF101010, $FF000000)
EndIf
DrawText (10, 130, "ScrollSpeed : " + StrF(ScrollSpeed,3), $FF101010, $FF000000)
StopDrawing ()
FlipBuffers ()
Delay (1)
Until KeyboardReleased(#PB_Key_Escape) Or MouseButton(3)
End
Procedure.f lenght (*p0.f2, *p1.f2)
Protected.f dx = *p1\x-*p0\x
Protected.f dy = *p1\y-*p0\y
ProcedureReturn Sqr (dx * dx + dy * dy)
EndProcedure
Procedure LpAdd (x.f, y.f)
lp(n)\x = x
lp(n)\y = y
n+1
EndProcedure
Procedure arc (x.f, y.f, r.f, ai.f, af.f)
Protected.f a, da = 360/64
a = ai
While a = <af
a+da
LpAdd (x + Cos ( Radian (a))*r, y + Sin ( Radian (a))*r)
Wend
EndProcedure
Re: My machine OGRE texture rotation problem ...
First at all, what PB version did you used to test my program ??pf shadoko wrote: Sat Apr 20, 2024 10:30 pm it's the x parameter you need to modify
if you have a 60Hz framerate, a 1/60 offset will shift the length of your texture every second
note: startdrawing(screenoutput()) isn't very good (very slow), better use a sprite
If I use the ScrollX, there is nothing at all who is moving ...
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
- pf shadoko
- Enthusiast
- Posts: 386
- Joined: Thu Jul 09, 2015 9:07 am
Re: My machine OGRE texture rotation problem ...
the latest version (but that's not the problem)
have you pressed the space bar ?
have you pressed the space bar ?
Re: My machine OGRE texture rotation problem ...
ScrollMaterial()
Syntax
ScrollMaterial(#Material, x, y, Mode [, Layer])
Description
Scrolls the material layer according to x,y values.
Parameters
#Material The material to use.
x, y The texture scroll offset, in pixels.
Mode It can be one of the following value:
#PB_Material_Fixed : The material is scrolled of the specified x,y offset, without regards of the previous scroll function.
#PB_Material_Animated: Each frame is the material is scrolled of the specified x,y offset automatically.
Layer (optional) The layer to scroll. The first layer is zero (if this parameter is omitted, the layer zero is scrolled).
Return value
None.
This must be my age, to forget the spacebar !!
I was thinking that the Scroll must be in pixels (See the doc).
You are using a float for ScrollMaterialX_l.f
Now I start to understand how it works.
Thanks very much,
marc
Syntax
ScrollMaterial(#Material, x, y, Mode [, Layer])
Description
Scrolls the material layer according to x,y values.
Parameters
#Material The material to use.
x, y The texture scroll offset, in pixels.
Mode It can be one of the following value:
#PB_Material_Fixed : The material is scrolled of the specified x,y offset, without regards of the previous scroll function.
#PB_Material_Animated: Each frame is the material is scrolled of the specified x,y offset automatically.
Layer (optional) The layer to scroll. The first layer is zero (if this parameter is omitted, the layer zero is scrolled).
Return value
None.
This must be my age, to forget the spacebar !!


I was thinking that the Scroll must be in pixels (See the doc).
You are using a float for ScrollMaterialX_l.f
Now I start to understand how it works.
Thanks very much,
marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
- pf shadoko
- Enthusiast
- Posts: 386
- Joined: Thu Jul 09, 2015 9:07 am
Re: My machine OGRE texture rotation problem ...
indeed, another error in the doc
(curiously, in the French version it's ok)
(curiously, in the French version it's ok)
Re: My machine OGRE texture rotation problem ...
Why do you use Blender? A 3D CAD should have the possiblity to create an assembly.Again, for those who are interested ...
How do I work:
1 ) I design all the mechanical parts (sketches) on paper with the needed measurements.
2 ) I design them in a 3D-CAD program.
3 ) I export these data to BLENDER data via COLLADA files (.dea).
4 ) Then import all the COLLADA parts in BLENDER.
5 ) Followed by reconstructing all the parts to one big machine.
Positions and rotations, the scaling is done in the 3D-CAD program.
6 ) Then I use the BLENDER2OGRE exporter to create the .mesh files.
7 ) I import these parts in PB 5.73x64 LTS as geometry
8 ) Inside PB can do some camera motions ...
Which CAD do you use!
Normally it is possible to export directly from CAD to a Mesh or STL File.
For Solid Works there exists a cheep "Maker Version" where you can test all such things.
As you know from my older posts I try to load 3D Step-Files directly to PB. But this is still a
hard job and I have to less time to finish it!
At the end I will have same problems as you:
- how to show that parts correctly on the screenand how to move it!
But for STL files I got it.
Re: My machine OGRE texture rotation problem ...
Hello SMaag,
It is some time I heard from you ...
Good to see you back.
Well I love BLENDER,
I bought (some time ago) all there books and stuff like CD/DVD's to support them.
And, I'm used to using the program for my needs.
also, and the most important, I can create textures/materials inside BLENDER I can't in my CAD/CAM program.
With BLENDER I can edit/sculpt some objects that I can't with CAD program.
Yes, I can directly export from my CAD program to STL ...
I'm doing some transparent light knobs for use in my program,
BLENDER is better for this than my CAD program.
Greetings,
Marc
It is some time I heard from you ...
Good to see you back.
Well I love BLENDER,
I bought (some time ago) all there books and stuff like CD/DVD's to support them.
And, I'm used to using the program for my needs.
also, and the most important, I can create textures/materials inside BLENDER I can't in my CAD/CAM program.
With BLENDER I can edit/sculpt some objects that I can't with CAD program.
Yes, I can directly export from my CAD program to STL ...
I'm doing some transparent light knobs for use in my program,
BLENDER is better for this than my CAD program.
Greetings,
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...