Hi,
I need to draw a cone and cylinder but I have written some code but doesn’t display anything:
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using RS.Common;
namespace GraficaDemo
{
public class Con : BaseObject
{
public Con(Vector3 position, int iShaderProgram, PrimitiveType drawType) : base(iShaderProgram, drawType)
{
var data = new List<float>();
var indices = new List<uint>();
var h = 100;
var r = 50;
double theta = Math.PI / 4;
int M = 50;
double x;
double y;
double z;
for (double i = 0; i <= h; i = i + 0.1) {
for (int j = 0; j < M; j++) {
x = (h - i) / r * Math.Cos(theta);
y = (h - i) / r * Math.Sin(theta);
z = i;
data.Add(DataConverter.ToFloat(x));
data.Add(DataConverter.ToFloat(y));
data.Add(DataConverter.ToFloat(z));
}
}
model = Matrix4.CreateTranslation(position);
Load(data.ToArray(), indices.ToArray(), true);
}
}
}
The Load() function is wrote by my teacher but he doesn’t want to explain how can I make the VBO or indices so I need those too but I don’t know how to make them or generate them…and I can’t even know if the code it’s good.
Thanks a lot !!!