Comments (6)
Following code using DrawModelEx fixes the spinning for me on Windows:
unit frm1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
ray_header;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
public
FCamera:TCamera;
FModel:TModel;
FTexture:TTexture2D;
FPosition:TVector3;
FAnimationCount, FAnimationFrameCounter:Integer;
FAnimations:PModelAnimation;
end;
var
Form1: TForm1;
procedure DrawModel(AModel:TModel; APosition:TVector3; AAxis:TVector3; AAngle:Single; AScale:Single; ATint:TColor);
implementation
{$R *.lfm}
procedure DrawModel(AModel:TModel; APosition:TVector3; AAxis:TVector3; AAngle:Single; AScale:Single; ATint:TColor);
var
Scale, Axis:TVector3;
begin
Scale:=Vector3Create(AScale,AScale,AScale);
DrawModelEx(AModel, APosition, AAxis, AAngle, Scale, ATint);
end;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
I:Integer;
begin
InitWindow(1280, 720, 'Animation Test');
FCamera.Position:=Vector3Create(15.0, 15.0, 15.0);
FCamera.Target:=Vector3Create(0.0,0.0,0.0);
FCamera.Up:=Vector3Create(0.0, 1.0, 0.0);
FCamera.FoVY:=45;
FCamera.Projection:=CAMERA_PERSPECTIVE;
FModel:=LoadModel('guy.iqm');
FTexture:=LoadTexture('guytex.png');
SetMaterialTexture(@FModel.Materials[0], MATERIAL_MAP_DIFFUSE, FTexture);
FPosition:=Vector3Create(0,0,0);
FAnimationCount:=0;
FAnimations:=LoadModelAnimations('guy.iqm', @FAnimationCount);
FAnimationFrameCounter:=0;
WriteLn('animation count: ', FAnimationCount);
SetCameraMode(FCamera, CAMERA_FREE);
SetTargetFPS(60);
while not WindowShouldClose() do
begin
UpdateCamera(@FCamera);
if IsKeyDown(KEY_SPACE)
then
begin
Inc(FAnimationFrameCounter);
UpdateModelAnimation(FModel, FAnimations[0], FAnimationFrameCounter);
if FAnimationFrameCounter>=FAnimations[0].FrameCount
then
FAnimationFrameCounter:=0;
end;
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3d(FCamera);
DrawModel(FModel, FPosition, Vector3Create(1.0, 0.0, 0.0), -45, 1, WHITE);
for I:=0 to FModel.BoneCount - 1 do
begin
DrawCube(FAnimations[0].FramePoses[FAnimationFrameCounter][I].Translation, 0.2, 0.2, 0.2, RED);
end;
DrawGrid(10,1);
EndMode3D();
DrawFPS(10,10);
EndDrawing();
end;
UnloadTexture(FTexture);
for I:=0 to FAnimationCount - 1 do
UnloadModelAnimation(FAnimations[I]);
UnloadModel(FModel);
CloseWindow();
end;
end.
from ray4laz.
Yes, I know that. But this behavior is only on Windows. In Linux ase everything works fine. As soon as I get a chance I will try to solve it.
from ray4laz.
There is probably an error in raylib. You need to compile examples from raylib in Windows and check. For example there was a bug loading voxel models on linux.
from ray4laz.
Ok, thanks for the support. I will be using Ray4Laz extensively and will try to help out wherever I can.
from ray4laz.
Thank you.
but why are you using this to create a form?
If you need it to be OOP style, look here
https://github.com/GuvaCode/Ray4Laz-Extras
https://github.com/GuvaCode/Ray4Laz-Extras/blob/master/source/ray_application.pas
from ray4laz.
No problem, thanks for the link. I just had this up where I reformatted it, but was meaning to update it anyway :)
from ray4laz.
Related Issues (16)
- RayGuy 3.0 HOT 7
- BindPose/FramePoses Rotation not working HOT 4
- GuiTextBox partialy functioning HOT 9
- How to publish as apk HOT 1
- Add to static link HOT 1
- How easy would it be to make a basic Lazarus game editor with this? HOT 3
- Delphi support HOT 3
- raylib window context to OpenGLControl (initial code) HOT 16
- Basic lighting example is black HOT 8
- How to run without Lazarus?
- Move examples to a separate repo HOT 1
- android platform HOT 2
- Some examples don't work for me HOT 5
- Nothing works HOT 3
- Unable to Run HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ray4laz.