Sign in to follow this  
EDBarrera

3D libraries in C or Java?

Recommended Posts

Hi, first of all I putted this question in Graphics Programming and Theory and I received answers about others tecnologies. Now, I put this message here. But I need people who know C and/or Java and they can tell me which of this programming language is better to create real-time rendering. And I'm grateful for people who answer me in the other side and here because they waste their time to answer. Thanks. I do not know how to start with my own 3D libraries like points, vectors, matrices, etc. I know Java and C. Java is Object Oriented Programming. C is Structure Programming. And I have a dilemma: Java represents the objects in the real world better than C, it encapsulates data and functions and you can have an entity Matrix to rotate points, etc. But because an entity like that has method like getX(), getY() and so on, when you want to do some mathematic calculations like multiplicate points with a matrix sush as: Point3D[] points = {new Point3D(2.0, 3.0, 4.0), ..., ...}; // Array of points 3D ... Matrix3DHomogeneous m = new Matrix3DHomogeneous(); Vector3D v = new Vector3D(0.0, 2.0, 0.0); m.translate(v); // Create an homogeneous matrix to translate points. m.transform(points); // Receive arrays of points and transforms them modifyng their coordinate. it may be take much time than C because you call more methods (functions) than C imaging that transform method do the following: Point3D p = null; for (int i = 0; i < points.length; i++) { p = points[i]; // Multiplicate points with the matrix using p.getX(), p.getY(), p.getZ()... } C does not have entity but you can use struct and header files to create something like entity in Java, for example a point and functions: point.h struct point { double x, y, z } transform.h void transform(point p) { ... = p.x; ... = p.y; ... = p.z; ... } Another problem is when a method receives an object you can modify its data or you can return a new object with new data. For example: Point3D[] points = {new Point3D(2.0, 3.0, 4.0), ..., ...}; // Array of points 3D ... Matrix3DHomogeneous m = new Matrix3DHomogeneous(); Vector3D v = new Vector3D(0.0, 2.0, 0.0); m.translate(v); // Create an homogeneous matrix to translate points. points = m.transform(points); // Receive arrays of points and transform them modifyng their coordinate. // See that the argument points is modifing inside the Matrix and then this method (transform) // return a new array with new points. The example above has another problem for me. I think to do it when I though that you maybe have points referensed with two or more variables and if you modify values of one variable you have to modify the other variables but calling p.setX(x), p.setY(y) or p.setComponents(x, y, z) continues to call more methods than p.x = x; p.y = y, etc. But, in the case that this is good implemented when you create object and object and object...the memory is very fill of this object maybe innecesary. Well, I think C is faster access to p.x than p.getX() and then do p.x = 0.0 instead of p.setX(0.0); because you do not call method. Imagine it in all point that you need to show and image 3D on screen and imagine other similar situations with other entities. But use p.getX() is better thatn p.x because you do not how is implemented the code inside the class and you can use p.getX() where you want and it is clearer than C. You can return a new point without affect the original point, in this case, the argument point: Point3D p = m.translate(point); Maybe this is not very important but I want to create good libraries while I learn real-time rendering. I would choose Java but C has its own power and run faster than Java, and it runs in a poor machine, Java need a best machine. Java is clearer than C and is a good programming language. I need your advice and thank you for your help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this