Hello agian.
How is everyone?
So i figured it would be simple to make a memblock, then using some for statements fill it with info and then make that into an object. I am having problems with this however and i dont know why.
I guess i am writing to the memblock incorectly or something, and that is what is giving me these strange results.
If anyone has the time could you please* take a look at what i have here.
Here is the code.
// CreateBoard.cpp : The main entrypoint for the application.
//
#include "DarkSDK.h"
#include "resource.h"
#include "stdio.h"
#include "stdlib.h"
#include "io.h"
void DarkSDK (void)
{
dbSyncOn();
dbSyncRate(0);
int verts, triangles, tiles, tilesPerRow, mbSize;
tilesPerRow=32;
tiles=tilesPerRow*tilesPerRow;
triangles=tiles*2;
verts=triangles*3;//6156=number of verts
mbSize=4+4+4+(36*verts);
dbMakeMemblock(1,mbSize);//#,size
dbWriteMemblockDWORD(1,0,338);
dbWriteMemblockDWORD(1,4,36);
dbWriteMemblockDWORD(1,8,verts);
int diffuse=dbRgb(0,0,0);
int offset=12;
//All this crap is just used (Hopefully) to do the UVs
int right=0, bottom=0;
float uLow, uHigh;
float vLow, vHigh;
// 0 3---5
// | \ \ |
// | \ \ |
// | \ \|
// 1----2 4
// 0=(0,0)
// 1=(0,1)
// 2=(1,1)
// 3=(0,0)
// 4=(1,1)
// 5=(1,0)
for(int i=0; i<tilesPerRow; i++) {
if(bottom) {
vLow=0.5;
vHigh=1.0;
}
else {
vLow=0.0;
vHigh=0.5;
}
for(int j=0; j<tilesPerRow; j++) {
if(right) {
uLow=0.5;
uHigh=1.0;
}
else {
uLow=0.0;
uHigh=0.5;
}
//0
//position
dbWriteMemblockFloat(1,offset+=4,j);
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,i);
//normal
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,1);
dbWriteMemblockFloat(1,offset+=4,0);
//difuse
dbWriteMemblockDWORD(1,offset+=4,diffuse);
//uv
dbWriteMemblockFloat(1,offset+=4,uLow);
dbWriteMemblockFloat(1,offset+=4,vLow);
//1
//position
dbWriteMemblockFloat(1,offset+=4,j);
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,i+1);
//normal
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,1);
dbWriteMemblockFloat(1,offset+=4,0);
//difuse
dbWriteMemblockDWORD(1,offset+=4,diffuse);
//uv
dbWriteMemblockFloat(1,offset+=4,uLow);
dbWriteMemblockFloat(1,offset+=4,vHigh);
//2
//position
dbWriteMemblockFloat(1,offset+=4,j+1);
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,i+1);
//normal
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,1);
dbWriteMemblockFloat(1,offset+=4,0);
//difuse
dbWriteMemblockDWORD(1,offset+=4,diffuse);
//uv
dbWriteMemblockFloat(1,offset+=4,uHigh);
dbWriteMemblockFloat(1,offset+=4,vHigh);
//3
//position
dbWriteMemblockFloat(1,offset+=4,j);
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,i);
//normal
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,1);
dbWriteMemblockFloat(1,offset+=4,0);
//difuse
dbWriteMemblockDWORD(1,offset+=4,diffuse);
//uv
dbWriteMemblockFloat(1,offset+=4,uLow);
dbWriteMemblockFloat(1,offset+=4,vLow);
//4
//position
dbWriteMemblockFloat(1,offset+=4,j+1);
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,i+1);
//normal
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,1);
dbWriteMemblockFloat(1,offset+=4,0);
//difuse
dbWriteMemblockDWORD(1,offset+=4,diffuse);
//uv
dbWriteMemblockFloat(1,offset+=4,uHigh);
dbWriteMemblockFloat(1,offset+=4,vHigh);
//5
//position
dbWriteMemblockFloat(1,offset+=4,j+1);
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,i);
//normal
dbWriteMemblockFloat(1,offset+=4,0);
dbWriteMemblockFloat(1,offset+=4,1);
dbWriteMemblockFloat(1,offset+=4,0);
//difuse
dbWriteMemblockDWORD(1,offset+=4,diffuse);
//uv
dbWriteMemblockFloat(1,offset+=4,uHigh);
dbWriteMemblockFloat(1,offset+=4,vLow);
right = !right;
}
bottom = !bottom;
}
dbAutoCamOn();
dbLoadImage("tile.jpg",1);
dbMakeMeshFromMemblock(1,1);
dbMakeObject(1,1,1);
// loop until the escape key is pressed
float cameraAngleX=0,cameraAngleY=0;
while (LoopSDK())
{
if (dbEscapeKey())
break;
cameraAngleX+=dbMouseMoveX();
cameraAngleY+=dbMouseMoveY();
dbControlCameraUsingArrowKeys(0,0.002,1);
dbYRotateCamera(cameraAngleX);
dbXRotateCamera(cameraAngleY);
dbSync();
}
}
*indecates intencly sencire begging and/or groveling.
Keep it simple.
Otherwise, you may not be clever enough.