3D Mesh in C++Builder

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

3D Mesh in C++Builder

Postby MyVCL2015 » Tue Jul 14, 2015 11:40 am

I have been looking at the Delphi 3D Mesh project available in the web page below. This Delphi code is too complex for me to translate to C++. Is there any similar 3D Mesh example written in C++Builder? Thanks

Delphi 3D Mesh
http://www.efg2.com/Lab/Graphics/ThreeDLab.htm
MyVCL2015
 
Posts: 5
Joined: Mon Jun 22, 2015 11:48 pm

Re: 3D Mesh in C++Builder

Postby rlebeau » Wed Jul 15, 2015 2:38 pm

MyVCL2015 wrote:This Delphi code is too complex for me to translate to C++.


Why translate it at all then? Did you know that you can use Delphi code in C++Builder projects? Well, you can. Simply add a Delphi .pas file to your C++Builder project, compile it so a C++ .hpp file is generated, and then you can #include that .hpp file in your C++ code and use the types/functions declared in it as needed.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1509
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: 3D Mesh in C++Builder

Postby MyVCL2015 » Sun Jul 19, 2015 4:58 pm

I have that Delphi project working C++Builder. It creates a class (TPantoGraph - see below) that has a canvas which is passed around to procedures. Using this Class and passing the canvas makes the Delphi code difficult to use outside the demo project. I am trying to get the 3D Mesh to draw on the TDirect2DCanvas. If I can get something working I will upload a C++Builder project.


// A PantoGraph object maps "World Coordinates" to a Delphi "Canvas".
// These World Coordinates are DOUBLE values that are defined using
// regular mathematical conventions. This means that instead of having
// increasing "Y" values as you go down a canvas, "Y" increases as you go
// up using the computer "pantograph".
TPantoGraph =
CLASS(TObject)
PRIVATE
iSave : INTEGER;
jSave : INTEGER;

vcx,vcy : DOUBLE; // 3D projection center-size viewport parms
vsx,vsy : DOUBLE;

xform2D : TMatrix; // default 2D transformation matrix
xform3D : TMatrix; // default 3D transformation matrix

uSaveW : TVector; // last vector -- world coordinates
// (used for relativePosition Positioning)
uSaveX : TVector; // last vector -- transformed

projection : TProjection;
ClipFlag : BOOLEAN;
positioning: TPositioning;
coordinate : TCoordinate;

PROTECTED
iMax : INTEGER; // size of viewport in pixels
jMax : INTEGER;

iEast : INTEGER; // ViewPort parameters
iWest : INTEGER;
jSouth : INTEGER;
jNorth : INTEGER;

xEast : DOUBLE; // World Coordinates of Canvas
xWest : DOUBLE;
yNorth : DOUBLE;
ySouth : DOUBLE;

xPixel : DOUBLE; // pixels per world unit horizontally
yPixel : DOUBLE; // pixels per world unit vertically

PUBLIC
Canvas : TCanvas;

CONSTRUCTOR Create (CONST PantoCanvas: TCanvas);
DESTRUCTOR Destroy;
Override;

PROCEDURE LineToIJ (CONST i,j: INTEGER); // interface to TCanvas
PROCEDURE MoveToIJ (CONST i,j: INTEGER);
PROCEDURE PointAtIJ (CONST i,j: INTEGER);
PROCEDURE RectangleIJ (CONST i1,i2, j1,j2: INTEGER);
PROCEDURE SetColor (CONST color: TColor);

PROCEDURE LineTo (CONST v: TVector); // draw 2D/3D vectors
PROCEDURE MoveTo (CONST v: TVector);
PROCEDURE PointAt (CONST v: TVector);
PROCEDURE Rectangle (CONST v1, v2: TVector);

PROCEDURE TextOutIJ (CONST i,j: INTEGER; CONST Text: STRING);
PROCEDURE TextOut (CONST v: TVector; CONST Text: STRING);

PROCEDURE SetPositioning (CONST p: TPositioning); // Relative or Absolute
PROCEDURE SetRelativeBase (CONST v: TVector);

// Clipping
PROCEDURE Clip (VAR u1,u2: TVector; VAR visible: BOOLEAN);
PROCEDURE SetClipping (CONST flag: BOOLEAN);

// 3D-to-2D Projection
PROCEDURE Project (CONST u: TVector; VAR v: TVector);
PROCEDURE SetProjection (CONST PrjType: TProjection);

// Default Transformation Matrices
PROCEDURE ClearTransform (CONST d: Tdimension);
PROCEDURE GetTransform (CONST d: Tdimension; VAR a: TMatrix);
PROCEDURE SetTransform (CONST a: TMatrix);
PROCEDURE VectorTransform (CONST u: TVector; VAR v: TVector);

// Windows / Viewports
PROCEDURE WorldCoordinatesRange (CONST xMin, xMax, yMin, yMax: DOUBLE);
PROCEDURE ViewPort (CONST xFractionMin, xFractionMax,
yFractionMin, yFractionMax: DOUBLE);
PROCEDURE ShowViewPortOutline;

// World/Pixel Coordinate Conversion
PROCEDURE WorldToPixel (CONST v: TVector; VAR i,j: INTEGER);
PROCEDURE PixelToWorld (CONST i,j: INTEGER; VAR visible: BOOLEAN;
VAR x,y: DOUBLE);

// Set coordinate type
PROCEDURE SetCoordinateType (CONST c: Tcoordinate);

END;
MyVCL2015
 
Posts: 5
Joined: Mon Jun 22, 2015 11:48 pm


Return to Technical

Who is online

Users browsing this forum: Bing [Bot] and 5 guests

cron